]>
git.proxmox.com Git - mirror_iproute2.git/blob - lib/ll_proto.c
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
16 #include <sys/ioctl.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
22 #include <linux/netdevice.h>
23 #include <linux/if_arp.h>
24 #include <linux/sockios.h>
30 #define __PF(f,n) { ETH_P_##f, #n },
43 __PF(IEEEPUPAT
,ieeepupat
)
57 __PF(PPP_DISC
,ppp_disc
)
69 __PF(LOCALTALK
,localtalk
)
72 __PF(TR_802_2
,tr_802_2
)
89 const char * ll_proto_n2a(unsigned short id
, char *buf
, int len
)
95 for (i
=0; i
<sizeof(llproto_names
)/sizeof(llproto_names
[0]); i
++) {
96 if (llproto_names
[i
].id
== id
)
97 return llproto_names
[i
].name
;
99 snprintf(buf
, len
, "[%d]", id
);
103 int ll_proto_a2n(unsigned short *id
, const char *buf
)
106 for (i
=0; i
< sizeof(llproto_names
)/sizeof(llproto_names
[0]); i
++) {
107 if (strcasecmp(llproto_names
[i
].name
, buf
) == 0) {
108 *id
= htons(llproto_names
[i
].id
);
112 if (get_be16(id
, buf
, 0))