1 /* 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 (at) ms2.inr.ac.ru> 10 */ 11 12 #include <stdio.h> 13 #include <stdlib.h> 14 #include <unistd.h> 15 #include <syslog.h> 16 #include <fcntl.h> 17 #include <sys/ioctl.h> 18 #include <sys/socket.h> 19 #include <sys/ioctl.h> 20 #include <netinet/in.h> 21 #include <arpa/inet.h> 22 #include <string.h> 23 24 #include <linux/netdevice.h> 25 #include <linux/if_arp.h> 26 #include <linux/sockios.h> 27 28 #include "rt_names.h" 29 30 const char * ll_type_n2a(int type, char *buf, int len) 31 { 32 #define __PF(f,n) { ARPHRD_##f, #n }, 33 static struct { 34 int type; 35 const char *name; 36 } arphrd_names[] = { 37 { 0, "generic" }, 38 __PF(ETHER,ether) 39 __PF(EETHER,eether) 40 __PF(AX25,ax25) 41 __PF(PRONET,pronet) 42 __PF(CHAOS,chaos) 43 #ifdef ARPHRD_IEEE802_TR 44 __PF(IEEE802,ieee802) 45 #else 46 __PF(IEEE802,tr) 47 #endif 48 __PF(ARCNET,arcnet) 49 __PF(APPLETLK,atalk) 50 __PF(DLCI,dlci) 51 #ifdef ARPHRD_ATM 52 __PF(ATM,atm) 53 #endif 54 __PF(METRICOM,metricom) 55 #ifdef ARPHRD_IEEE1394 56 __PF(IEEE1394,ieee1394) 57 #endif 58 #ifdef ARPHRD_INFINIBAND 59 __PF(INFINIBAND,infiniband) 60 #endif 61 62 __PF(SLIP,slip) 63 __PF(CSLIP,cslip) 64 __PF(SLIP6,slip6) 65 __PF(CSLIP6,cslip6) 66 __PF(RSRVD,rsrvd) 67 __PF(ADAPT,adapt) 68 __PF(ROSE,rose) 69 __PF(X25,x25) 70 #ifdef ARPHRD_HWX25 71 __PF(HWX25,hwx25) 72 #endif 73 __PF(CAN,can) 74 __PF(PPP,ppp) 75 __PF(HDLC,hdlc) 76 __PF(LAPB,lapb) 77 #ifdef ARPHRD_DDCMP 78 __PF(DDCMP,ddcmp) 79 #endif 80 #ifdef ARPHRD_RAWHDLC 81 __PF(RAWHDLC,rawhdlc) 82 #endif 83 84 __PF(TUNNEL,ipip) 85 __PF(TUNNEL6,tunnel6) 86 __PF(FRAD,frad) 87 __PF(SKIP,skip) 88 __PF(LOOPBACK,loopback) 89 __PF(LOCALTLK,ltalk) 90 __PF(FDDI,fddi) 91 __PF(BIF,bif) 92 __PF(SIT,sit) 93 __PF(IPDDP,ip/ddp) 94 __PF(IPGRE,gre) 95 __PF(PIMREG,pimreg) 96 __PF(HIPPI,hippi) 97 __PF(ASH,ash) 98 __PF(ECONET,econet) 99 __PF(IRDA,irda) 100 __PF(FCPP,fcpp) 101 __PF(FCAL,fcal) 102 __PF(FCPL,fcpl) 103 __PF(FCFABRIC,fcfb0) 104 __PF(FCFABRIC+1,fcfb1) 105 __PF(FCFABRIC+2,fcfb2) 106 __PF(FCFABRIC+3,fcfb3) 107 __PF(FCFABRIC+4,fcfb4) 108 __PF(FCFABRIC+5,fcfb5) 109 __PF(FCFABRIC+6,fcfb6) 110 __PF(FCFABRIC+7,fcfb7) 111 __PF(FCFABRIC+8,fcfb8) 112 __PF(FCFABRIC+9,fcfb9) 113 __PF(FCFABRIC+10,fcfb10) 114 __PF(FCFABRIC+11,fcfb11) 115 __PF(FCFABRIC+12,fcfb12) 116 #ifdef ARPHRD_IEEE802_TR 117 __PF(IEEE802_TR,tr) 118 #endif 119 #ifdef ARPHRD_IEEE80211 120 __PF(IEEE80211,ieee802.11) 121 #endif 122 #ifdef ARPHRD_IEEE80211_PRISM 123 __PF(IEEE80211_PRISM,ieee802.11/prism) 124 #endif 125 #ifdef ARPHRD_IEEE80211_RADIOTAP 126 __PF(IEEE80211_RADIOTAP,ieee802.11/radiotap) 127 #endif 128 #ifdef ARPHRD_VOID 129 __PF(VOID,void) 130 #endif 131 }; 132 #undef __PF 133 134 int i; 135 for (i=0; i<sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) { 136 if (arphrd_names[i].type == type) 137 return arphrd_names[i].name; 138 } 139 snprintf(buf, len, "[%d]", type); 140 return buf; 141 } 142