]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/staging/bcm/Arp.c
4 * Abstract: This file contains the routines for handling ARP PACKETS
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
18 * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt.
21 * =========================================================================*/
24 reply_to_arp_request(struct sk_buff
*skb
)
26 PMINI_ADAPTER Adapter
;
27 struct ArpHeader
*pArpHdr
= NULL
;
28 struct ethhdr
*pethhdr
= NULL
;
30 /* Check for valid skb */
33 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_PRINTK
, 0, 0, "Invalid skb: Cannot reply to ARP request\n");
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
))
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
);
90 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_TX
, ARP_RESP
, DBG_LVL_ALL
, "<=============\n");