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