|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * ! 24: * ORIGINS: 82 ! 25: * ! 26: * (C) COPYRIGHT Apple Computer, Inc. 1992-1996 ! 27: * All Rights Reserved ! 28: * ! 29: */ ! 30: ! 31: /* Miscellaneous definitions for AppleTalk used by all protocol ! 32: * modules. ! 33: */ ! 34: ! 35: #ifndef _NETAT_APPLETALK_H_ ! 36: #define _NETAT_APPLETALK_H_ ! 37: ! 38: #include <sys/types.h> ! 39: #include <sys/uio.h> ! 40: ! 41: /* ! 42: Non-aligned types are used in packet headers. ! 43: */ ! 44: ! 45: /* New fundemental types: non-aligned variations of u_short and u_long */ ! 46: typedef u_char ua_short[2]; /* Unaligned short */ ! 47: typedef u_char ua_long[4]; /* Unaligned long */ ! 48: ! 49: /* Two at_net typedefs; the first is aligned the other isn't */ ! 50: typedef u_short at_net_al; /* Aligned AppleTalk network number */ ! 51: typedef ua_short at_net_unal; /* Unaligned AppleTalk network number */ ! 52: ! 53: /* Miscellaneous types */ ! 54: typedef u_char at_node; /* AppleTalk node number */ ! 55: typedef u_char at_socket; /* AppleTalk socket number */ ! 56: ! 57: typedef at_net_unal at_net; /* Default: Unaligned AppleTalk network number */ ! 58: struct atalk_addr { ! 59: u_char atalk_unused; ! 60: at_net atalk_net; ! 61: at_node atalk_node; ! 62: }; ! 63: ! 64: /* Macros to manipulate unaligned fields */ ! 65: #define UAS_ASSIGN(x,s) *(unsigned short *) &(x[0]) = (unsigned short) (s) ! 66: #define UAS_UAS(x,y) *(unsigned short *) &(x[0]) = *(unsigned short *) &(y[0]) ! 67: #define UAS_VALUE(x) (*(unsigned short *) &(x[0])) ! 68: #define UAL_ASSIGN(x,l) *(unsigned long *) &(x[0]) = (unsigned long) (l) ! 69: #define UAL_UAL(x,y) *(unsigned long *) &(x[0]) = *(unsigned long *) &(y[0]) ! 70: #define UAL_VALUE(x) (*(unsigned long *) &(x[0])) ! 71: ! 72: /* Macros to manipulate at_net variables */ ! 73: #define NET_ASSIGN(x,s) *(unsigned short *)&(x[0]) = (unsigned short)(s) ! 74: #define NET_NET(x, y) *(unsigned short *)&(x[0]) = *(unsigned short *)&(y[0]) ! 75: #define NET_VALUE(x) (*(unsigned short *) &(x[0])) ! 76: #define ATALK_ASSIGN(a, net, node, unused ) \ ! 77: a.atalk_unused = unused; a.atalk_node = node; NET_ASSIGN(a.atalk_net, net) ! 78: ! 79: #define NET_EQUAL(a, b) (NET_VALUE(a) == NET_VALUE(b)) ! 80: #define NET_NOTEQ(a, b) (NET_VALUE(a) != NET_VALUE(b)) ! 81: #define NET_EQUAL0(a) (NET_VALUE(a) == 0) ! 82: #define NET_NOTEQ0(a) (NET_VALUE(a) != 0) ! 83: ! 84: ! 85: /* ! 86: AppleTalk Internet Address ! 87: */ ! 88: ! 89: typedef struct at_inet { ! 90: u_short net; /* Network Address */ ! 91: u_char node; /* Node number */ ! 92: u_char socket; /* Socket number */ ! 93: } at_inet_t; ! 94: ! 95: /* ! 96: DDP Address for OT ! 97: */ ! 98: ! 99: typedef struct ddp_addr { ! 100: at_inet_t inet; ! 101: u_short ddptype; ! 102: } ddp_addr_t; ! 103: ! 104: /* ! 105: AppleTalk address ! 106: */ ! 107: ! 108: struct at_addr { ! 109: u_short s_net; /* 16-bit network address */ ! 110: u_char s_node; /* 8-bit node # (1-0xfd) */ ! 111: }; ! 112: ! 113: /* ! 114: Appletalk sockaddr definition ! 115: */ ! 116: struct sockaddr_at { ! 117: u_char sat_len; /* total length */ ! 118: u_char sat_family; /* address family (AF_APPLETALK) */ ! 119: u_char sat_port; /* 8-bit "socket number" */ ! 120: struct at_addr sat_addr; /* 16-bit "net" and 8-bit "node */ ! 121: char sat_zero[8]; /* used for netrange in netatalk */ ! 122: }; ! 123: ! 124: #define ATADDR_ANYNET (u_short)0x0000 ! 125: #define ATADDR_ANYNODE (u_char)0x00 ! 126: #define ATADDR_ANYPORT (u_char)0x00 ! 127: ! 128: #define ATADDR_BCASTNODE (u_char)0xff /* There is no BCAST for NET */ ! 129: ! 130: /* make sure the net, node and socket numbers are in legal range : ! 131: * ! 132: * Net# 0 Local Net ! 133: * 1 - 0xfffe Legal net nos ! 134: * 0xffff Reserved by Apple for future use. ! 135: * Node# 0 Illegal ! 136: * 1 - 0x7f Legal (user node id's) ! 137: * 0x80 - 0xfe Legal (server node id's; 0xfe illegal in ! 138: * Phase II nodes) ! 139: * 0xff Broadcast ! 140: * Socket# 0 Illegal ! 141: * 1 - 0xfe Legal ! 142: * 0xff Illegal ! 143: */ ! 144: #define valid_at_addr(addr) \ ! 145: ((!(addr) || (addr)->net == 0xffff || (addr)->node == 0 || \ ! 146: (addr)->socket == 0 || (addr)->socket == 0xff)? 0: 1) ! 147: ! 148: /*** * ETHERTYPE_ definitions are in netinet/if_ether.h *** */ ! 149: #define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ ! 150: #define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ ! 151: ! 152: /* ! 153: DDP protocol types ! 154: */ ! 155: ! 156: #define DDP_RTMP 0x01 ! 157: #define DDP_NBP 0x02 ! 158: #define DDP_ATP 0x03 ! 159: #define DDP_ECHO 0x04 ! 160: #define DDP_RTMP_REQ 0x05 ! 161: #define DDP_ZIP 0x06 ! 162: #define DDP_ADSP 0x07 ! 163: ! 164: /* ! 165: Protocols for the socket API ! 166: */ ! 167: ! 168: #define ATPROTO_NONE 0 /* no corresponding DDP type exists */ ! 169: ! 170: #define ATPROTO_ATP DDP_ATP /* must match DDP type */ ! 171: #define ATPROTO_ADSP DDP_ADSP /* must match DDP type */ ! 172: ! 173: #define ATPROTO_DDP 249 /* *** to be eliminated eventually *** */ ! 174: #define ATPROTO_LAP 250 /* *** to be eliminated eventually *** */ ! 175: ! 176: #define ATPROTO_AURP 251 /* no corresponding DDP type exists */ ! 177: #define ATPROTO_ASP 252 /* no corresponding DDP type exists */ ! 178: #define ATPROTO_AFP 253 /* no corresponding DDP type exists */ ! 179: ! 180: #define ATPROTO_RAW 255 /* no corresponding DDP type exists */ ! 181: ! 182: /* ! 183: Options for use with [gs]etsockopt at the DDP level. ! 184: First word of comment is data type; bool is stored in int. ! 185: */ ! 186: #define DDP_CHKSUM_ON 1 /* DDP checksums should be used */ ! 187: /* *** DDP_CHKSUM_ON not yet fully implemented *** */ ! 188: #define DDP_HDRINCL 2 /* int; header is included with data */ ! 189: #define DDP_GETSOCKNAME 3 /* used to get ddp_addr_t */ ! 190: #define DDP_SLFSNDOFF 4 /* packets sent to the cable-multicast address ! 191: on this socket should not be looped back */ ! 192: /* *** DDP_SLFSNDOFF not yet fully implemented *** */ ! 193: #define DDP_STRIPHDR 5 /* drop DDP header on receive (raw) */ ! 194: ! 195: /* ! 196: AppleTalk protocol retry and timeout ! 197: */ ! 198: ! 199: typedef struct at_retry { ! 200: short interval; /* Retry interval in seconds */ ! 201: short retries; /* Maximum number of retries */ ! 202: u_char backoff; /* Retry backoff, must be 1 through 4 */ ! 203: } at_retry_t; ! 204: ! 205: /* ! 206: Basic NBP Definitions needed for LibcAT ! 207: */ ! 208: ! 209: #define NBP_NVE_STR_SIZE 32 /* Maximum NBP tuple string size */ ! 210: typedef struct at_nvestr { ! 211: u_char len; ! 212: u_char str[NBP_NVE_STR_SIZE]; ! 213: } at_nvestr_t; ! 214: ! 215: /* Entity Name */ ! 216: typedef struct at_entity { ! 217: at_nvestr_t object; ! 218: at_nvestr_t type; ! 219: at_nvestr_t zone; ! 220: } at_entity_t; ! 221: ! 222: #define NBP_TUPLE_SIZE ((3*NBP_NVE_STR_SIZE)+3) ! 223: /* 3 for field lengths + 3*32 for three names */ ! 224: typedef struct at_nbptuple { ! 225: at_inet_t enu_addr; ! 226: u_char enu_enum; ! 227: at_entity_t enu_entity; ! 228: } at_nbptuple_t; ! 229: ! 230: /* ! 231: Basic ATP Definitions needed for LibcAT ! 232: */ ! 233: ! 234: #define ATP_TRESP_MAX 8 /* Maximum number of Tresp pkts */ ! 235: ! 236: /* Response buffer structure for atp_sendreq() and atp_sendrsp() */ ! 237: typedef struct at_resp { ! 238: u_char bitmap; /* Bitmap of responses */ ! 239: u_char filler[3]; /* Force 68K to RISC alignment */ ! 240: struct iovec resp[ATP_TRESP_MAX]; /* Buffer for response data */ ! 241: long userdata[ATP_TRESP_MAX]; /* Buffer for response user data */ ! 242: } at_resp_t; ! 243: ! 244: /* ! 245: Needed for ASP and ADSP ! 246: */ ! 247: ! 248: typedef struct { ! 249: int maxlen; /* max buffer length */ ! 250: int len; /* length of data */ ! 251: char *buf; /* pointer to buffer */ ! 252: } strbuf_t; ! 253: ! 254: #define IFID_HOME 0 /* home port in ifID_table */ ! 255: ! 256: #define ATALK_VALUE(a) ((*(u_long *) &(a))&0x00ffffff) ! 257: #define ATALK_EQUAL(a, b) (ATALK_VALUE(a) == ATALK_VALUE(b)) ! 258: ! 259: #define VERSION_LENGTH 80 /* length of version string */ ! 260: ! 261: /* struture containing general information regarding the state of ! 262: * the Appletalk networking ! 263: */ ! 264: typedef struct at_state { ! 265: unsigned int flags; /* various init flags */ ! 266: } at_state_t; ! 267: ! 268: /* at_state_t 'flags' defines */ ! 269: #define AT_ST_STARTED 0x0001 ! 270: #define AT_ST_MULTIHOME 0x0080 /* set if multihome mode */ ! 271: #define AT_ST_ROUTER 0x0100 /* set if we are a router */ ! 272: #define AT_ST_IF_CHANGED 0x0200 /* set when state of any I/F ! 273: changes (for SNMP) */ ! 274: #define AT_ST_RT_CHANGED 0x0400 /* route table changed (for SNMP)*/ ! 275: #define AT_ST_ZT_CHANGED 0x0800 /* zone table changed (for SNMP) */ ! 276: #define AT_ST_NBP_CHANGED 0x1000 /* if nbp table changed (for SNMP)*/ ! 277: ! 278: #ifdef KERNEL ! 279: extern at_state_t at_state; /* global state of AT network */ ! 280: ! 281: #define ROUTING_MODE (at_state.flags & AT_ST_ROUTER) ! 282: #define MULTIHOME_MODE (at_state.flags & AT_ST_MULTIHOME) ! 283: #define MULTIPORT_MODE (ROUTING_MODE || MULTIHOME_MODE) ! 284: #endif /* KERNEL */ ! 285: ! 286: /* defines originally from h/at_elap.h */ ! 287: #define AT_ADDR 0 ! 288: #define ET_ADDR 1 ! 289: #define AT_ADDR_NO_LOOP 2 /* disables packets from looping back */ ! 290: ! 291: #endif /* _NETAT_APPLETALK_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.