appletalk.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (c) 1988, 1989, 1990, 1993, 1994, 1995, 1996
  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. * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
  22. */
  23. struct LAP {
  24. uint8_t dst;
  25. uint8_t src;
  26. uint8_t type;
  27. };
  28. #define lapShortDDP 1 /* short DDP type */
  29. #define lapDDP 2 /* DDP type */
  30. #define lapKLAP 'K' /* Kinetics KLAP type */
  31. /* Datagram Delivery Protocol */
  32. struct atDDP {
  33. uint16_t length;
  34. uint16_t checksum;
  35. uint16_t dstNet;
  36. uint16_t srcNet;
  37. uint8_t dstNode;
  38. uint8_t srcNode;
  39. uint8_t dstSkt;
  40. uint8_t srcSkt;
  41. uint8_t type;
  42. };
  43. struct atShortDDP {
  44. uint16_t length;
  45. uint8_t dstSkt;
  46. uint8_t srcSkt;
  47. uint8_t type;
  48. };
  49. #define ddpMaxWKS 0x7F
  50. #define ddpMaxData 586
  51. #define ddpLengthMask 0x3FF
  52. #define ddpHopShift 10
  53. #define ddpSize 13 /* size of DDP header (avoid struct padding) */
  54. #define ddpSSize 5
  55. #define ddpWKS 128 /* boundary of DDP well known sockets */
  56. #define ddpRTMP 1 /* RTMP type */
  57. #define ddpRTMPrequest 5 /* RTMP request type */
  58. #define ddpNBP 2 /* NBP type */
  59. #define ddpATP 3 /* ATP type */
  60. #define ddpECHO 4 /* ECHO type */
  61. #define ddpIP 22 /* IP type */
  62. #define ddpARP 23 /* ARP type */
  63. #define ddpEIGRP 88 /* EIGRP over Appletalk */
  64. #define ddpKLAP 0x4b /* Kinetics KLAP type */
  65. /* AppleTalk Transaction Protocol */
  66. struct atATP {
  67. uint8_t control;
  68. uint8_t bitmap;
  69. uint16_t transID;
  70. int32_t userData;
  71. };
  72. #define atpReqCode 0x40
  73. #define atpRspCode 0x80
  74. #define atpRelCode 0xC0
  75. #define atpXO 0x20
  76. #define atpEOM 0x10
  77. #define atpSTS 0x08
  78. #define atpFlagMask 0x3F
  79. #define atpControlMask 0xF8
  80. #define atpMaxNum 8
  81. #define atpMaxData 578
  82. /* AppleTalk Echo Protocol */
  83. struct atEcho {
  84. uint8_t echoFunction;
  85. uint8_t *echoData;
  86. };
  87. #define echoSkt 4 /* the echoer socket */
  88. #define echoSize 1 /* size of echo header */
  89. #define echoRequest 1 /* echo request */
  90. #define echoReply 2 /* echo request */
  91. /* Name Binding Protocol */
  92. struct atNBP {
  93. uint8_t control;
  94. uint8_t id;
  95. };
  96. struct atNBPtuple {
  97. uint16_t net;
  98. uint8_t node;
  99. uint8_t skt;
  100. uint8_t enumerator;
  101. };
  102. #define nbpBrRq 0x10
  103. #define nbpLkUp 0x20
  104. #define nbpLkUpReply 0x30
  105. #define nbpNIS 2
  106. #define nbpTupleMax 15
  107. #define nbpHeaderSize 2
  108. #define nbpTupleSize 5
  109. #define nbpSkt 2 /* NIS */
  110. /* Routing Table Maint. Protocol */
  111. #define rtmpSkt 1 /* number of RTMP socket */
  112. #define rtmpSize 4 /* minimum size */
  113. #define rtmpTupleSize 3
  114. /* Zone Information Protocol */
  115. struct zipHeader {
  116. uint8_t command;
  117. uint8_t netcount;
  118. };
  119. #define zipHeaderSize 2
  120. #define zipQuery 1
  121. #define zipReply 2
  122. #define zipTakedown 3
  123. #define zipBringup 4
  124. #define ddpZIP 6
  125. #define zipSkt 6
  126. #define GetMyZone 7
  127. #define GetZoneList 8
  128. /*
  129. * UDP port range used for ddp-in-udp encapsulation is 16512-16639
  130. * for client sockets (128-255) and 200-327 for server sockets
  131. * (0-127). We also try to recognize the pre-April 88 server
  132. * socket range of 768-895.
  133. */
  134. #define atalk_port(p) \
  135. (((unsigned)((p) - 16512) < 128) || \
  136. ((unsigned)((p) - 200) < 128) || \
  137. ((unsigned)((p) - 768) < 128))