ll_types.c 2.2 KB

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