token.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* @(#) $Header: /home/pdw/vcvs/repos/iftop/token.h,v 1.2 2003/06/06 22:42:35 pdw Exp $ (LBL) */
  2. /*
  3. * Copyright (c) 1998, Larry Lile
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice unmodified, this list of conditions, and the following
  11. * disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. *
  28. */
  29. #define TOKEN_HDRLEN 14
  30. #define TOKEN_RING_MAC_LEN 6
  31. #define ROUTING_SEGMENT_MAX 16
  32. #define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
  33. #define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
  34. #define TOKEN_FC_LLC 1
  35. #define BROADCAST(trp) ((ntohs((trp)->token_rcf) & 0xE000) >> 13)
  36. #define RIF_LENGTH(trp) ((ntohs((trp)->token_rcf) & 0x1f00) >> 8)
  37. #define DIRECTION(trp) ((ntohs((trp)->token_rcf) & 0x0080) >> 7)
  38. #define LARGEST_FRAME(trp) ((ntohs((trp)->token_rcf) & 0x0070) >> 4)
  39. #define RING_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0xfff0) >> 4)
  40. #define BRIDGE_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0x000f))
  41. #define SEGMENT_COUNT(trp) ((RIF_LENGTH(trp) - 2) / 2)
  42. struct token_header {
  43. u_int8_t token_ac;
  44. u_int8_t token_fc;
  45. u_int8_t token_dhost[TOKEN_RING_MAC_LEN];
  46. u_int8_t token_shost[TOKEN_RING_MAC_LEN];
  47. u_int16_t token_rcf;
  48. u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
  49. };