3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/netatm/ipatm/ipatm_output.c,v 1.4.2.1 2000/06/02 22:39:08 archie Exp $
34 * Output IP packets across an ATM VCC
38 #include <netatm/kern_include.h>
40 #include <netatm/ipatm/ipatm_var.h>
41 #include <netatm/ipatm/ipatm_serv.h>
44 __RCSID("@(#) $FreeBSD: src/sys/netatm/ipatm/ipatm_output.c,v 1.4.2.1 2000/06/02 22:39:08 archie Exp $");
51 * All IP packets output to an ATM interface will be directed here via
52 * the atm_ifoutput() function. If there is an ATM VCC already setup for
53 * the destination IP address, then we'll just send the packet to that VCC.
54 * Otherwise we will have to setup a new VCC, ARPing for the corresponding
55 * destination ATM hardware address along the way.
58 * ifp pointer to ifnet structure
59 * m pointer to packet buffer chain to be output
60 * dst pointer to packet's IP destination address
63 * 0 packet "output" was successful
64 * errno output failed - reason indicated
68 ipatm_ifoutput(ifp, m, dst)
78 atm_pdu_print(m, "ipatm_ifoutput");
83 * See if we've already got an appropriate VCC
85 ivp = ipatm_iptovc((struct sockaddr_in *)dst, (struct atm_nif *)ifp);
94 * Can we use this VCC now??
96 if ((ivp->iv_state == IPVCC_ACTIVE) &&
97 (ivp->iv_flags & IVF_MAPOK)) {
100 * OK, now send packet
102 err = atm_cm_cpcs_data(ivp->iv_conn, m);
105 * Output problem, drop packet
112 * VCC is unavailable for data packets. Queue packet
113 * for now, but only maintain a queue length of one.
116 KB_FREEALL(ivp->iv_queue);
121 struct in_ifaddr *ia;
122 #if (defined(BSD) && (BSD < 199306))
123 extern struct ifnet loif;
127 * No VCC to destination
131 * Is packet for our interface address?
133 TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
134 if (ia->ia_ifp != ifp)
136 if (((struct sockaddr_in *)dst)->sin_addr.s_addr ==
137 IA_SIN(ia)->sin_addr.s_addr) {
140 * It's for us - hand packet to loopback driver
142 (void) if_simloop(ifp, m, dst->sa_family, 0);
148 * Is this a broadcast packet ??
150 #if (defined(BSD) && (BSD >= 199306))
151 if (in_broadcast(((struct sockaddr_in *)dst)->sin_addr, ifp)) {
153 if (in_broadcast(((struct sockaddr_in *)dst)->sin_addr)) {
159 * If interface server exists and provides broadcast
160 * services, then let it deal with this packet
163 for (inp = ipatm_nif_head; inp; inp = inp->inf_next) {
164 if (inp->inf_nif == (struct atm_nif *)ifp)
170 (inp->inf_serv == NULL) ||
171 (inp->inf_serv->is_bcast_output == NULL)) {
177 err = (*inp->inf_serv->is_bcast_output)(inp, m);
182 * How about a multicast packet ??
184 if (IN_MULTICAST(ntohl(SATOSIN(dst)->sin_addr.s_addr))) {
186 * Multicast isn't currently supported
194 * Well, I guess we need to create an SVC to the destination
196 if ((err = ipatm_createsvc(ifp, AF_INET,
197 (caddr_t)&((struct sockaddr_in *)dst)->sin_addr,
200 * SVC open is proceeding, queue packet
206 * SVC open failed, release buffers and return