ALSA: hda - Add static_hdmi_pcm option to HDMI codec parser
[linux-2.6/next.git] / drivers / staging / bcm / Arp.c
blobd60d8593d2efef918562b501979b9406dbab5eea
2 /*
3 * File Name: Arp.c
4 * Abstract: This file contains the routines for handling ARP PACKETS
5 */
6 #include "headers.h"
7 #define ARP_PKT_SIZE 60
9 /* =========================================================================
10 * Function - reply_to_arp_request()
12 * Description - When this host tries to broadcast ARP request packet through
13 * the virtual interface (veth0), reply directly to upper layer.
14 * This function allocates a new skb for ARP reply packet,
15 * fills in the fields of the packet and then sends it to
16 * upper layer.
18 * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt.
20 * Returns - None
21 * =========================================================================*/
23 VOID
24 reply_to_arp_request(struct sk_buff *skb)
26 PMINI_ADAPTER Adapter;
27 struct ArpHeader *pArpHdr = NULL;
28 struct ethhdr *pethhdr = NULL;
29 UCHAR uiIPHdr[4];
30 /* Check for valid skb */
31 if(skb == NULL)
33 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid skb: Cannot reply to ARP request\n");
34 return;
38 Adapter = GET_BCM_ADAPTER(skb->dev);
39 /* Print the ARP Request Packet */
40 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP Packet Dump :");
41 BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len);
44 * Extract the Ethernet Header and Arp Payload including Header
46 pethhdr = (struct ethhdr *)skb->data;
47 pArpHdr = (struct ArpHeader *)(skb->data+ETH_HLEN);
49 if(Adapter->bETHCSEnabled)
51 if(memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN))
53 bcm_kfree_skb(skb);
54 return;
58 // Set the Ethernet Header First.
59 memcpy(pethhdr->h_dest, pethhdr->h_source, ETH_ALEN);
60 if(!memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN))
62 pethhdr->h_source[5]++;
65 /* Set the reply to ARP Reply */
66 pArpHdr->arp.ar_op = ntohs(ARPOP_REPLY);
68 /* Set the HW Address properly */
69 memcpy(pArpHdr->ar_sha, pethhdr->h_source, ETH_ALEN);
70 memcpy(pArpHdr->ar_tha, pethhdr->h_dest, ETH_ALEN);
72 // Swapping the IP Adddress
73 memcpy(uiIPHdr,pArpHdr->ar_sip,4);
74 memcpy(pArpHdr->ar_sip,pArpHdr->ar_tip,4);
75 memcpy(pArpHdr->ar_tip,uiIPHdr,4);
77 /* Print the ARP Reply Packet */
79 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP REPLY PACKET: ");
81 /* Send the Packet to upper layer */
82 BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len);
84 skb->protocol = eth_type_trans(skb,skb->dev);
85 skb->pkt_type = PACKET_HOST;
87 // skb->mac.raw=skb->data+LEADER_SIZE;
88 skb_set_mac_header (skb, LEADER_SIZE);
89 netif_rx(skb);
90 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "<=============\n");
91 return;