llc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (c) 1993, 1994, 1997
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that: (1) source code distributions
  7. * retain the above copyright notice and this paragraph in its entirety, (2)
  8. * distributions including binary code include the above copyright notice and
  9. * this paragraph in its entirety in the documentation or other materials
  10. * provided with the distribution, and (3) all advertising materials mentioning
  11. * features or use of this software display the following acknowledgement:
  12. * ``This product includes software developed by the University of California,
  13. * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14. * the University nor the names of its contributors may be used to endorse
  15. * or promote products derived from this software without specific prior
  16. * written permission.
  17. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. * @(#) $Header: /home/pdw/vcvs/repos/iftop/llc.h,v 1.2 2003/06/06 22:42:35 pdw Exp $ (LBL)
  22. */
  23. /*
  24. * This stuff should come from a system header file, but there's no
  25. * obviously portable way to do that and it's not really going
  26. * to change from system to system.
  27. */
  28. /*
  29. * A somewhat abstracted view of the LLC header
  30. */
  31. struct llc {
  32. u_int8_t dsap;
  33. u_int8_t ssap;
  34. union {
  35. u_int8_t u_ctl;
  36. u_int16_t is_ctl;
  37. struct {
  38. u_int8_t snap_ui;
  39. u_int8_t snap_pi[5];
  40. } snap;
  41. struct {
  42. u_int8_t snap_ui;
  43. u_int8_t snap_orgcode[3];
  44. u_int8_t snap_ethertype[2];
  45. } snap_ether;
  46. } ctl;
  47. };
  48. #define llcui ctl.snap.snap_ui
  49. #define llcpi ctl.snap.snap_pi
  50. #define llc_orgcode ctl.snap_ether.snap_orgcode
  51. #define llc_ethertype ctl.snap_ether.snap_ethertype
  52. #define llcis ctl.is_ctl
  53. #define llcu ctl.u_ctl
  54. #define LLC_U_FMT 3
  55. #define LLC_GSAP 1
  56. #define LLC_S_FMT 1
  57. #define LLC_U_POLL 0x10
  58. #define LLC_IS_POLL 0x0100
  59. #define LLC_XID_FI 0x81
  60. #define LLC_U_CMD(u) ((u) & 0xef)
  61. #define LLC_UI 0x03
  62. #define LLC_UA 0x63
  63. #define LLC_DISC 0x43
  64. #define LLC_DM 0x0f
  65. #define LLC_SABME 0x6f
  66. #define LLC_TEST 0xe3
  67. #define LLC_XID 0xaf
  68. #define LLC_FRMR 0x87
  69. #define LLC_S_CMD(is) (((is) >> 1) & 0x03)
  70. #define LLC_RR 0x0001
  71. #define LLC_RNR 0x0005
  72. #define LLC_REJ 0x0009
  73. #define LLC_IS_NR(is) (((is) >> 9) & 0x7f)
  74. #define LLC_I_NS(is) (((is) >> 1) & 0x7f)
  75. #ifndef LLCSAP_NULL
  76. #define LLCSAP_NULL 0x00
  77. #endif
  78. #ifndef LLCSAP_GLOBAL
  79. #define LLCSAP_GLOBAL 0xff
  80. #endif
  81. #ifndef LLCSAP_8021B_I
  82. #define LLCSAP_8021B_I 0x02
  83. #endif
  84. #ifndef LLCSAP_8021B_G
  85. #define LLCSAP_8021B_G 0x03
  86. #endif
  87. #ifndef LLCSAP_IP
  88. #define LLCSAP_IP 0x06
  89. #endif
  90. #ifndef LLCSAP_PROWAYNM
  91. #define LLCSAP_PROWAYNM 0x0e
  92. #endif
  93. #ifndef LLCSAP_8021D
  94. #define LLCSAP_8021D 0x42
  95. #endif
  96. #ifndef LLCSAP_RS511
  97. #define LLCSAP_RS511 0x4e
  98. #endif
  99. #ifndef LLCSAP_ISO8208
  100. #define LLCSAP_ISO8208 0x7e
  101. #endif
  102. #ifndef LLCSAP_PROWAY
  103. #define LLCSAP_PROWAY 0x8e
  104. #endif
  105. #ifndef LLCSAP_SNAP
  106. #define LLCSAP_SNAP 0xaa
  107. #endif
  108. #ifndef LLCSAP_IPX
  109. #define LLCSAP_IPX 0xe0
  110. #endif
  111. #ifndef LLCSAP_NETBEUI
  112. #define LLCSAP_NETBEUI 0xf0
  113. #endif
  114. #ifndef LLCSAP_ISONS
  115. #define LLCSAP_ISONS 0xfe
  116. #endif
  117. #define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
  118. #define OUI_CISCO 0x00000c /* Cisco protocols */
  119. #define ETHERTYPE_CISCO_CDP 0x2000 /* Cisco Discovery Protocol */
  120. #define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
  121. #define OUI_APPLETALK 0x080007 /* Appletalk */