]>
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 * 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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1996 Apple Computer, Inc.
25 * Created April 8, 1996 by Tuyen Nguyen
26 * Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
30 #include <sys/errno.h>
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <machine/spl.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/filedesc.h>
38 #include <sys/fcntl.h>
40 #include <sys/socket.h>
41 #include <sys/socketvar.h>
44 #include <netat/sysglue.h>
45 #include <netat/appletalk.h>
46 #include <netat/at_var.h>
47 #include <netat/routing_tables.h>
48 #include <netat/at_pcb.h>
49 #include <netat/aurp.h>
50 #include <netat/debug.h>
53 * Any AURP protocol or appletalk data (ddp) packets flowing through
54 * are inserted into the kernel aurpd process's (atalk) input queue.
55 * Assume here that we deal with single packets, i.e., someone earlier
56 * in the food chain has broken up packet chains.
58 void AURPsend(mdata
, type
, node
)
62 struct aurp_domain
*domain
;
64 int msize
= AT_WR_OFFSET
+32+IP_DOMAINSIZE
;
66 /* Add the domain header */
67 if ((m
= gbuf_alloc(msize
, PRI_MED
)) == 0) {
69 dPrintf(D_M_AURP
, D_L_WARNING
, ("AURPsend: gbuf_alloc failed\n"));
73 gbuf_rinc(m
,AT_WR_OFFSET
+32);
75 domain
= (struct aurp_domain
*)gbuf_rptr(m
);
76 domain
->dst_length
= IP_LENGTH
;
77 domain
->dst_authority
= IP_AUTHORITY
;
78 domain
->dst_distinguisher
= IP_DISTINGUISHER
;
79 domain
->src_length
= IP_LENGTH
;
80 domain
->src_authority
= IP_AUTHORITY
;
81 domain
->src_distinguisher
= IP_DISTINGUISHER
;
82 domain
->src_address
= aurp_global
.src_addr
;
83 domain
->version
= AUD_Version
;
86 domain
->dst_address
= aurp_global
.dst_addr
[node
];
91 * Called from within ddp (via ddp_AURPsendx) to handle data (DDP) packets
92 * sent from the AppleTalk stack, routing updates, and routing info
95 void AURPcmdx(code
, mdata
, param
)
105 if (aurp_gref
== 0) {
106 if (code
!= AURPCODE_DEBUGINFO
)
112 case AURPCODE_DATAPKT
: /* data packet */
113 node
= (unsigned char)param
;
114 if (gbuf_next(mdata
)) {
115 mdata_next
= gbuf_next(mdata
);
116 gbuf_next(mdata
) = 0;
117 AURPsend(mdata
, AUD_Atalk
, node
);
120 mdata_next
= gbuf_next(mdata
);
121 gbuf_next(mdata
) = 0;
122 /* Indicate non-AURP packet, node id of peer */
123 AURPsend(mdata
, AUD_Atalk
, node
);
124 } while (mdata_next
);
126 AURPsend(mdata
, AUD_Atalk
, node
);
129 case AURPCODE_RTUPDATE
:
130 AURPrtupdate((RT_entry
*)mdata
, param
);
133 case AURPCODE_DEBUGINFO
: /* debug info */
134 dbgBits
= *(dbgBits_t
*)mdata
;
139 dPrintf(D_M_AURP
, D_L_ERROR
, ("AURPcmdx: bad code, %d\n", code
));