]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/ddp.h
xnu-517.3.15.tar.gz
[apple/xnu.git] / bsd / netat / ddp.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 *
27 * ORIGINS: 82
28 *
29 * (C) COPYRIGHT Apple Computer, Inc. 1992-1996
30 * All Rights Reserved
31 *
32 */
33
34 #ifndef _NETAT_DDP_H_
35 #define _NETAT_DDP_H_
36 #include <sys/appleapiopts.h>
37
38 /* Header and data sizes */
39
40 #define DDP_HDR_SIZE 5 /* DDP (short) header size */
41 #define DDP_X_HDR_SIZE 13 /* DDP extended header size */
42 #define DDP_DATA_SIZE 586 /* Maximum DataGram data size */
43 #define DDP_DATAGRAM_SIZE 599 /* Maximum DataGram size */
44
45 /* DDP socket definitions */
46
47 #define DDP_SOCKET_1st_RESERVED 1 /* First in reserved range */
48 #define DDP_SOCKET_1st_EXPERIMENTAL 64 /* First in experimental range */
49 #define DDP_SOCKET_1st_DYNAMIC 128 /* First in dynamic range */
50 #define DDP_SOCKET_LAST 253 /* Last socket in any range */
51
52 /* DDP type used to replace "0" on packets sent out, for compatibility
53 with Open Transport */
54 #define DEFAULT_OT_DDPTYPE 11
55
56 /* DDP well-known sockets */
57
58 #define RTMP_SOCKET 1 /* RTMP socket number */
59 #define NBP_SOCKET 2 /* NIS socket number */
60 #define EP_SOCKET 4 /* EP socket number */
61 #define ZIP_SOCKET 6 /* ZIP socket number */
62
63 /* DDP extended header packet format */
64
65 typedef struct {
66 unsigned unused:2,
67 hopcount:4,
68 length:10; /* Datagram length */
69 ua_short checksum; /* Checksum */
70 at_net dst_net; /* Destination network number */
71 at_net src_net; /* Source network number */
72 at_node dst_node; /* Destination node ID */
73 at_node src_node; /* Source node ID */
74 at_socket dst_socket; /* Destination socket number */
75 at_socket src_socket; /* Source socket number */
76 u_char type; /* Protocol type */
77 char data[DDP_DATA_SIZE];
78 } at_ddp_t;
79
80
81 #define DDPLEN_ASSIGN(ddp, len) ddp->length = len
82 #define DDPLEN_VALUE(ddp) ddp->length
83
84
85 /* DDP module statistics and configuration */
86
87 typedef struct at_ddp_stats {
88 /* General */
89
90 /* Receive stats */
91 u_int rcv_bytes;
92 u_int rcv_packets;
93 u_int rcv_bad_length;
94 u_int rcv_unreg_socket;
95 u_int rcv_bad_socket;
96 u_int rcv_bad_checksum;
97 u_int rcv_dropped_nobuf;
98
99 /* Transmit stats */
100 u_int xmit_bytes;
101 u_int xmit_packets;
102 u_int xmit_BRT_used;
103 u_int xmit_bad_length;
104 u_int xmit_bad_addr;
105 u_int xmit_dropped_nobuf;
106 } at_ddp_stats_t;
107
108 /* DDP streams module ioctls */
109
110 #define AT_MID_DDP 203
111
112 #define DDP_IOC_MYIOCTL(i) ((i>>8) == AT_MID_DDP)
113 #define DDP_IOC_GET_CFG ((AT_MID_DDP<<8) | 1)
114
115 #ifdef NOT_USED
116 #define DDP_IOC_BIND_SOCK ((AT_MID_DDP<<8) | 2)
117 #define DDP_IOC_GET_STATS ((AT_MID_DDP<<8) | 3)
118 #define DDP_IOC_LSTATUS_TABLE ((AT_MID_DDP<<8) | 4)
119 #define DDP_IOC_ULSTATUS_TABLE ((AT_MID_DDP<<8) | 5)
120 #define DDP_IOC_RSTATUS_TABLE ((AT_MID_DDP<<8) | 6)
121 #define DDP_IOC_SET_WROFF ((AT_MID_DDP<<8) | 7 )
122 #define DDP_IOC_SET_OPTS ((AT_MID_DDP<<8) | 8 )
123 #define DDP_IOC_GET_OPTS ((AT_MID_DDP<<8) | 9 )
124 #define DDP_IOC_GET_SOCK ((AT_MID_DDP<<8) | 10)
125 #define DDP_IOC_GET_PEER ((AT_MID_DDP<<8) | 11)
126 #define DDP_IOC_SET_PEER ((AT_MID_DDP<<8) | 12)
127 #define DDP_IOC_SET_PROTO ((AT_MID_DDP<<8) | 13)
128 #endif
129
130 #ifdef KERNEL
131 #ifdef __APPLE_API_PRIVATE
132
133 #define DDP_MIN_NETWORK 0x0001
134 #define DDP_MAX_NETWORK 0xfffe
135 #define DDP_STARTUP_LOW 0xff00
136 #define DDP_STARTUP_HIGH DDP_MAX_NETWORK
137
138 typedef struct {
139 void **inputQ;
140 int *pidM;
141 char **socketM;
142 char *dbgBits;
143 } proto_reg_t;
144
145 /* *** note: this counts on the src address always being that of the
146 home port
147 *** */
148 #define FROM_US(ddp) ((NET_VALUE(ddp->src_net) ==\
149 ifID_home->ifThisNode.s_net) && \
150 ifID_home->ifThisNode.s_node == ddp->src_node)
151
152 #define RT_LOOKUP_OKAY(ifID, ddp) \
153 ((ROUTING_MODE && ifID->ifRoutingState==PORT_ONLINE) || \
154 (MULTIHOME_MODE && FROM_US(ddp)))
155
156 #ifdef NOT_YET
157 /* from sys_glue.c */
158 int ddp_adjmsg(gbuf_t *m, int len);
159 gbuf_t *ddp_growmsg(gbuf_t *mp, int len);
160
161 /* from ddp.c */
162 int ddp_add_if(at_ifaddr_t *ifID);
163 int ddp_rem_if(at_ifaddr_t *ifID);
164 int ddp_bind_socket(ddp_socket_t *socketp);
165 int ddp_close_socket(ddp_socket_t *socketp);
166 int ddp_output(gbuf_t **mp, at_socket src_socket, int src_addr_included);
167 void ddp_input(gbuf_t *mp, at_ifaddr_t *ifID);
168 int ddp_router_output(
169 gbuf_t *mp,
170 at_ifaddr_t *ifID,
171 int addr_type,
172 at_net_al router_net,
173 at_node router_node,
174 etalk_addr_t *enet_addr);
175
176 /* from ddp_proto.c */
177 int ddp_close(gref_t *gref);
178 void ddp_putmsg(gref_t *gref, gbuf_t *mp);
179 gbuf_t *ddp_compress_msg(gbuf_t *mp);
180 void ddp_stop(gbuf_t *mioc, gref_t *gref);
181
182 /* in ddp_lap.c */
183 void ddp_bit_reverse(unsigned char *);
184
185 #endif /* NOT_YET */
186
187 /* in ddp_lap.c */
188 int ddp_shutdown(int);
189
190 #endif /* __APPLE_API_PRIVATE */
191 #endif /* KERNEL */
192 #endif /* _NETAT_DDP_H_ */