]>
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_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1996 Apple Computer, Inc.
26 * Created April 8, 1996 by Tuyen Nguyen
27 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
31 #include <sys/errno.h>
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <machine/spl.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
38 #include <sys/filedesc.h>
39 #include <sys/fcntl.h>
41 #include <sys/socket.h>
42 #include <sys/socketvar.h>
45 #include <netat/sysglue.h>
46 #include <netat/appletalk.h>
47 #include <netat/at_var.h>
48 #include <netat/routing_tables.h>
49 #include <netat/at_pcb.h>
50 #include <netat/aurp.h>
51 #include <netat/debug.h>
54 * Any AURP protocol or appletalk data (ddp) packets flowing through
55 * are inserted into the kernel aurpd process's (atalk) input queue.
56 * Assume here that we deal with single packets, i.e., someone earlier
57 * in the food chain has broken up packet chains.
59 void AURPsend(mdata
, type
, node
)
63 struct aurp_domain
*domain
;
65 int msize
= AT_WR_OFFSET
+32+IP_DOMAINSIZE
;
67 /* Add the domain header */
68 if ((m
= gbuf_alloc(msize
, PRI_MED
)) == 0) {
70 dPrintf(D_M_AURP
, D_L_WARNING
, ("AURPsend: gbuf_alloc failed\n"));
74 gbuf_rinc(m
,AT_WR_OFFSET
+32);
76 domain
= (struct aurp_domain
*)gbuf_rptr(m
);
77 domain
->dst_length
= IP_LENGTH
;
78 domain
->dst_authority
= IP_AUTHORITY
;
79 domain
->dst_distinguisher
= IP_DISTINGUISHER
;
80 domain
->src_length
= IP_LENGTH
;
81 domain
->src_authority
= IP_AUTHORITY
;
82 domain
->src_distinguisher
= IP_DISTINGUISHER
;
83 domain
->src_address
= aurp_global
.src_addr
;
84 domain
->version
= AUD_Version
;
87 domain
->dst_address
= aurp_global
.dst_addr
[node
];
92 * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets
93 * sent from the AppleTalk stack, routing updates, and routing info
96 void AURPcmdx(code
, mdata
, param
)
106 if (aurp_gref
== 0) {
107 if (code
!= AURPCODE_DEBUGINFO
)
113 case AURPCODE_DATAPKT
: /* data packet */
114 node
= (unsigned char)param
;
115 if (gbuf_next(mdata
)) {
116 mdata_next
= gbuf_next(mdata
);
117 gbuf_next(mdata
) = 0;
118 AURPsend(mdata
, AUD_Atalk
, node
);
121 mdata_next
= gbuf_next(mdata
);
122 gbuf_next(mdata
) = 0;
123 /* Indicate non-AURP packet, node id of peer */
124 AURPsend(mdata
, AUD_Atalk
, node
);
125 } while (mdata_next
);
127 AURPsend(mdata
, AUD_Atalk
, node
);
130 case AURPCODE_RTUPDATE
:
131 AURPrtupdate((RT_entry
*)mdata
, param
);
134 case AURPCODE_DEBUGINFO
: /* debug info */
135 dbgBits
= *(dbgBits_t
*)mdata
;
140 dPrintf(D_M_AURP
, D_L_ERROR
, ("AURPcmdx: bad code, %d\n", code
));