10f74e101Schristos /* 20f74e101Schristos * Copyright (c) 1988, 1989, 1990, 1993, 1994, 1995, 1996 30f74e101Schristos * The Regents of the University of California. All rights reserved. 40f74e101Schristos * 50f74e101Schristos * Redistribution and use in source and binary forms, with or without 60f74e101Schristos * modification, are permitted provided that: (1) source code distributions 70f74e101Schristos * retain the above copyright notice and this paragraph in its entirety, (2) 80f74e101Schristos * distributions including binary code include the above copyright notice and 90f74e101Schristos * this paragraph in its entirety in the documentation or other materials 100f74e101Schristos * provided with the distribution, and (3) all advertising materials mentioning 110f74e101Schristos * features or use of this software display the following acknowledgement: 120f74e101Schristos * ``This product includes software developed by the University of California, 130f74e101Schristos * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 140f74e101Schristos * the University nor the names of its contributors may be used to endorse 150f74e101Schristos * or promote products derived from this software without specific prior 160f74e101Schristos * written permission. 170f74e101Schristos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 180f74e101Schristos * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 190f74e101Schristos * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 200f74e101Schristos * 210f74e101Schristos * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX). 220f74e101Schristos */ 230f74e101Schristos 240f74e101Schristos struct LAP { 25*d881c474Schristos nd_uint8_t dst; 26*d881c474Schristos nd_uint8_t src; 27*d881c474Schristos nd_uint8_t type; 280f74e101Schristos }; 290f74e101Schristos #define lapShortDDP 1 /* short DDP type */ 300f74e101Schristos #define lapDDP 2 /* DDP type */ 310f74e101Schristos #define lapKLAP 'K' /* Kinetics KLAP type */ 320f74e101Schristos 330f74e101Schristos /* Datagram Delivery Protocol */ 340f74e101Schristos 350f74e101Schristos struct atDDP { 36*d881c474Schristos nd_uint16_t length; 37*d881c474Schristos nd_uint16_t checksum; 38*d881c474Schristos nd_uint16_t dstNet; 39*d881c474Schristos nd_uint16_t srcNet; 40*d881c474Schristos nd_uint8_t dstNode; 41*d881c474Schristos nd_uint8_t srcNode; 42*d881c474Schristos nd_uint8_t dstSkt; 43*d881c474Schristos nd_uint8_t srcSkt; 44*d881c474Schristos nd_uint8_t type; 450f74e101Schristos }; 460f74e101Schristos 470f74e101Schristos struct atShortDDP { 48*d881c474Schristos nd_uint16_t length; 49*d881c474Schristos nd_uint8_t dstSkt; 50*d881c474Schristos nd_uint8_t srcSkt; 51*d881c474Schristos nd_uint8_t type; 520f74e101Schristos }; 530f74e101Schristos 540f74e101Schristos #define ddpMaxWKS 0x7F 550f74e101Schristos #define ddpMaxData 586 560f74e101Schristos #define ddpLengthMask 0x3FF 570f74e101Schristos #define ddpHopShift 10 580f74e101Schristos #define ddpSize 13 /* size of DDP header (avoid struct padding) */ 590f74e101Schristos #define ddpSSize 5 600f74e101Schristos #define ddpWKS 128 /* boundary of DDP well known sockets */ 610f74e101Schristos #define ddpRTMP 1 /* RTMP type */ 620f74e101Schristos #define ddpRTMPrequest 5 /* RTMP request type */ 630f74e101Schristos #define ddpNBP 2 /* NBP type */ 640f74e101Schristos #define ddpATP 3 /* ATP type */ 650f74e101Schristos #define ddpECHO 4 /* ECHO type */ 660f74e101Schristos #define ddpIP 22 /* IP type */ 670f74e101Schristos #define ddpARP 23 /* ARP type */ 680f74e101Schristos #define ddpEIGRP 88 /* EIGRP over Appletalk */ 690f74e101Schristos #define ddpKLAP 0x4b /* Kinetics KLAP type */ 700f74e101Schristos 710f74e101Schristos 720f74e101Schristos /* AppleTalk Transaction Protocol */ 730f74e101Schristos 740f74e101Schristos struct atATP { 75*d881c474Schristos nd_uint8_t control; 76*d881c474Schristos nd_uint8_t bitmap; 77*d881c474Schristos nd_uint16_t transID; 78*d881c474Schristos nd_uint32_t userData; 790f74e101Schristos }; 800f74e101Schristos 810f74e101Schristos #define atpReqCode 0x40 820f74e101Schristos #define atpRspCode 0x80 830f74e101Schristos #define atpRelCode 0xC0 840f74e101Schristos #define atpXO 0x20 850f74e101Schristos #define atpEOM 0x10 860f74e101Schristos #define atpSTS 0x08 870f74e101Schristos #define atpFlagMask 0x3F 880f74e101Schristos #define atpControlMask 0xF8 890f74e101Schristos #define atpMaxNum 8 900f74e101Schristos #define atpMaxData 578 910f74e101Schristos 920f74e101Schristos 930f74e101Schristos /* AppleTalk Echo Protocol */ 940f74e101Schristos 950f74e101Schristos struct atEcho { 96*d881c474Schristos nd_uint8_t echoFunction; 97*d881c474Schristos nd_uint8_t echoData[1]; /* Should be [], C99-style */ 980f74e101Schristos }; 990f74e101Schristos 1000f74e101Schristos #define echoSkt 4 /* the echoer socket */ 1010f74e101Schristos #define echoSize 1 /* size of echo header */ 1020f74e101Schristos #define echoRequest 1 /* echo request */ 1030f74e101Schristos #define echoReply 2 /* echo request */ 1040f74e101Schristos 1050f74e101Schristos 1060f74e101Schristos /* Name Binding Protocol */ 1070f74e101Schristos 1080f74e101Schristos struct atNBP { 109*d881c474Schristos nd_uint8_t control; 110*d881c474Schristos nd_uint8_t id; 1110f74e101Schristos }; 1120f74e101Schristos 1130f74e101Schristos struct atNBPtuple { 114*d881c474Schristos nd_uint16_t net; 115*d881c474Schristos nd_uint8_t node; 116*d881c474Schristos nd_uint8_t skt; 117*d881c474Schristos nd_uint8_t enumerator; 1180f74e101Schristos }; 1190f74e101Schristos 1200f74e101Schristos #define nbpBrRq 0x10 1210f74e101Schristos #define nbpLkUp 0x20 1220f74e101Schristos #define nbpLkUpReply 0x30 1230f74e101Schristos 1240f74e101Schristos #define nbpNIS 2 1250f74e101Schristos #define nbpTupleMax 15 1260f74e101Schristos 1270f74e101Schristos #define nbpHeaderSize 2 1280f74e101Schristos #define nbpTupleSize 5 1290f74e101Schristos 1300f74e101Schristos #define nbpSkt 2 /* NIS */ 1310f74e101Schristos 1320f74e101Schristos 1330f74e101Schristos /* Routing Table Maint. Protocol */ 1340f74e101Schristos 1350f74e101Schristos #define rtmpSkt 1 /* number of RTMP socket */ 1360f74e101Schristos #define rtmpSize 4 /* minimum size */ 1370f74e101Schristos #define rtmpTupleSize 3 1380f74e101Schristos 1390f74e101Schristos 1400f74e101Schristos /* Zone Information Protocol */ 1410f74e101Schristos 1420f74e101Schristos struct zipHeader { 143*d881c474Schristos nd_uint8_t command; 144*d881c474Schristos nd_uint8_t netcount; 1450f74e101Schristos }; 1460f74e101Schristos 1470f74e101Schristos #define zipHeaderSize 2 1480f74e101Schristos #define zipQuery 1 1490f74e101Schristos #define zipReply 2 1500f74e101Schristos #define zipTakedown 3 1510f74e101Schristos #define zipBringup 4 1520f74e101Schristos #define ddpZIP 6 1530f74e101Schristos #define zipSkt 6 1540f74e101Schristos #define GetMyZone 7 1550f74e101Schristos #define GetZoneList 8 1560f74e101Schristos 1570f74e101Schristos /* 1580f74e101Schristos * UDP port range used for ddp-in-udp encapsulation is 16512-16639 1590f74e101Schristos * for client sockets (128-255) and 200-327 for server sockets 1600f74e101Schristos * (0-127). We also try to recognize the pre-April 88 server 1610f74e101Schristos * socket range of 768-895. 1620f74e101Schristos */ 1630f74e101Schristos #define atalk_port(p) \ 1640f74e101Schristos (((unsigned)((p) - 16512) < 128) || \ 1650f74e101Schristos ((unsigned)((p) - 200) < 128) || \ 1660f74e101Schristos ((unsigned)((p) - 768) < 128)) 167