1/* 2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* 29 * 30 * ORIGINS: 82 31 * 32 * (C) COPYRIGHT Apple Computer, Inc. 1992-1996 33 * All Rights Reserved 34 * 35 */ 36 37#ifndef _NETAT_DDP_H_ 38#define _NETAT_DDP_H_ 39#include <sys/appleapiopts.h> 40 41#ifdef __APPLE_API_OBSOLETE 42 43/* Header and data sizes */ 44 45#define DDP_HDR_SIZE 5 /* DDP (short) header size */ 46#define DDP_X_HDR_SIZE 13 /* DDP extended header size */ 47#define DDP_DATA_SIZE 586 /* Maximum DataGram data size */ 48#define DDP_DATAGRAM_SIZE 599 /* Maximum DataGram size */ 49 50/* DDP socket definitions */ 51 52#define DDP_SOCKET_1st_RESERVED 1 /* First in reserved range */ 53#define DDP_SOCKET_1st_EXPERIMENTAL 64 /* First in experimental range */ 54#define DDP_SOCKET_1st_DYNAMIC 128 /* First in dynamic range */ 55#define DDP_SOCKET_LAST 253 /* Last socket in any range */ 56 57/* DDP type used to replace "0" on packets sent out, for compatibility 58 with Open Transport */ 59#define DEFAULT_OT_DDPTYPE 11 60 61/* DDP well-known sockets */ 62 63#define RTMP_SOCKET 1 /* RTMP socket number */ 64#define NBP_SOCKET 2 /* NIS socket number */ 65#define EP_SOCKET 4 /* EP socket number */ 66#define ZIP_SOCKET 6 /* ZIP socket number */ 67 68/* DDP extended header packet format */ 69 70typedef struct { 71#if BYTE_ORDER == BIG_ENDIAN 72 unsigned unused:2, 73 hopcount:4, /* hop count/len high order */ 74 length_H:2; 75#endif 76#if BYTE_ORDER == LITTLE_ENDIAN 77 unsigned length_H:2, 78 hopcount:4, 79 unused:2; 80#endif 81 u_char length_L; /* len low order */ 82 ua_short checksum; /* Checksum */ 83 at_net dst_net; /* Destination network number */ 84 at_net src_net; /* Source network number */ 85 at_node dst_node; /* Destination node ID */ 86 at_node src_node; /* Source node ID */ 87 at_socket dst_socket; /* Destination socket number */ 88 at_socket src_socket; /* Source socket number */ 89 u_char type; /* Protocol type */ 90 char data[DDP_DATA_SIZE]; 91} at_ddp_t; 92 93 94#define DDPLEN_ASSIGN(ddp, len) \ 95 ddp->length_H = 0x03 & (len >> 8); \ 96 ddp->length_L = len & 0xff; 97 98#define DDPLEN_VALUE(ddp) \ 99 (((u_short)ddp->length_H) << 8) + ddp->length_L 100 101/* DDP module statistics and configuration */ 102 103typedef struct at_ddp_stats { 104 /* General */ 105 106 /* Receive stats */ 107 u_int rcv_bytes; 108 u_int rcv_packets; 109 u_int rcv_bad_length; 110 u_int rcv_unreg_socket; 111 u_int rcv_bad_socket; 112 u_int rcv_bad_checksum; 113 u_int rcv_dropped_nobuf; 114 115 /* Transmit stats */ 116 u_int xmit_bytes; 117 u_int xmit_packets; 118 u_int xmit_BRT_used; 119 u_int xmit_bad_length; 120 u_int xmit_bad_addr; 121 u_int xmit_dropped_nobuf; 122} at_ddp_stats_t; 123 124 125/* DDP streams module ioctls */ 126 127#define AT_MID_DDP 203 128 129#define DDP_IOC_MYIOCTL(i) ((i>>8) == AT_MID_DDP) 130#define DDP_IOC_GET_CFG ((AT_MID_DDP<<8) | 1) 131 132#ifdef NOT_USED 133#define DDP_IOC_BIND_SOCK ((AT_MID_DDP<<8) | 2) 134#define DDP_IOC_GET_STATS ((AT_MID_DDP<<8) | 3) 135#define DDP_IOC_LSTATUS_TABLE ((AT_MID_DDP<<8) | 4) 136#define DDP_IOC_ULSTATUS_TABLE ((AT_MID_DDP<<8) | 5) 137#define DDP_IOC_RSTATUS_TABLE ((AT_MID_DDP<<8) | 6) 138#define DDP_IOC_SET_WROFF ((AT_MID_DDP<<8) | 7 ) 139#define DDP_IOC_SET_OPTS ((AT_MID_DDP<<8) | 8 ) 140#define DDP_IOC_GET_OPTS ((AT_MID_DDP<<8) | 9 ) 141#define DDP_IOC_GET_SOCK ((AT_MID_DDP<<8) | 10) 142#define DDP_IOC_GET_PEER ((AT_MID_DDP<<8) | 11) 143#define DDP_IOC_SET_PEER ((AT_MID_DDP<<8) | 12) 144#define DDP_IOC_SET_PROTO ((AT_MID_DDP<<8) | 13) 145#endif 146 147#ifdef KERNEL_PRIVATE 148 149#define DDP_MIN_NETWORK 0x0001 150#define DDP_MAX_NETWORK 0xfffe 151#define DDP_STARTUP_LOW 0xff00 152#define DDP_STARTUP_HIGH DDP_MAX_NETWORK 153 154typedef struct { 155 void **inputQ; 156 int *pidM; 157 char **socketM; 158 char *dbgBits; 159} proto_reg_t; 160 161/* *** note: this counts on the src address always being that of the 162 home port 163 *** */ 164#define FROM_US(ddp) ((NET_VALUE(ddp->src_net) ==\ 165 ifID_home->ifThisNode.s_net) && \ 166 ifID_home->ifThisNode.s_node == ddp->src_node) 167 168#define RT_LOOKUP_OKAY(ifID, ddp) \ 169 ((ROUTING_MODE && ifID->ifRoutingState==PORT_ONLINE) || \ 170 (MULTIHOME_MODE && FROM_US(ddp))) 171 172#ifdef NOT_YET 173/* from sys_glue.c */ 174 175/* from ddp.c */ 176int ddp_bind_socket(ddp_socket_t *socketp); 177int ddp_close_socket(ddp_socket_t *socketp); 178 179/* from ddp_proto.c */ 180int ddp_close(gref_t *gref); 181void ddp_putmsg(gref_t *gref, gbuf_t *mp); 182void ddp_stop(gbuf_t *mioc, gref_t *gref); 183 184/* in ddp_lap.c */ 185 186#endif /* NOT_YET */ 187 188void ddp_bit_reverse(unsigned char *); 189 190int ddp_pru_abort(struct socket *so); 191 192int ddp_pru_attach(struct socket *so, int proto, 193 struct proc *p); 194int ddp_pru_bind(struct socket *so, struct sockaddr *nam, 195 struct proc *p); 196int ddp_pru_connect(struct socket *so, struct sockaddr *nam, 197 struct proc *p); 198 199int ddp_pru_control(struct socket *so, u_long cmd, caddr_t data, 200 struct ifnet *ifp, struct proc *p); 201int ddp_pru_detach(struct socket *so); 202int ddp_pru_disconnect(struct socket *so); 203 204int ddp_pru_peeraddr(struct socket *so, 205 struct sockaddr **nam); 206 207int ddp_pru_send(struct socket *so, int flags, struct mbuf *m, 208 struct sockaddr *addr, struct mbuf *control, 209 struct proc *p); 210 211int ddp_pru_shutdown(struct socket *so); 212int ddp_pru_sockaddr(struct socket *so, 213 struct sockaddr **nam); 214 215int ddp_output(gbuf_t **, at_socket , int ); 216u_short ddp_checksum(gbuf_t *, int); 217gbuf_t *ddp_compress_msg(gbuf_t *); 218 219struct at_ifaddr; 220struct etalk_addr; 221 222int ddp_router_output( 223 gbuf_t *mp, 224 struct at_ifaddr *ifID, 225 int addr_type, 226 at_net_al router_net, 227 at_node router_node, 228 struct etalk_addr *enet_addr); 229 230struct at_ifaddr *forUs(at_ddp_t *); 231 232void zip_send_queries(struct at_ifaddr *, at_net_al, at_node); 233int zip_handle_getmyzone(struct at_ifaddr *, gbuf_t *); 234int zip_type_packet(gbuf_t *); 235void zip_sched_getnetinfo (void *); 236 237int at_unreg_mcast(struct at_ifaddr *, caddr_t); 238int at_reg_mcast(struct at_ifaddr *, caddr_t); 239 240int ddp_shutdown(int); 241 242void routing_needed(gbuf_t *, struct at_ifaddr *, char); 243 244int getPhysAddrSize(int); 245int getAarpTableSize(int); 246 247int aarp_init1(struct at_ifaddr *); 248int aarp_init2(struct at_ifaddr *); 249 250int getRtmpTableSize(void); 251 252void sethzonehash(struct at_ifaddr *); 253 254int ddp_add_if(struct at_ifaddr *); 255void ddp_rem_if(struct at_ifaddr *); 256 257void ddp_brt_init(void); 258void ddp_brt_shutdown(void); 259 260int setLocalZones(at_nvestr_t *, int); 261 262void ddp_brt_sweep(void); 263 264 265#endif /* KERNEL_PRIVATE */ 266#endif /* __APPLE_API_OBSOLETE */ 267#endif /* _NETAT_DDP_H_ */ 268