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