This source file includes following definitions.
- arp_check_expire
- arp_release_entry
- arp_send
- arp_expire_request
- arp_send_q
- arp_destroy
- arp_rcv
- arp_find
- arp_get_info
- arp_lookup
- arp_req_set
- arp_req_get
- arp_ioctl
- arp_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include <linux/types.h>
32 #include <linux/string.h>
33 #include <linux/kernel.h>
34 #include <linux/sched.h>
35 #include <linux/config.h>
36 #include <linux/socket.h>
37 #include <linux/sockios.h>
38 #include <linux/errno.h>
39 #include <linux/if_arp.h>
40 #include <linux/in.h>
41 #include <asm/system.h>
42 #include <asm/segment.h>
43 #include <stdarg.h>
44 #include <linux/inet.h>
45 #include <linux/netdevice.h>
46 #include <linux/etherdevice.h>
47 #include "ip.h"
48 #include "route.h"
49 #include "protocol.h"
50 #include "tcp.h"
51 #include <linux/skbuff.h>
52 #include "sock.h"
53 #include "arp.h"
54 #ifdef CONFIG_AX25
55 #include "ax25.h"
56 #endif
57
58
59
60
61
62
63
64
65 struct arp_table
66 {
67 struct arp_table *next;
68 unsigned long last_used;
69 unsigned int flags;
70 unsigned long ip;
71 unsigned char ha[MAX_ADDR_LEN];
72 unsigned char hlen;
73 unsigned short htype;
74 struct device *dev;
75
76
77
78
79
80 struct timer_list timer;
81 int retries;
82 struct sk_buff_head skb;
83 };
84
85
86
87
88
89 struct arphdr
90 {
91 unsigned short ar_hrd;
92 unsigned short ar_pro;
93 unsigned char ar_hln;
94 unsigned char ar_pln;
95 unsigned short ar_op;
96
97 #if 0
98
99
100
101 unsigned char ar_sha[ETH_ALEN];
102 unsigned char ar_sip[4];
103 unsigned char ar_tha[ETH_ALEN];
104 unsigned char ar_tip[4];
105 #endif
106
107 };
108
109
110
111
112
113
114
115
116
117
118 #define ARP_RES_TIME (250*(HZ/10))
119
120
121
122
123
124
125 #define ARP_MAX_TRIES 3
126
127
128
129
130
131 #define ARP_TIMEOUT (600*HZ)
132
133
134
135
136
137
138
139 #define ARP_CHECK_INTERVAL (60 * HZ)
140
141
142 static void arp_check_expire (unsigned long);
143
144
145 static struct timer_list arp_timer =
146 { NULL, NULL, ARP_CHECK_INTERVAL, 0L, &arp_check_expire };
147
148
149
150
151
152
153
154 #define ARP_TABLE_SIZE 16
155
156 struct arp_table *arp_tables[ARP_TABLE_SIZE] =
157 {
158 NULL,
159 };
160
161
162
163
164
165 #define HASH(paddr) (htonl(paddr) & (ARP_TABLE_SIZE - 1))
166
167
168
169
170
171
172 static int proxies = 0;
173
174
175
176
177
178
179
180
181
182
183 static void arp_check_expire(unsigned long dummy)
184 {
185 int i;
186 unsigned long now = jiffies;
187 unsigned long flags;
188 save_flags(flags);
189 cli();
190
191 for (i = 0; i < ARP_TABLE_SIZE; i++)
192 {
193 struct arp_table *entry;
194 struct arp_table **pentry = &arp_tables[i];
195
196 while ((entry = *pentry) != NULL)
197 {
198 if ((now - entry->last_used) > ARP_TIMEOUT
199 && !(entry->flags & ATF_PERM))
200 {
201 *pentry = entry->next;
202 if (entry->flags & ATF_PUBL)
203 proxies--;
204 del_timer(&entry->timer);
205 kfree_s(entry, sizeof(struct arp_table));
206 }
207 else
208 pentry = &entry->next;
209 }
210 }
211 restore_flags(flags);
212
213
214
215
216
217 del_timer(&arp_timer);
218 arp_timer.expires = ARP_CHECK_INTERVAL;
219 add_timer(&arp_timer);
220 }
221
222
223
224
225
226
227 static void arp_release_entry(struct arp_table *entry)
228 {
229 struct sk_buff *skb;
230
231 if (entry->flags & ATF_PUBL)
232 proxies--;
233
234 while ((skb = skb_dequeue(&entry->skb)) != NULL)
235 {
236 if (skb->free)
237 kfree_skb(skb, FREE_WRITE);
238 }
239 del_timer(&entry->timer);
240 kfree_s(entry, sizeof(struct arp_table));
241 return;
242 }
243
244
245
246
247
248
249
250 void arp_send(int type, int ptype, unsigned long dest_ip,
251 struct device *dev, unsigned long src_ip,
252 unsigned char *dest_hw, unsigned char *src_hw)
253 {
254 struct sk_buff *skb;
255 struct arphdr *arp;
256 unsigned char *arp_ptr;
257
258
259
260
261
262 if(dev->flags&IFF_NOARP)
263 return;
264
265
266
267
268
269 skb = alloc_skb(sizeof(struct arphdr)+ 2*(dev->addr_len+4)
270 + dev->hard_header_len, GFP_ATOMIC);
271 if (skb == NULL)
272 {
273 printk("ARP: no memory to send an arp packet\n");
274 return;
275 }
276 skb->len = sizeof(struct arphdr) + dev->hard_header_len + 2*(dev->addr_len+4);
277 skb->arp = 1;
278 skb->dev = dev;
279 skb->free = 1;
280
281
282
283
284
285 dev->hard_header(skb->data,dev,ptype,dest_hw?dest_hw:dev->broadcast,src_hw?src_hw:NULL,skb->len,skb);
286
287
288 arp = (struct arphdr *) (skb->data + dev->hard_header_len);
289 arp->ar_hrd = htons(dev->type);
290 #ifdef CONFIG_AX25
291 arp->ar_pro = (dev->type != ARPHRD_AX25)? htons(ETH_P_IP) : htons(AX25_P_IP);
292 #else
293 arp->ar_pro = htons(ETH_P_IP);
294 #endif
295 arp->ar_hln = dev->addr_len;
296 arp->ar_pln = 4;
297 arp->ar_op = htons(type);
298
299 arp_ptr=(unsigned char *)(arp+1);
300
301 memcpy(arp_ptr, src_hw, dev->addr_len);
302 arp_ptr+=dev->addr_len;
303 memcpy(arp_ptr, &src_ip,4);
304 arp_ptr+=4;
305 if (dest_hw != NULL)
306 memcpy(arp_ptr, dest_hw, dev->addr_len);
307 else
308 memset(arp_ptr, 0, dev->addr_len);
309 arp_ptr+=dev->addr_len;
310 memcpy(arp_ptr, &dest_ip, 4);
311
312 dev_queue_xmit(skb, dev, 0);
313 }
314
315
316
317
318
319
320
321 static void arp_expire_request (unsigned long arg)
322 {
323 struct arp_table *entry = (struct arp_table *) arg;
324 struct arp_table **pentry;
325 unsigned long hash;
326 unsigned long flags;
327
328 save_flags(flags);
329 cli();
330
331
332
333
334
335
336
337 if (entry->flags & ATF_COM)
338 {
339 restore_flags(flags);
340 return;
341 }
342
343 if (--entry->retries > 0)
344 {
345 unsigned long ip = entry->ip;
346 struct device *dev = entry->dev;
347
348
349 del_timer(&entry->timer);
350 entry->timer.expires = ARP_RES_TIME;
351 add_timer(&entry->timer);
352 restore_flags(flags);
353 arp_send(ARPOP_REQUEST, ETH_P_ARP, ip, dev, dev->pa_addr,
354 NULL, dev->dev_addr);
355 return;
356 }
357
358
359
360
361
362
363
364
365 hash = HASH(entry->ip);
366 pentry = &arp_tables[hash];
367 while (*pentry != NULL)
368 {
369 if (*pentry == entry)
370 {
371 *pentry = entry->next;
372 del_timer(&entry->timer);
373 restore_flags(flags);
374 arp_release_entry(entry);
375 return;
376 }
377 pentry = &(*pentry)->next;
378 }
379 restore_flags(flags);
380 printk("Possible ARP queue corruption.\n");
381
382
383
384 }
385
386
387
388
389
390
391 static void arp_send_q(struct arp_table *entry, unsigned char *hw_dest)
392 {
393 struct sk_buff *skb;
394
395
396
397
398
399
400 if(!(entry->flags&ATF_COM))
401 {
402 printk("arp_send_q: incomplete entry for %s\n",
403 in_ntoa(entry->ip));
404 return;
405 }
406
407 while((skb = skb_dequeue(&entry->skb)) != NULL)
408 {
409 IS_SKB(skb);
410 if(!skb->dev->rebuild_header(skb->data,skb->dev,skb->raddr,skb))
411 {
412 skb->arp = 1;
413 if(skb->sk==NULL)
414 dev_queue_xmit(skb, skb->dev, 0);
415 else
416 dev_queue_xmit(skb,skb->dev,skb->sk->priority);
417 }
418 else
419 {
420
421
422 printk("arp_send_q: The impossible occurred. Please notify Alan.\n");
423 printk("arp_send_q: active entity %s\n",in_ntoa(entry->ip));
424 printk("arp_send_q: failed to find %s\n",in_ntoa(skb->raddr));
425 }
426 }
427 }
428
429
430
431
432
433
434 void arp_destroy(unsigned long ip_addr, int force)
435 {
436 struct arp_table *entry;
437 struct arp_table **pentry;
438 unsigned long hash = HASH(ip_addr);
439
440 cli();
441 pentry = &arp_tables[hash];
442 while ((entry = *pentry) != NULL)
443 {
444 if (entry->ip == ip_addr)
445 {
446 if ((entry->flags & ATF_PERM) && !force)
447 return;
448 *pentry = entry->next;
449 del_timer(&entry->timer);
450 sti();
451 arp_release_entry(entry);
452 return;
453 }
454 pentry = &entry->next;
455 }
456 sti();
457 }
458
459
460
461
462
463
464
465
466 int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
467 {
468
469
470
471
472 struct arphdr *arp = (struct arphdr *)skb->h.raw;
473 unsigned char *arp_ptr= (unsigned char *)(arp+1);
474 struct arp_table *entry;
475 struct arp_table *proxy_entry;
476 int addr_hint,hlen,htype;
477 unsigned long hash,dest_hash;
478 unsigned char ha[MAX_ADDR_LEN];
479 long sip,tip;
480 unsigned char *sha,*tha;
481
482
483
484
485
486
487
488
489 if (arp->ar_hln != dev->addr_len ||
490 dev->type != ntohs(arp->ar_hrd) ||
491 dev->flags & IFF_NOARP ||
492 arp->ar_pln != 4)
493 {
494 kfree_skb(skb, FREE_READ);
495 return 0;
496 }
497
498
499
500
501
502
503
504 switch(dev->type)
505 {
506 #ifdef CONFIG_AX25
507 case ARPHRD_AX25:
508 if(arp->ar_pro != htons(AX25_P_IP))
509 {
510 kfree_skb(skb, FREE_READ);
511 return 0;
512 }
513 break;
514 #endif
515 case ARPHRD_ETHER:
516 if(arp->ar_pro != htons(ETH_P_IP))
517 {
518 kfree_skb(skb, FREE_READ);
519 return 0;
520 }
521 break;
522
523 default:
524 printk("ARP: dev->type mangled!\n");
525 kfree_skb(skb, FREE_READ);
526 return 0;
527 }
528
529
530
531
532
533 hlen = dev->addr_len;
534 htype = dev->type;
535
536 sha=arp_ptr;
537 arp_ptr+=hlen;
538 memcpy(&sip,arp_ptr,4);
539 arp_ptr+=4;
540 tha=arp_ptr;
541 arp_ptr+=hlen;
542 memcpy(&tip,arp_ptr,4);
543
544
545
546
547 if(tip == INADDR_LOOPBACK)
548 {
549 kfree_skb(skb, FREE_READ);
550 return 0;
551 }
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570 addr_hint = ip_chk_addr(tip);
571
572 if(arp->ar_op == htons(ARPOP_REPLY))
573 {
574 if(addr_hint!=IS_MYADDR)
575 {
576
577
578
579 kfree_skb(skb, FREE_READ);
580 return 0;
581 }
582
583
584
585 }
586 else
587 {
588
589
590
591 if(addr_hint != IS_MYADDR)
592 {
593
594
595
596
597
598 if (proxies == 0)
599 {
600 kfree_skb(skb, FREE_READ);
601 return 0;
602 }
603
604 dest_hash = HASH(tip);
605 cli();
606 for(proxy_entry=arp_tables[dest_hash];
607 proxy_entry;
608 proxy_entry = proxy_entry->next)
609 {
610 if(proxy_entry->ip == tip && proxy_entry->htype==htype)
611 break;
612 }
613 if (proxy_entry && (proxy_entry->flags & ATF_PUBL))
614 {
615 memcpy(ha, proxy_entry->ha, hlen);
616 sti();
617 arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,ha);
618 kfree_skb(skb, FREE_READ);
619 return 0;
620 }
621 else
622 {
623 sti();
624 kfree_skb(skb, FREE_READ);
625 return 0;
626 }
627 }
628 else
629 {
630
631
632
633 arp_send(ARPOP_REPLY,ETH_P_ARP,sip,dev,tip,sha,dev->dev_addr);
634 }
635 }
636
637
638
639
640
641
642
643
644 hash = HASH(sip);
645 cli();
646 for(entry=arp_tables[hash];entry;entry=entry->next)
647 if(entry->ip==sip && entry->htype==htype)
648 break;
649
650 if(entry)
651 {
652
653
654
655 memcpy(entry->ha, sha, hlen);
656 entry->hlen = hlen;
657 entry->last_used = jiffies;
658 if (!(entry->flags & ATF_COM))
659 {
660
661
662
663
664 del_timer(&entry->timer);
665 entry->flags |= ATF_COM;
666 sti();
667
668
669
670
671
672 arp_send_q(entry, sha);
673 }
674 else
675 {
676 sti();
677 }
678 }
679 else
680 {
681
682
683
684 entry = (struct arp_table *)kmalloc(sizeof(struct arp_table),GFP_ATOMIC);
685 if(entry == NULL)
686 {
687 sti();
688 printk("ARP: no memory for new arp entry\n");
689
690 kfree_skb(skb, FREE_READ);
691 return 0;
692 }
693
694 entry->ip = sip;
695 entry->hlen = hlen;
696 entry->htype = htype;
697 entry->flags = ATF_COM;
698 memcpy(entry->ha, sha, hlen);
699 entry->last_used = jiffies;
700 entry->dev = skb->dev;
701 skb_queue_head_init(&entry->skb);
702 entry->next = arp_tables[hash];
703 arp_tables[hash] = entry;
704
705 sti();
706 }
707
708
709
710
711 kfree_skb(skb, FREE_READ);
712 return 0;
713 }
714
715
716
717
718
719
720 int arp_find(unsigned char *haddr, unsigned long paddr, struct device *dev,
721 unsigned long saddr, struct sk_buff *skb)
722 {
723 struct arp_table *entry;
724 unsigned long hash;
725
726 switch (ip_chk_addr(paddr))
727 {
728 case IS_MYADDR:
729 printk("ARP: arp called for own IP address\n");
730 memcpy(haddr, dev->dev_addr, dev->addr_len);
731 skb->arp = 1;
732 return 0;
733 case IS_BROADCAST:
734 memcpy(haddr, dev->broadcast, dev->addr_len);
735 skb->arp = 1;
736 return 0;
737 }
738
739 hash = HASH(paddr);
740 cli();
741
742
743
744
745 for (entry = arp_tables[hash]; entry != NULL; entry = entry->next)
746 if (entry->ip == paddr)
747 break;
748
749
750 if (entry != NULL)
751 {
752 if (!(entry->flags & ATF_COM))
753 {
754
755
756
757
758
759 if (skb != NULL)
760 skb_queue_tail(&entry->skb, skb);
761 sti();
762 return 1;
763 }
764
765
766
767
768
769 entry->last_used = jiffies;
770 memcpy(haddr, entry->ha, dev->addr_len);
771 if (skb)
772 skb->arp = 1;
773 sti();
774 return 0;
775 }
776
777
778
779
780
781 entry = (struct arp_table *) kmalloc(sizeof(struct arp_table),
782 GFP_ATOMIC);
783 if (entry != NULL)
784 {
785 entry->ip = paddr;
786 entry->hlen = dev->addr_len;
787 entry->htype = dev->type;
788 entry->flags = 0;
789 memset(entry->ha, 0, dev->addr_len);
790 entry->last_used = jiffies;
791 entry->next = arp_tables[hash];
792 entry->dev = dev;
793 arp_tables[hash] = entry;
794 entry->timer.function = arp_expire_request;
795 entry->timer.data = (unsigned long)entry;
796 entry->timer.expires = ARP_RES_TIME;
797 add_timer(&entry->timer);
798 entry->retries = ARP_MAX_TRIES;
799 skb_queue_head_init(&entry->skb);
800 if (skb != NULL)
801 skb_queue_tail(&entry->skb, skb);
802 }
803 else
804 {
805 if (skb != NULL && skb->free)
806 kfree_skb(skb, FREE_WRITE);
807 }
808 sti();
809
810
811
812
813
814 arp_send(ARPOP_REQUEST, ETH_P_ARP, paddr, dev, saddr, NULL,
815 dev->dev_addr);
816
817 return 1;
818 }
819
820
821
822
823
824
825 #define HBUFFERLEN 30
826
827 int arp_get_info(char *buffer, char **start, off_t offset, int length)
828 {
829 int len=0;
830 off_t begin=0;
831 off_t pos=0;
832 int size;
833 struct arp_table *entry;
834 char hbuffer[HBUFFERLEN];
835 int i,j,k;
836 const char hexbuf[] = "0123456789ABCDEF";
837
838 size = sprintf(buffer,"IP address HW type Flags HW address\n");
839 pos+=size;
840 len+=size;
841
842 cli();
843 for(i=0; i<ARP_TABLE_SIZE; i++)
844 {
845 for(entry=arp_tables[i]; entry!=NULL; entry=entry->next)
846 {
847
848
849
850 for(k=0,j=0;k<HBUFFERLEN-3 && j<entry->hlen;j++)
851 {
852 hbuffer[k++]=hexbuf[ (entry->ha[j]>>4)&15 ];
853 hbuffer[k++]=hexbuf[ entry->ha[j]&15 ];
854 hbuffer[k++]=':';
855 }
856 hbuffer[--k]=0;
857
858 size = sprintf(buffer+len,
859 "%-17s0x%-10x0x%-10x%s\n",
860 in_ntoa(entry->ip),
861 (unsigned int)entry->htype,
862 entry->flags,
863 hbuffer);
864
865 len+=size;
866 pos=begin+len;
867
868 if(pos<offset)
869 {
870 len=0;
871 begin=pos;
872 }
873 if(pos>offset+length)
874 break;
875 }
876 }
877 sti();
878
879 *start=buffer+(offset-begin);
880 len-=(offset-begin);
881 if(len>length)
882 len=length;
883 return len;
884 }
885
886
887
888
889
890
891
892 static struct arp_table *arp_lookup(unsigned long paddr)
893 {
894 struct arp_table *entry;
895 unsigned long hash = HASH(paddr);
896
897 cli();
898 for (entry = arp_tables[hash]; entry != NULL; entry = entry->next)
899 if (entry->ip == paddr) break;
900 return entry;
901 }
902
903
904
905
906
907
908 static int arp_req_set(struct arpreq *req)
909 {
910 struct arpreq r;
911 struct arp_table *entry;
912 struct sockaddr_in *si;
913 int htype, hlen;
914 unsigned long ip, hash;
915 struct rtable *rt;
916
917 memcpy_fromfs(&r, req, sizeof(r));
918
919
920 if (r.arp_pa.sa_family != AF_INET)
921 return -EPFNOSUPPORT;
922
923
924
925
926
927
928
929 switch (r.arp_ha.sa_family) {
930 case 0:
931
932 printk("Application using old BSD convention for arp set. Please recompile it.\n");
933 case ARPHRD_ETHER:
934 htype = ARPHRD_ETHER;
935 hlen = ETH_ALEN;
936 break;
937 #ifdef CONFIG_AX25
938 case ARPHRD_AX25:
939 htype = ARPHRD_AX25;
940 hlen = 7;
941 break;
942 #endif
943 default:
944 return -EPFNOSUPPORT;
945 }
946
947 si = (struct sockaddr_in *) &r.arp_pa;
948 ip = si->sin_addr.s_addr;
949 if (ip == 0)
950 {
951 printk("ARP: SETARP: requested PA is 0.0.0.0 !\n");
952 return -EINVAL;
953 }
954
955
956
957
958
959 rt = ip_rt_route(ip, NULL, NULL);
960 if (rt == NULL)
961 return -ENETUNREACH;
962
963
964
965
966
967 hash = HASH(ip);
968 cli();
969
970
971
972
973 for (entry = arp_tables[hash]; entry != NULL; entry = entry->next)
974 if (entry->ip == ip)
975 break;
976
977
978
979
980
981 if (entry == NULL)
982 {
983 entry = (struct arp_table *) kmalloc(sizeof(struct arp_table),
984 GFP_ATOMIC);
985 if (entry == NULL)
986 {
987 sti();
988 return -ENOMEM;
989 }
990 entry->ip = ip;
991 entry->hlen = hlen;
992 entry->htype = htype;
993 entry->next = arp_tables[hash];
994 arp_tables[hash] = entry;
995 skb_queue_head_init(&entry->skb);
996 }
997 else
998 if (entry->flags & ATF_PUBL)
999 proxies--;
1000
1001
1002
1003
1004 memcpy(&entry->ha, &r.arp_ha.sa_data, hlen);
1005 entry->last_used = jiffies;
1006 entry->flags = r.arp_flags | ATF_COM;
1007 if (entry->flags & ATF_PUBL)
1008 proxies++;
1009 entry->dev = rt->rt_dev;
1010 sti();
1011
1012 return 0;
1013 }
1014
1015
1016
1017
1018
1019
1020 static int arp_req_get(struct arpreq *req)
1021 {
1022 struct arpreq r;
1023 struct arp_table *entry;
1024 struct sockaddr_in *si;
1025
1026
1027
1028
1029
1030 memcpy_fromfs(&r, req, sizeof(r));
1031
1032 if (r.arp_pa.sa_family != AF_INET)
1033 return -EPFNOSUPPORT;
1034
1035
1036
1037
1038
1039 si = (struct sockaddr_in *) &r.arp_pa;
1040 entry = arp_lookup(si->sin_addr.s_addr);
1041
1042 if (entry == NULL)
1043 {
1044 sti();
1045 return -ENXIO;
1046 }
1047
1048
1049
1050
1051
1052 memcpy(r.arp_ha.sa_data, &entry->ha, entry->hlen);
1053 r.arp_ha.sa_family = entry->htype;
1054 r.arp_flags = entry->flags;
1055 sti();
1056
1057
1058
1059
1060
1061 memcpy_tofs(req, &r, sizeof(r));
1062 return 0;
1063 }
1064
1065
1066
1067
1068
1069
1070 int arp_ioctl(unsigned int cmd, void *arg)
1071 {
1072 struct arpreq r;
1073 struct sockaddr_in *si;
1074 int err;
1075
1076 switch(cmd)
1077 {
1078 case DDIOCSDBG:
1079 return dbg_ioctl(arg, DBG_ARP);
1080 case SIOCDARP:
1081 if (!suser())
1082 return -EPERM;
1083 err = verify_area(VERIFY_READ, arg, sizeof(struct arpreq));
1084 if(err)
1085 return err;
1086 memcpy_fromfs(&r, arg, sizeof(r));
1087 if (r.arp_pa.sa_family != AF_INET)
1088 return -EPFNOSUPPORT;
1089 si = (struct sockaddr_in *) &r.arp_pa;
1090 arp_destroy(si->sin_addr.s_addr, 1);
1091 return 0;
1092 case SIOCGARP:
1093 err = verify_area(VERIFY_WRITE, arg, sizeof(struct arpreq));
1094 if(err)
1095 return err;
1096 return arp_req_get((struct arpreq *)arg);
1097 case SIOCSARP:
1098 if (!suser())
1099 return -EPERM;
1100 err = verify_area(VERIFY_READ, arg, sizeof(struct arpreq));
1101 if(err)
1102 return err;
1103 return arp_req_set((struct arpreq *)arg);
1104 default:
1105 return -EINVAL;
1106 }
1107
1108 return 0;
1109 }
1110
1111
1112
1113
1114
1115
1116 static struct packet_type arp_packet_type =
1117 {
1118 0,
1119 0,
1120 arp_rcv,
1121 NULL,
1122 NULL
1123 };
1124
1125 void arp_init (void)
1126 {
1127
1128 arp_packet_type.type=htons(ETH_P_ARP);
1129 dev_add_pack(&arp_packet_type);
1130
1131 add_timer(&arp_timer);
1132 }
1133