]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/ddp.h
xnu-792.10.96.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 * 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 #ifndef _NETAT_DDP_H_
32 #define _NETAT_DDP_H_
33 #include <sys/appleapiopts.h>
34
35 #ifdef __APPLE_API_OBSOLETE
36
37 /* Header and data sizes */
38
39 #define DDP_HDR_SIZE 5 /* DDP (short) header size */
40 #define DDP_X_HDR_SIZE 13 /* DDP extended header size */
41 #define DDP_DATA_SIZE 586 /* Maximum DataGram data size */
42 #define DDP_DATAGRAM_SIZE 599 /* Maximum DataGram size */
43
44 /* DDP socket definitions */
45
46 #define DDP_SOCKET_1st_RESERVED 1 /* First in reserved range */
47 #define DDP_SOCKET_1st_EXPERIMENTAL 64 /* First in experimental range */
48 #define DDP_SOCKET_1st_DYNAMIC 128 /* First in dynamic range */
49 #define DDP_SOCKET_LAST 253 /* Last socket in any range */
50
51 /* DDP type used to replace "0" on packets sent out, for compatibility
52 with Open Transport */
53 #define DEFAULT_OT_DDPTYPE 11
54
55 /* DDP well-known sockets */
56
57 #define RTMP_SOCKET 1 /* RTMP socket number */
58 #define NBP_SOCKET 2 /* NIS socket number */
59 #define EP_SOCKET 4 /* EP socket number */
60 #define ZIP_SOCKET 6 /* ZIP socket number */
61
62 /* DDP extended header packet format */
63
64 typedef struct {
65 #if BYTE_ORDER == BIG_ENDIAN
66 unsigned unused:2,
67 hopcount:4, /* hop count/len high order */
68 length_H:2;
69 #endif
70 #if BYTE_ORDER == LITTLE_ENDIAN
71 unsigned length_H:2,
72 hopcount:4,
73 unused:2;
74 #endif
75 u_char length_L; /* len low order */
76 ua_short checksum; /* Checksum */
77 at_net dst_net; /* Destination network number */
78 at_net src_net; /* Source network number */
79 at_node dst_node; /* Destination node ID */
80 at_node src_node; /* Source node ID */
81 at_socket dst_socket; /* Destination socket number */
82 at_socket src_socket; /* Source socket number */
83 u_char type; /* Protocol type */
84 char data[DDP_DATA_SIZE];
85 } at_ddp_t;
86
87
88 #define DDPLEN_ASSIGN(ddp, len) \
89 ddp->length_H = 0x03 & (len >> 8); \
90 ddp->length_L = len & 0xff;
91
92 #define DDPLEN_VALUE(ddp) \
93 (((u_short)ddp->length_H) << 8) + ddp->length_L
94
95 /* DDP module statistics and configuration */
96
97 typedef struct at_ddp_stats {
98 /* General */
99
100 /* Receive stats */
101 u_int rcv_bytes;
102 u_int rcv_packets;
103 u_int rcv_bad_length;
104 u_int rcv_unreg_socket;
105 u_int rcv_bad_socket;
106 u_int rcv_bad_checksum;
107 u_int rcv_dropped_nobuf;
108
109 /* Transmit stats */
110 u_int xmit_bytes;
111 u_int xmit_packets;
112 u_int xmit_BRT_used;
113 u_int xmit_bad_length;
114 u_int xmit_bad_addr;
115 u_int xmit_dropped_nobuf;
116 } at_ddp_stats_t;
117
118
119 /* DDP streams module ioctls */
120
121 #define AT_MID_DDP 203
122
123 #define DDP_IOC_MYIOCTL(i) ((i>>8) == AT_MID_DDP)
124 #define DDP_IOC_GET_CFG ((AT_MID_DDP<<8) | 1)
125
126 #ifdef NOT_USED
127 #define DDP_IOC_BIND_SOCK ((AT_MID_DDP<<8) | 2)
128 #define DDP_IOC_GET_STATS ((AT_MID_DDP<<8) | 3)
129 #define DDP_IOC_LSTATUS_TABLE ((AT_MID_DDP<<8) | 4)
130 #define DDP_IOC_ULSTATUS_TABLE ((AT_MID_DDP<<8) | 5)
131 #define DDP_IOC_RSTATUS_TABLE ((AT_MID_DDP<<8) | 6)
132 #define DDP_IOC_SET_WROFF ((AT_MID_DDP<<8) | 7 )
133 #define DDP_IOC_SET_OPTS ((AT_MID_DDP<<8) | 8 )
134 #define DDP_IOC_GET_OPTS ((AT_MID_DDP<<8) | 9 )
135 #define DDP_IOC_GET_SOCK ((AT_MID_DDP<<8) | 10)
136 #define DDP_IOC_GET_PEER ((AT_MID_DDP<<8) | 11)
137 #define DDP_IOC_SET_PEER ((AT_MID_DDP<<8) | 12)
138 #define DDP_IOC_SET_PROTO ((AT_MID_DDP<<8) | 13)
139 #endif
140
141 #ifdef KERNEL_PRIVATE
142
143 #define DDP_MIN_NETWORK 0x0001
144 #define DDP_MAX_NETWORK 0xfffe
145 #define DDP_STARTUP_LOW 0xff00
146 #define DDP_STARTUP_HIGH DDP_MAX_NETWORK
147
148 typedef struct {
149 void **inputQ;
150 int *pidM;
151 char **socketM;
152 char *dbgBits;
153 } proto_reg_t;
154
155 /* *** note: this counts on the src address always being that of the
156 home port
157 *** */
158 #define FROM_US(ddp) ((NET_VALUE(ddp->src_net) ==\
159 ifID_home->ifThisNode.s_net) && \
160 ifID_home->ifThisNode.s_node == ddp->src_node)
161
162 #define RT_LOOKUP_OKAY(ifID, ddp) \
163 ((ROUTING_MODE && ifID->ifRoutingState==PORT_ONLINE) || \
164 (MULTIHOME_MODE && FROM_US(ddp)))
165
166 #ifdef NOT_YET
167 /* from sys_glue.c */
168 int ddp_adjmsg(gbuf_t *m, int len);
169 gbuf_t *ddp_growmsg(gbuf_t *mp, int len);
170
171 /* from ddp.c */
172 int ddp_add_if(at_ifaddr_t *ifID);
173 int ddp_rem_if(at_ifaddr_t *ifID);
174 int ddp_bind_socket(ddp_socket_t *socketp);
175 int ddp_close_socket(ddp_socket_t *socketp);
176 int ddp_output(gbuf_t **mp, at_socket src_socket, int src_addr_included);
177 void ddp_input(gbuf_t *mp, at_ifaddr_t *ifID);
178 int ddp_router_output(
179 gbuf_t *mp,
180 at_ifaddr_t *ifID,
181 int addr_type,
182 at_net_al router_net,
183 at_node router_node,
184 etalk_addr_t *enet_addr);
185
186 /* from ddp_proto.c */
187 int ddp_close(gref_t *gref);
188 void ddp_putmsg(gref_t *gref, gbuf_t *mp);
189 gbuf_t *ddp_compress_msg(gbuf_t *mp);
190 void ddp_stop(gbuf_t *mioc, gref_t *gref);
191
192 /* in ddp_lap.c */
193 void ddp_bit_reverse(unsigned char *);
194
195 #endif /* NOT_YET */
196
197 /* in ddp_lap.c */
198 int ddp_shutdown(int);
199
200 #endif /* KERNEL_PRIVATE */
201 #endif /* __APPLE_API_OBSOLETE */
202 #endif /* _NETAT_DDP_H_ */