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