blob: 925d60ddc0020d5cb7748b53ae9e630763014020 [file] [log] [blame]
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00001/*
2 * ll_types.c
3 *
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.
8 *
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
10 */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000011#include <stdio.h>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000012#include <arpa/inet.h>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000013
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000014#include <linux/if_arp.h>
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000015
16char * ll_type_n2a(int type, char *buf, int len)
17{
18#define __PF(f,n) { ARPHRD_##f, #n },
19static struct {
20 int type;
21 char *name;
22} arphrd_names[] = {
23{ 0, "generic" },
24__PF(ETHER,ether)
25__PF(EETHER,eether)
26__PF(AX25,ax25)
27__PF(PRONET,pronet)
28__PF(CHAOS,chaos)
29#ifdef ARPHRD_IEEE802_TR
30__PF(IEEE802,ieee802)
31#else
32__PF(IEEE802,tr)
33#endif
34__PF(ARCNET,arcnet)
35__PF(APPLETLK,atalk)
36__PF(DLCI,dlci)
37__PF(ATM,atm)
38__PF(METRICOM,metricom)
39#ifdef ARPHRD_IEEE1394
40__PF(IEEE1394,ieee1394)
41#endif
42
43__PF(SLIP,slip)
44__PF(CSLIP,cslip)
45__PF(SLIP6,slip6)
46__PF(CSLIP6,cslip6)
47__PF(RSRVD,rsrvd)
48__PF(ADAPT,adapt)
49__PF(ROSE,rose)
50__PF(X25,x25)
51__PF(HWX25,hwx25)
52__PF(PPP,ppp)
53__PF(HDLC,hdlc)
54__PF(LAPB,lapb)
55__PF(DDCMP,ddcmp)
56__PF(RAWHDLC,rawhdlc)
57
58__PF(TUNNEL,ipip)
59__PF(TUNNEL6,tunnel6)
60__PF(FRAD,frad)
61__PF(SKIP,skip)
62__PF(LOOPBACK,loopback)
63__PF(LOCALTLK,ltalk)
64__PF(FDDI,fddi)
65__PF(BIF,bif)
66__PF(SIT,sit)
67__PF(IPDDP,ip/ddp)
68__PF(IPGRE,gre)
69__PF(PIMREG,pimreg)
70__PF(HIPPI,hippi)
71__PF(ASH,ash)
72__PF(ECONET,econet)
73__PF(IRDA,irda)
74__PF(FCPP,fcpp)
75__PF(FCAL,fcal)
76__PF(FCPL,fcpl)
77__PF(FCFABRIC,fcfb0)
78__PF(FCFABRIC+1,fcfb1)
79__PF(FCFABRIC+2,fcfb2)
80__PF(FCFABRIC+3,fcfb3)
81__PF(FCFABRIC+4,fcfb4)
82__PF(FCFABRIC+5,fcfb5)
83__PF(FCFABRIC+6,fcfb6)
84__PF(FCFABRIC+7,fcfb7)
85__PF(FCFABRIC+8,fcfb8)
86__PF(FCFABRIC+9,fcfb9)
87__PF(FCFABRIC+10,fcfb10)
88__PF(FCFABRIC+11,fcfb11)
89__PF(FCFABRIC+12,fcfb12)
90#ifdef ARPHRD_IEEE802_TR
91__PF(IEEE802_TR,tr)
92#endif
93#ifdef ARPHRD_IEEE80211
94__PF(IEEE80211,ieee802.11)
95#endif
96#ifdef ARPHRD_VOID
97__PF(VOID,void)
98#endif
99};
100#undef __PF
101
102 int i;
103 for (i=0; i<sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) {
104 if (arphrd_names[i].type == type)
105 return arphrd_names[i].name;
106 }
107 snprintf(buf, len, "[%d]", type);
108 return buf;
109}