]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/aurp_tx.c
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.
39 #include <sys/errno.h>
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <machine/spl.h>
43 #include <sys/systm.h>
44 #include <sys/kernel.h>
46 #include <sys/filedesc.h>
47 #include <sys/fcntl.h>
49 #include <sys/socket.h>
50 #include <sys/socketvar.h>
53 #include <netat/sysglue.h>
54 #include <netat/appletalk.h>
55 #include <netat/at_pcb.h>
56 #include <netat/at_var.h>
57 #include <netat/routing_tables.h>
58 #include <netat/aurp.h>
59 #include <netat/debug.h>
62 * Any AURP protocol or appletalk data (ddp) packets flowing through
63 * are inserted into the kernel aurpd process's (atalk) input queue.
64 * Assume here that we deal with single packets, i.e., someone earlier
65 * in the food chain has broken up packet chains.
67 void AURPsend(mdata
, type
, node
)
71 struct aurp_domain
*domain
;
73 int msize
= AT_WR_OFFSET
+32+IP_DOMAINSIZE
;
75 /* Add the domain header */
76 if ((m
= gbuf_alloc(msize
, PRI_MED
)) == 0) {
78 dPrintf(D_M_AURP
, D_L_WARNING
, ("AURPsend: gbuf_alloc failed\n"));
82 gbuf_rinc(m
,AT_WR_OFFSET
+32);
84 domain
= (struct aurp_domain
*)gbuf_rptr(m
);
85 domain
->dst_length
= IP_LENGTH
;
86 domain
->dst_authority
= IP_AUTHORITY
;
87 domain
->dst_distinguisher
= IP_DISTINGUISHER
;
88 domain
->src_length
= IP_LENGTH
;
89 domain
->src_authority
= IP_AUTHORITY
;
90 domain
->src_distinguisher
= IP_DISTINGUISHER
;
91 domain
->src_address
= aurp_global
.src_addr
;
92 domain
->version
= AUD_Version
;
95 domain
->dst_address
= aurp_global
.dst_addr
[node
];
100 * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets
101 * sent from the AppleTalk stack, routing updates, and routing info
104 void AURPcmdx(code
, mdata
, param
)
114 if (aurp_gref
== 0) {
115 if (code
!= AURPCODE_DEBUGINFO
)
121 case AURPCODE_DATAPKT
: /* data packet */
122 node
= (unsigned char)param
;
123 if (gbuf_next(mdata
)) {
124 mdata_next
= gbuf_next(mdata
);
125 gbuf_next(mdata
) = 0;
126 AURPsend(mdata
, AUD_Atalk
, node
);
129 mdata_next
= gbuf_next(mdata
);
130 gbuf_next(mdata
) = 0;
131 /* Indicate non-AURP packet, node id of peer */
132 AURPsend(mdata
, AUD_Atalk
, node
);
133 } while (mdata_next
);
135 AURPsend(mdata
, AUD_Atalk
, node
);
138 case AURPCODE_RTUPDATE
:
139 AURPrtupdate((RT_entry
*)mdata
, param
);
142 case AURPCODE_DEBUGINFO
: /* debug info */
143 dbgBits
= *(dbgBits_t
*)mdata
;
148 dPrintf(D_M_AURP
, D_L_ERROR
, ("AURPcmdx: bad code, %d\n", code
));
152 #endif /* AURP_SUPPORT */