]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_tx.c
729b6e953c8e59ddbcbf42b7e15e1af0362c551c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1996 Apple Computer, Inc.
31 * Created April 8, 1996 by Tuyen Nguyen
32 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
36 #include <sys/errno.h>
37 #include <sys/types.h>
38 #include <sys/param.h>
39 #include <machine/spl.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
43 #include <sys/filedesc.h>
44 #include <sys/fcntl.h>
46 #include <sys/socket.h>
47 #include <sys/socketvar.h>
50 #include <netat/sysglue.h>
51 #include <netat/appletalk.h>
52 #include <netat/at_var.h>
53 #include <netat/routing_tables.h>
54 #include <netat/at_pcb.h>
55 #include <netat/aurp.h>
56 #include <netat/debug.h>
59 * Any AURP protocol or appletalk data (ddp) packets flowing through
60 * are inserted into the kernel aurpd process's (atalk) input queue.
61 * Assume here that we deal with single packets, i.e., someone earlier
62 * in the food chain has broken up packet chains.
64 void AURPsend(mdata
, type
, node
)
68 struct aurp_domain
*domain
;
70 int msize
= AT_WR_OFFSET
+32+IP_DOMAINSIZE
;
72 /* Add the domain header */
73 if ((m
= gbuf_alloc(msize
, PRI_MED
)) == 0) {
75 dPrintf(D_M_AURP
, D_L_WARNING
, ("AURPsend: gbuf_alloc failed\n"));
79 gbuf_rinc(m
,AT_WR_OFFSET
+32);
81 domain
= (struct aurp_domain
*)gbuf_rptr(m
);
82 domain
->dst_length
= IP_LENGTH
;
83 domain
->dst_authority
= IP_AUTHORITY
;
84 domain
->dst_distinguisher
= IP_DISTINGUISHER
;
85 domain
->src_length
= IP_LENGTH
;
86 domain
->src_authority
= IP_AUTHORITY
;
87 domain
->src_distinguisher
= IP_DISTINGUISHER
;
88 domain
->src_address
= aurp_global
.src_addr
;
89 domain
->version
= AUD_Version
;
92 domain
->dst_address
= aurp_global
.dst_addr
[node
];
97 * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets
98 * sent from the AppleTalk stack, routing updates, and routing info
101 void AURPcmdx(code
, mdata
, param
)
111 if (aurp_gref
== 0) {
112 if (code
!= AURPCODE_DEBUGINFO
)
118 case AURPCODE_DATAPKT
: /* data packet */
119 node
= (unsigned char)param
;
120 if (gbuf_next(mdata
)) {
121 mdata_next
= gbuf_next(mdata
);
122 gbuf_next(mdata
) = 0;
123 AURPsend(mdata
, AUD_Atalk
, node
);
126 mdata_next
= gbuf_next(mdata
);
127 gbuf_next(mdata
) = 0;
128 /* Indicate non-AURP packet, node id of peer */
129 AURPsend(mdata
, AUD_Atalk
, node
);
130 } while (mdata_next
);
132 AURPsend(mdata
, AUD_Atalk
, node
);
135 case AURPCODE_RTUPDATE
:
136 AURPrtupdate((RT_entry
*)mdata
, param
);
139 case AURPCODE_DEBUGINFO
: /* debug info */
140 dbgBits
= *(dbgBits_t
*)mdata
;
145 dPrintf(D_M_AURP
, D_L_ERROR
, ("AURPcmdx: bad code, %d\n", code
));