ll_types.c revision 98f9a1d24442399db3b1b6190010855804ca15e2
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@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 30const char * ll_type_n2a(int type, char *buf, int len) 31{ 32#define __PF(f,n) { ARPHRD_##f, #n }, 33static 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