You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ipv4.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. #include <string.h>
  2. #include <stdint.h>
  3. #include <errno.h>
  4. #include <byteswap.h>
  5. #include <malloc.h>
  6. #include <vsprintf.h>
  7. #include <gpxe/list.h>
  8. #include <gpxe/in.h>
  9. #include <gpxe/arp.h>
  10. #include <gpxe/if_ether.h>
  11. #include <gpxe/pkbuff.h>
  12. #include <gpxe/netdevice.h>
  13. #include <gpxe/ip.h>
  14. #include <gpxe/tcpip.h>
  15. /** @file
  16. *
  17. * IPv4 protocol
  18. *
  19. * The gPXE IP stack is currently implemented on top of the uIP
  20. * protocol stack. This file provides wrappers around uIP so that
  21. * higher-level protocol implementations do not need to talk directly
  22. * to uIP (which has a somewhat baroque API).
  23. *
  24. */
  25. /* Unique IP datagram identification number */
  26. static uint16_t next_ident = 0;
  27. struct net_protocol ipv4_protocol;
  28. /** An IPv4 address/routing table entry */
  29. struct ipv4_miniroute {
  30. /** List of miniroutes */
  31. struct list_head list;
  32. /** Network device */
  33. struct net_device *netdev;
  34. /** Reference to network device */
  35. struct reference netdev_ref;
  36. /** IPv4 address */
  37. struct in_addr address;
  38. /** Subnet mask */
  39. struct in_addr netmask;
  40. /** Gateway address */
  41. struct in_addr gateway;
  42. };
  43. /** List of IPv4 miniroutes */
  44. static LIST_HEAD ( miniroutes );
  45. /** List of fragment reassembly buffers */
  46. static LIST_HEAD ( frag_buffers );
  47. static void ipv4_forget_netdev ( struct reference *ref );
  48. /**
  49. * Add IPv4 minirouting table entry
  50. *
  51. * @v netdev Network device
  52. * @v address IPv4 address
  53. * @v netmask Subnet mask
  54. * @v gateway Gateway address (or @c INADDR_NONE for no gateway)
  55. * @ret miniroute Routing table entry, or NULL
  56. */
  57. static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev,
  58. struct in_addr address,
  59. struct in_addr netmask,
  60. struct in_addr gateway ) {
  61. struct ipv4_miniroute *miniroute;
  62. /* Allocate and populate miniroute structure */
  63. miniroute = malloc ( sizeof ( *miniroute ) );
  64. if ( miniroute ) {
  65. DBG ( "IPv4 add %s", inet_ntoa ( address ) );
  66. DBG ( "/%s ", inet_ntoa ( netmask ) );
  67. if ( gateway.s_addr != INADDR_NONE )
  68. DBG ( "gw %s ", inet_ntoa ( gateway ) );
  69. DBG ( "via %s\n", netdev->name );
  70. /* Record routing information */
  71. miniroute->netdev = netdev;
  72. miniroute->address = address;
  73. miniroute->netmask = netmask;
  74. miniroute->gateway = gateway;
  75. /* Add to end of list if we have a gateway, otherwise
  76. * to start of list.
  77. */
  78. if ( gateway.s_addr != INADDR_NONE ) {
  79. list_add_tail ( &miniroute->list, &miniroutes );
  80. } else {
  81. list_add ( &miniroute->list, &miniroutes );
  82. }
  83. /* Record reference to net_device */
  84. miniroute->netdev_ref.forget = ipv4_forget_netdev;
  85. ref_add ( &miniroute->netdev_ref, &netdev->references );
  86. }
  87. return miniroute;
  88. }
  89. /**
  90. * Delete IPv4 minirouting table entry
  91. *
  92. * @v miniroute Routing table entry
  93. */
  94. static void del_ipv4_miniroute ( struct ipv4_miniroute *miniroute ) {
  95. DBG ( "IPv4 del %s", inet_ntoa ( miniroute->address ) );
  96. DBG ( "/%s ", inet_ntoa ( miniroute->netmask ) );
  97. if ( miniroute->gateway.s_addr != INADDR_NONE )
  98. DBG ( "gw %s ", inet_ntoa ( miniroute->gateway ) );
  99. DBG ( "via %s\n", miniroute->netdev->name );
  100. ref_del ( &miniroute->netdev_ref );
  101. list_del ( &miniroute->list );
  102. free ( miniroute );
  103. }
  104. /**
  105. * Forget reference to net_device
  106. *
  107. * @v ref Persistent reference
  108. */
  109. static void ipv4_forget_netdev ( struct reference *ref ) {
  110. struct ipv4_miniroute *miniroute
  111. = container_of ( ref, struct ipv4_miniroute, netdev_ref );
  112. del_ipv4_miniroute ( miniroute );
  113. }
  114. /**
  115. * Add IPv4 interface
  116. *
  117. * @v netdev Network device
  118. * @v address IPv4 address
  119. * @v netmask Subnet mask
  120. * @v gateway Gateway address (or @c INADDR_NONE for no gateway)
  121. * @ret rc Return status code
  122. *
  123. */
  124. int add_ipv4_address ( struct net_device *netdev, struct in_addr address,
  125. struct in_addr netmask, struct in_addr gateway ) {
  126. struct ipv4_miniroute *miniroute;
  127. /* Clear any existing address for this net device */
  128. del_ipv4_address ( netdev );
  129. /* Add new miniroute */
  130. miniroute = add_ipv4_miniroute ( netdev, address, netmask, gateway );
  131. if ( ! miniroute )
  132. return -ENOMEM;
  133. return 0;
  134. }
  135. /**
  136. * Remove IPv4 interface
  137. *
  138. * @v netdev Network device
  139. */
  140. void del_ipv4_address ( struct net_device *netdev ) {
  141. struct ipv4_miniroute *miniroute;
  142. list_for_each_entry ( miniroute, &miniroutes, list ) {
  143. if ( miniroute->netdev == netdev ) {
  144. del_ipv4_miniroute ( miniroute );
  145. break;
  146. }
  147. }
  148. }
  149. /**
  150. * Perform IPv4 routing
  151. *
  152. * @v dest Final destination address
  153. * @ret dest Next hop destination address
  154. * @ret miniroute Routing table entry to use, or NULL if no route
  155. */
  156. static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
  157. struct ipv4_miniroute *miniroute;
  158. int local;
  159. int has_gw;
  160. list_for_each_entry ( miniroute, &miniroutes, list ) {
  161. local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
  162. & miniroute->netmask.s_addr ) == 0 );
  163. has_gw = ( miniroute->gateway.s_addr != INADDR_NONE );
  164. if ( local || has_gw ) {
  165. if ( ! local )
  166. *dest = miniroute->gateway;
  167. return miniroute;
  168. }
  169. }
  170. return NULL;
  171. }
  172. /**
  173. * Fragment reassembly counter timeout
  174. *
  175. * @v timer Retry timer
  176. * @v over If asserted, the timer is greater than @c MAX_TIMEOUT
  177. */
  178. static void ipv4_frag_expired ( struct retry_timer *timer __unused,
  179. int over ) {
  180. if ( over ) {
  181. DBG ( "Fragment reassembly timeout" );
  182. /* Free the fragment buffer */
  183. }
  184. }
  185. /**
  186. * Free fragment buffer
  187. *
  188. * @v fragbug Fragment buffer
  189. */
  190. static void free_fragbuf ( struct frag_buffer *fragbuf ) {
  191. if ( fragbuf ) {
  192. free_dma ( fragbuf, sizeof ( *fragbuf ) );
  193. }
  194. }
  195. /**
  196. * Fragment reassembler
  197. *
  198. * @v pkb Packet buffer, fragment of the datagram
  199. * @ret frag_pkb Reassembled packet, or NULL
  200. */
  201. static struct pk_buff * ipv4_reassemble ( struct pk_buff * pkb ) {
  202. struct iphdr *iphdr = pkb->data;
  203. struct frag_buffer *fragbuf;
  204. /**
  205. * Check if the fragment belongs to any fragment series
  206. */
  207. list_for_each_entry ( fragbuf, &frag_buffers, list ) {
  208. if ( fragbuf->ident == iphdr->ident &&
  209. fragbuf->src.s_addr == iphdr->src.s_addr ) {
  210. /**
  211. * Check if the packet is the expected fragment
  212. *
  213. * The offset of the new packet must be equal to the
  214. * length of the data accumulated so far (the length of
  215. * the reassembled packet buffer
  216. */
  217. if ( pkb_len ( fragbuf->frag_pkb ) ==
  218. ( iphdr->frags & IP_MASK_OFFSET ) ) {
  219. /**
  220. * Append the contents of the fragment to the
  221. * reassembled packet buffer
  222. */
  223. pkb_pull ( pkb, sizeof ( *iphdr ) );
  224. memcpy ( pkb_put ( fragbuf->frag_pkb,
  225. pkb_len ( pkb ) ),
  226. pkb->data, pkb_len ( pkb ) );
  227. free_pkb ( pkb );
  228. /** Check if the fragment series is over */
  229. if ( !iphdr->frags & IP_MASK_MOREFRAGS ) {
  230. pkb = fragbuf->frag_pkb;
  231. free_fragbuf ( fragbuf );
  232. return pkb;
  233. }
  234. } else {
  235. /* Discard the fragment series */
  236. free_fragbuf ( fragbuf );
  237. free_pkb ( pkb );
  238. }
  239. return NULL;
  240. }
  241. }
  242. /** Check if the fragment is the first in the fragment series */
  243. if ( iphdr->frags & IP_MASK_MOREFRAGS &&
  244. ( ( iphdr->frags & IP_MASK_OFFSET ) == 0 ) ) {
  245. /** Create a new fragment buffer */
  246. fragbuf = ( struct frag_buffer* ) malloc ( sizeof( *fragbuf ) );
  247. fragbuf->ident = iphdr->ident;
  248. fragbuf->src = iphdr->src;
  249. /* Set up the reassembly packet buffer */
  250. fragbuf->frag_pkb = alloc_pkb ( IP_FRAG_PKB_SIZE );
  251. pkb_pull ( pkb, sizeof ( *iphdr ) );
  252. memcpy ( pkb_put ( fragbuf->frag_pkb, pkb_len ( pkb ) ),
  253. pkb->data, pkb_len ( pkb ) );
  254. free_pkb ( pkb );
  255. /* Set the reassembly timer */
  256. fragbuf->frag_timer.timeout = IP_FRAG_TIMEOUT;
  257. fragbuf->frag_timer.expired = ipv4_frag_expired;
  258. start_timer ( &fragbuf->frag_timer );
  259. /* Add the fragment buffer to the list of fragment buffers */
  260. list_add ( &fragbuf->list, &frag_buffers );
  261. }
  262. return NULL;
  263. }
  264. /**
  265. * Add IPv4 pseudo-header checksum to existing checksum
  266. *
  267. * @v pkb Packet buffer
  268. * @v csum Existing checksum
  269. * @ret csum Updated checksum
  270. */
  271. static uint16_t ipv4_pshdr_chksum ( struct pk_buff *pkb, uint16_t csum ) {
  272. struct ipv4_pseudo_header pshdr;
  273. struct iphdr *iphdr = pkb->data;
  274. size_t hdrlen = ( ( iphdr->verhdrlen & IP_MASK_HLEN ) * 4 );
  275. /* Build pseudo-header */
  276. pshdr.src = iphdr->src;
  277. pshdr.dest = iphdr->dest;
  278. pshdr.zero_padding = 0x00;
  279. pshdr.protocol = iphdr->protocol;
  280. pshdr.len = htons ( pkb_len ( pkb ) - hdrlen );
  281. /* Update the checksum value */
  282. return tcpip_continue_chksum ( csum, &pshdr, sizeof ( pshdr ) );
  283. }
  284. /**
  285. * Determine link-layer address
  286. *
  287. * @v dest IPv4 destination address
  288. * @v src IPv4 source address
  289. * @v netdev Network device
  290. * @v ll_dest Link-layer destination address buffer
  291. * @ret rc Return status code
  292. */
  293. static int ipv4_ll_addr ( struct in_addr dest, struct in_addr src,
  294. struct net_device *netdev, uint8_t *ll_dest ) {
  295. struct ll_protocol *ll_protocol = netdev->ll_protocol;
  296. uint8_t *dest_bytes = ( ( uint8_t * ) &dest );
  297. if ( dest.s_addr == INADDR_BROADCAST ) {
  298. /* Broadcast address */
  299. memcpy ( ll_dest, ll_protocol->ll_broadcast,
  300. ll_protocol->ll_addr_len );
  301. return 0;
  302. } else if ( IN_MULTICAST ( dest.s_addr ) ) {
  303. /* Special case: IPv4 multicast over Ethernet. This
  304. * code may need to be generalised once we find out
  305. * what happens for other link layers.
  306. */
  307. ll_dest[0] = 0x01;
  308. ll_dest[1] = 0x00;
  309. ll_dest[2] = 0x5e;
  310. ll_dest[3] = dest_bytes[1] & 0x7f;
  311. ll_dest[4] = dest_bytes[2];
  312. ll_dest[5] = dest_bytes[3];
  313. return 0;
  314. } else {
  315. /* Unicast address: resolve via ARP */
  316. return arp_resolve ( netdev, &ipv4_protocol, &dest,
  317. &src, ll_dest );
  318. }
  319. }
  320. /**
  321. * Transmit IP packet
  322. *
  323. * @v pkb Packet buffer
  324. * @v tcpip Transport-layer protocol
  325. * @v st_dest Destination network-layer address
  326. * @v netdev Network device (or NULL to route automatically)
  327. * @v trans_csum Transport-layer checksum to complete, or NULL
  328. * @ret rc Status
  329. *
  330. * This function expects a transport-layer segment and prepends the IP header
  331. */
  332. static int ipv4_tx ( struct pk_buff *pkb,
  333. struct tcpip_protocol *tcpip_protocol,
  334. struct sockaddr_tcpip *st_dest,
  335. struct net_device *netdev,
  336. uint16_t *trans_csum ) {
  337. struct iphdr *iphdr = pkb_push ( pkb, sizeof ( *iphdr ) );
  338. struct sockaddr_in *sin_dest = ( ( struct sockaddr_in * ) st_dest );
  339. struct ipv4_miniroute *miniroute;
  340. struct in_addr next_hop;
  341. uint8_t ll_dest[MAX_LL_ADDR_LEN];
  342. int rc;
  343. /* Fill up the IP header, except source address */
  344. memset ( iphdr, 0, sizeof ( *iphdr ) );
  345. iphdr->verhdrlen = ( IP_VER | ( sizeof ( *iphdr ) / 4 ) );
  346. iphdr->service = IP_TOS;
  347. iphdr->len = htons ( pkb_len ( pkb ) );
  348. iphdr->ident = htons ( ++next_ident );
  349. iphdr->ttl = IP_TTL;
  350. iphdr->protocol = tcpip_protocol->tcpip_proto;
  351. iphdr->dest = sin_dest->sin_addr;
  352. /* Use routing table to identify next hop and transmitting netdev */
  353. next_hop = iphdr->dest;
  354. if ( ( miniroute = ipv4_route ( &next_hop ) ) ) {
  355. iphdr->src = miniroute->address;
  356. netdev = miniroute->netdev;
  357. }
  358. if ( ! netdev ) {
  359. DBG ( "IPv4 has no route to %s\n", inet_ntoa ( iphdr->dest ) );
  360. rc = -EHOSTUNREACH;
  361. goto err;
  362. }
  363. /* Determine link-layer destination address */
  364. if ( ( rc = ipv4_ll_addr ( next_hop, iphdr->src, netdev,
  365. ll_dest ) ) != 0 ) {
  366. DBG ( "IPv4 has no link-layer address for %s\n",
  367. inet_ntoa ( iphdr->dest ) );
  368. goto err;
  369. }
  370. /* Fix up checksums */
  371. if ( trans_csum )
  372. *trans_csum = ipv4_pshdr_chksum ( pkb, *trans_csum );
  373. iphdr->chksum = tcpip_chksum ( iphdr, sizeof ( *iphdr ) );
  374. /* Print IP4 header for debugging */
  375. DBG ( "IPv4 TX %s->", inet_ntoa ( iphdr->src ) );
  376. DBG ( "%s len %d proto %d id %04x csum %04x\n",
  377. inet_ntoa ( iphdr->dest ), ntohs ( iphdr->len ), iphdr->protocol,
  378. ntohs ( iphdr->ident ), ntohs ( iphdr->chksum ) );
  379. /* Hand off to link layer */
  380. return net_tx ( pkb, netdev, &ipv4_protocol, ll_dest );
  381. err:
  382. free_pkb ( pkb );
  383. return rc;
  384. }
  385. /**
  386. * Process incoming packets
  387. *
  388. * @v pkb Packet buffer
  389. * @v netdev Network device
  390. * @v ll_source Link-layer destination source
  391. *
  392. * This function expects an IP4 network datagram. It processes the headers
  393. * and sends it to the transport layer.
  394. */
  395. static int ipv4_rx ( struct pk_buff *pkb, struct net_device *netdev __unused,
  396. const void *ll_source __unused ) {
  397. struct iphdr *iphdr = pkb->data;
  398. size_t hdrlen;
  399. size_t len;
  400. union {
  401. struct sockaddr_in sin;
  402. struct sockaddr_tcpip st;
  403. } src, dest;
  404. uint16_t csum;
  405. uint16_t pshdr_csum;
  406. /* Sanity check the IPv4 header */
  407. if ( pkb_len ( pkb ) < sizeof ( *iphdr ) ) {
  408. DBG ( "IPv4 packet too short at %d bytes (min %d bytes)\n",
  409. pkb_len ( pkb ), sizeof ( *iphdr ) );
  410. goto err;
  411. }
  412. if ( ( iphdr->verhdrlen & IP_MASK_VER ) != IP_VER ) {
  413. DBG ( "IPv4 version %#02x not supported\n", iphdr->verhdrlen );
  414. goto err;
  415. }
  416. hdrlen = ( ( iphdr->verhdrlen & IP_MASK_HLEN ) * 4 );
  417. if ( hdrlen < sizeof ( *iphdr ) ) {
  418. DBG ( "IPv4 header too short at %d bytes (min %d bytes)\n",
  419. hdrlen, sizeof ( *iphdr ) );
  420. goto err;
  421. }
  422. if ( hdrlen > pkb_len ( pkb ) ) {
  423. DBG ( "IPv4 header too long at %d bytes "
  424. "(packet is %d bytes)\n", hdrlen, pkb_len ( pkb ) );
  425. goto err;
  426. }
  427. if ( ( csum = tcpip_chksum ( iphdr, hdrlen ) ) != 0 ) {
  428. DBG ( "IPv4 checksum incorrect (is %04x including checksum "
  429. "field, should be 0000)\n", csum );
  430. goto err;
  431. }
  432. len = ntohs ( iphdr->len );
  433. if ( len < hdrlen ) {
  434. DBG ( "IPv4 length too short at %d bytes "
  435. "(header is %d bytes)\n", len, hdrlen );
  436. goto err;
  437. }
  438. if ( len > pkb_len ( pkb ) ) {
  439. DBG ( "IPv4 length too long at %d bytes "
  440. "(packet is %d bytes)\n", len, pkb_len ( pkb ) );
  441. goto err;
  442. }
  443. /* Print IPv4 header for debugging */
  444. DBG ( "IPv4 RX %s<-", inet_ntoa ( iphdr->dest ) );
  445. DBG ( "%s len %d proto %d id %04x csum %04x\n",
  446. inet_ntoa ( iphdr->src ), ntohs ( iphdr->len ), iphdr->protocol,
  447. ntohs ( iphdr->ident ), ntohs ( iphdr->chksum ) );
  448. /* Truncate packet to correct length, calculate pseudo-header
  449. * checksum and then strip off the IPv4 header.
  450. */
  451. pkb_unput ( pkb, ( pkb_len ( pkb ) - len ) );
  452. pshdr_csum = ipv4_pshdr_chksum ( pkb, TCPIP_EMPTY_CSUM );
  453. pkb_pull ( pkb, hdrlen );
  454. /* Fragment reassembly */
  455. if ( ( iphdr->frags & htons ( IP_MASK_MOREFRAGS ) ) ||
  456. ( ( iphdr->frags & htons ( IP_MASK_OFFSET ) ) != 0 ) ) {
  457. /* Pass the fragment to ipv4_reassemble() which either
  458. * returns a fully reassembled packet buffer or NULL.
  459. */
  460. pkb = ipv4_reassemble ( pkb );
  461. if ( ! pkb )
  462. return 0;
  463. }
  464. /* Construct socket addresses and hand off to transport layer */
  465. memset ( &src, 0, sizeof ( src ) );
  466. src.sin.sin_family = AF_INET;
  467. src.sin.sin_addr = iphdr->src;
  468. memset ( &dest, 0, sizeof ( dest ) );
  469. dest.sin.sin_family = AF_INET;
  470. dest.sin.sin_addr = iphdr->dest;
  471. return tcpip_rx ( pkb, iphdr->protocol, &src.st, &dest.st, pshdr_csum);
  472. err:
  473. free_pkb ( pkb );
  474. return -EINVAL;
  475. }
  476. /**
  477. * Check existence of IPv4 address for ARP
  478. *
  479. * @v netdev Network device
  480. * @v net_addr Network-layer address
  481. * @ret rc Return status code
  482. */
  483. static int ipv4_arp_check ( struct net_device *netdev, const void *net_addr ) {
  484. const struct in_addr *address = net_addr;
  485. struct ipv4_miniroute *miniroute;
  486. list_for_each_entry ( miniroute, &miniroutes, list ) {
  487. if ( ( miniroute->netdev == netdev ) &&
  488. ( miniroute->address.s_addr == address->s_addr ) ) {
  489. /* Found matching address */
  490. return 0;
  491. }
  492. }
  493. return -ENOENT;
  494. }
  495. /**
  496. * Convert IPv4 address to dotted-quad notation
  497. *
  498. * @v in IP address
  499. * @ret string IP address in dotted-quad notation
  500. */
  501. char * inet_ntoa ( struct in_addr in ) {
  502. static char buf[16]; /* "xxx.xxx.xxx.xxx" */
  503. uint8_t *bytes = ( uint8_t * ) &in;
  504. sprintf ( buf, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] );
  505. return buf;
  506. }
  507. /**
  508. * Transcribe IP address
  509. *
  510. * @v net_addr IP address
  511. * @ret string IP address in dotted-quad notation
  512. *
  513. */
  514. static const char * ipv4_ntoa ( const void *net_addr ) {
  515. return inet_ntoa ( * ( ( struct in_addr * ) net_addr ) );
  516. }
  517. /** IPv4 protocol */
  518. struct net_protocol ipv4_protocol __net_protocol = {
  519. .name = "IP",
  520. .net_proto = htons ( ETH_P_IP ),
  521. .net_addr_len = sizeof ( struct in_addr ),
  522. .rx = ipv4_rx,
  523. .ntoa = ipv4_ntoa,
  524. };
  525. /** IPv4 TCPIP net protocol */
  526. struct tcpip_net_protocol ipv4_tcpip_protocol __tcpip_net_protocol = {
  527. .name = "IPv4",
  528. .sa_family = AF_INET,
  529. .tx = ipv4_tx,
  530. };
  531. /** IPv4 ARP protocol */
  532. struct arp_net_protocol ipv4_arp_protocol __arp_net_protocol = {
  533. .net_protocol = &ipv4_protocol,
  534. .check = ipv4_arp_check,
  535. };