#include "lwip/pbuf.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
Include dependency graph for arp.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | eth_addr |
struct | eth_hdr |
Defines | |
#define | ARP_TMR_INTERVAL 10000 |
#define | ETHTYPE_ARP 0x0806 |
#define | ETHTYPE_IP 0x0800 |
Functions | |
void | string2mac (struct eth_addr *mac, char *name) |
void | mac2string (struct eth_addr *mac, char *name) |
void | arp_init (void) |
void | arp_tmr (void) |
void | arp_ip_input (struct netif *netif, struct pbuf *p) |
pbuf * | arp_arp_input (struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) |
eth_addr * | arp_lookup (struct ip_addr *ipaddr) |
pbuf * | arp_query (struct netif *netif, struct eth_addr *ethaddr, struct ip_addr *ipaddr) |
Variables | |
eth_addr | PACK_STRUCT_STRUCT |
|
Definition at line 62 of file arp.h. Referenced by rt_3c905cif_init(), rt_3com905cif_etharp_timer(), rt_rtl8139_ifetharp_timer(), and rt_rtl8139if_init(). |
|
Definition at line 64 of file arp.h. Referenced by arp_arp_input(), arp_query(), etharp_arp_input(), etharp_query(), rt_3c905cif_input(), and rt_rtl8139if_input(). |
|
Definition at line 65 of file arp.h. Referenced by arp_arp_input(), arp_query(), etharp_arp_input(), etharp_output(), etharp_query(), rt_3c905cif_input(), rt_rtl8139if_input(), and update_arp_entry(). |
|
Definition at line 257 of file arp.c. References add_arp_entry(), ARP_REPLY, ARP_REQUEST, ARPH_HWLEN_SET, ARPH_PROTOLEN_SET, ETHTYPE_ARP, ETHTYPE_IP, htons, HWTYPE_ETHERNET, netif::ip_addr, ip_addr_cmp, ip_addr_set, NULL, pbuf::payload, pbuf_free(), pbuf::tot_len, and u8_t.
00258 { 00259 struct arp_hdr *hdr; 00260 u8_t i; 00261 00262 if(p->tot_len < sizeof(struct arp_hdr)) { 00263 00264 pbuf_free(p); 00265 return NULL; 00266 } 00267 00268 hdr = p->payload; 00269 00270 switch(htons(hdr->opcode)) { 00271 case ARP_REQUEST: 00272 /* ARP request. If it asked for our address, we send out a 00273 reply. */ 00274 00275 if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { 00276 hdr->opcode = htons(ARP_REPLY); 00277 00278 ip_addr_set(&(hdr->dipaddr), &(hdr->sipaddr)); 00279 ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr)); 00280 00281 for(i = 0; i < 6; ++i) { 00282 hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i]; 00283 hdr->shwaddr.addr[i] = ethaddr->addr[i]; 00284 hdr->ethhdr.dest.addr[i] = hdr->dhwaddr.addr[i]; 00285 hdr->ethhdr.src.addr[i] = ethaddr->addr[i]; 00286 } 00287 00288 hdr->hwtype = htons(HWTYPE_ETHERNET); 00289 ARPH_HWLEN_SET(hdr, 6); 00290 00291 hdr->proto = htons(ETHTYPE_IP); 00292 ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr)); 00293 00294 hdr->ethhdr.type = htons(ETHTYPE_ARP); 00295 return p; 00296 } 00297 break; 00298 case ARP_REPLY: 00299 /* ARP reply. We insert or update the ARP table. */ 00300 00301 if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { 00302 add_arp_entry(&(hdr->sipaddr), &(hdr->shwaddr)); 00303 #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) 00304 dhcp_arp_reply(&hdr->sipaddr); 00305 #endif 00306 } 00307 break; 00308 default: 00309 00310 break; 00311 } 00312 00313 pbuf_free(p); 00314 return NULL; 00315 } |
Here is the call graph for this function:
|
Definition at line 155 of file arp.c. References arp_table, IP_ADDR_ANY, ip_addr_set, ipaddr, and u8_t.
00156 { 00157 u8_t i; 00158 00159 for(i = 0; i < ARP_TABLE_SIZE; ++i) { 00160 ip_addr_set(&(arp_table[i].ipaddr), 00161 IP_ADDR_ANY); 00162 } 00163 } |
|
Definition at line 242 of file arp.c. References add_arp_entry(), netif::ip_addr, ip_addr_maskcmp, netif::netmask, and pbuf::payload.
00243 { 00244 struct ethip_hdr *hdr; 00245 00246 hdr = p->payload; 00247 00248 /* Only insert/update an entry if the source IP address of the 00249 incoming IP packet comes from a host on the local network. */ 00250 if(!ip_addr_maskcmp(&(hdr->ip.src), &(netif->ip_addr), &(netif->netmask))) { 00251 return; 00252 } 00253 add_arp_entry(&(hdr->ip.src), &(hdr->eth.src)); 00254 } |
Here is the call graph for this function:
|
Definition at line 318 of file arp.c. References arp_table, arp_entry::ethaddr, ip_addr_cmp, ipaddr, NULL, and u8_t.
00319 { 00320 u8_t i; 00321 00322 for(i = 0; i < ARP_TABLE_SIZE; ++i) { 00323 if(ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { 00324 return &arp_table[i].ethaddr; 00325 } 00326 } 00327 return NULL; 00328 } |
|
Definition at line 331 of file arp.c. References ARP_REQUEST, ARPH_HWLEN_SET, ARPH_PROTOLEN_SET, ETHTYPE_ARP, ETHTYPE_IP, htons, HWTYPE_ETHERNET, netif::ip_addr, ip_addr_set, ipaddr, NULL, pbuf_alloc(), PBUF_LINK, PBUF_RAM, and u8_t.
00332 { 00333 struct arp_hdr *hdr; 00334 struct pbuf *p; 00335 u8_t i; 00336 00337 p = pbuf_alloc(PBUF_LINK, sizeof(struct arp_hdr), PBUF_RAM); 00338 if(p == NULL) { 00339 return NULL; 00340 } 00341 00342 hdr = p->payload; 00343 00344 hdr->opcode = htons(ARP_REQUEST); 00345 00346 for(i = 0; i < 6; ++i) { 00347 hdr->dhwaddr.addr[i] = 0x00; 00348 hdr->shwaddr.addr[i] = ethaddr->addr[i]; 00349 } 00350 00351 ip_addr_set(&(hdr->dipaddr), ipaddr); 00352 ip_addr_set(&(hdr->sipaddr), &(netif->ip_addr)); 00353 00354 hdr->hwtype = htons(HWTYPE_ETHERNET); 00355 ARPH_HWLEN_SET(hdr, 6); 00356 00357 hdr->proto = htons(ETHTYPE_IP); 00358 ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr)); 00359 00360 for(i = 0; i < 6; ++i) { 00361 hdr->ethhdr.dest.addr[i] = 0xff; 00362 hdr->ethhdr.src.addr[i] = ethaddr->addr[i]; 00363 } 00364 00365 hdr->ethhdr.type = htons(ETHTYPE_ARP); 00366 return p; 00367 } |
Here is the call graph for this function:
|
Definition at line 166 of file arp.c. References ARP_MAXAGE, arp_table, ctime, arp_entry::ctime, IP_ADDR_ANY, ip_addr_isany, ip_addr_set, ipaddr, and u8_t.
00167 { 00168 u8_t i; 00169 00170 ++ctime; 00171 for(i = 0; i < ARP_TABLE_SIZE; ++i) { 00172 if(!ip_addr_isany(&arp_table[i].ipaddr) && 00173 ctime - arp_table[i].ctime >= ARP_MAXAGE) { 00174 ip_addr_set(&(arp_table[i].ipaddr), 00175 IP_ADDR_ANY); 00176 } 00177 } 00178 } |
|
Definition at line 138 of file arp.c. References get_char_from_u8_t(), name, and u8_t.
00138 { 00139 int i,hop=0; 00140 u8_t aux; 00141 00142 for(i=0; i<5; i++){ 00143 aux = mac->addr[i]; 00144 name[hop] = get_char_from_u8_t((aux & 0xf0)>>4); 00145 name[hop+1] = get_char_from_u8_t((aux & 0x0f)); 00146 name[hop+2] = 0x3a; //0x3a is the code ascii (in hex) for ':' 00147 hop+=3; 00148 } 00149 name[hop] = get_char_from_u8_t((mac->addr[5] & 0xf0)>>4); 00150 name[hop+1] = get_char_from_u8_t((mac->addr[5] & 0x0f)); 00151 } |
Here is the call graph for this function:
|
Definition at line 128 of file arp.c. References get_u8_t_from_char(), and name.
00128 { 00129 int i,hop=0; 00130 00131 for(i=0; i<6; i++){ 00132 mac->addr[i] = get_u8_t_from_char(name[hop],0) + get_u8_t_from_char(name[hop+1],1); 00133 hop+=3; 00134 } 00135 } |
Here is the call graph for this function:
|
|