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