Deleted Added
full compact
in6_src.c (78064) in6_src.c (83130)
1/* $FreeBSD: head/sys/netinet6/in6_src.c 78064 2001-06-11 12:39:29Z ume $ */
1/* $FreeBSD: head/sys/netinet6/in6_src.c 83130 2001-09-06 02:40:43Z jlemon $ */
2/* $KAME: in6_src.c,v 1.37 2001/03/29 05:34:31 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 126 unchanged lines hidden (view full) ---

136
137 /*
138 * If the caller doesn't specify the source address but
139 * the outgoing interface, use an address associated with
140 * the interface.
141 */
142 if (pi && pi->ipi6_ifindex) {
143 /* XXX boundary check is assumed to be already done. */
2/* $KAME: in6_src.c,v 1.37 2001/03/29 05:34:31 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 126 unchanged lines hidden (view full) ---

136
137 /*
138 * If the caller doesn't specify the source address but
139 * the outgoing interface, use an address associated with
140 * the interface.
141 */
142 if (pi && pi->ipi6_ifindex) {
143 /* XXX boundary check is assumed to be already done. */
144 ia6 = in6_ifawithscope(ifindex2ifnet[pi->ipi6_ifindex],
145 dst);
144 ia6 = in6_ifawithscope(ifnet_byindex(pi->ipi6_ifindex), dst);
146 if (ia6 == 0) {
147 *errorp = EADDRNOTAVAIL;
148 return(0);
149 }
150 return(&satosin6(&ia6->ia_addr)->sin6_addr);
151 }
152
153 /*

--- 11 unchanged lines hidden (view full) ---

165 * I'm not sure if boundary check for scope_id is done
166 * somewhere...
167 */
168 if (dstsock->sin6_scope_id < 0 ||
169 if_index < dstsock->sin6_scope_id) {
170 *errorp = ENXIO; /* XXX: better error? */
171 return(0);
172 }
145 if (ia6 == 0) {
146 *errorp = EADDRNOTAVAIL;
147 return(0);
148 }
149 return(&satosin6(&ia6->ia_addr)->sin6_addr);
150 }
151
152 /*

--- 11 unchanged lines hidden (view full) ---

164 * I'm not sure if boundary check for scope_id is done
165 * somewhere...
166 */
167 if (dstsock->sin6_scope_id < 0 ||
168 if_index < dstsock->sin6_scope_id) {
169 *errorp = ENXIO; /* XXX: better error? */
170 return(0);
171 }
173 ia6 = in6_ifawithscope(ifindex2ifnet[dstsock->sin6_scope_id],
172 ia6 = in6_ifawithscope(ifnet_byindex(dstsock->sin6_scope_id),
174 dst);
175 if (ia6 == 0) {
176 *errorp = EADDRNOTAVAIL;
177 return(0);
178 }
179 return(&satosin6(&ia6->ia_addr)->sin6_addr);
180 }
181

--- 287 unchanged lines hidden (view full) ---

469
470 /*
471 * KAME assumption: link id == interface id
472 */
473
474 if (in6p && in6p->in6p_outputopts &&
475 (pi = in6p->in6p_outputopts->ip6po_pktinfo) &&
476 pi->ipi6_ifindex) {
173 dst);
174 if (ia6 == 0) {
175 *errorp = EADDRNOTAVAIL;
176 return(0);
177 }
178 return(&satosin6(&ia6->ia_addr)->sin6_addr);
179 }
180

--- 287 unchanged lines hidden (view full) ---

468
469 /*
470 * KAME assumption: link id == interface id
471 */
472
473 if (in6p && in6p->in6p_outputopts &&
474 (pi = in6p->in6p_outputopts->ip6po_pktinfo) &&
475 pi->ipi6_ifindex) {
477 ifp = ifindex2ifnet[pi->ipi6_ifindex];
476 ifp = ifnet_byindex(pi->ipi6_ifindex);
478 in6->s6_addr16[1] = htons(pi->ipi6_ifindex);
479 } else if (in6p && IN6_IS_ADDR_MULTICAST(in6) &&
480 in6p->in6p_moptions &&
481 in6p->in6p_moptions->im6o_multicast_ifp) {
482 ifp = in6p->in6p_moptions->im6o_multicast_ifp;
483 in6->s6_addr16[1] = htons(ifp->if_index);
484 } else if (scopeid) {
485 /* boundary check */
486 if (scopeid < 0 || if_index < scopeid)
487 return ENXIO; /* XXX EINVAL? */
477 in6->s6_addr16[1] = htons(pi->ipi6_ifindex);
478 } else if (in6p && IN6_IS_ADDR_MULTICAST(in6) &&
479 in6p->in6p_moptions &&
480 in6p->in6p_moptions->im6o_multicast_ifp) {
481 ifp = in6p->in6p_moptions->im6o_multicast_ifp;
482 in6->s6_addr16[1] = htons(ifp->if_index);
483 } else if (scopeid) {
484 /* boundary check */
485 if (scopeid < 0 || if_index < scopeid)
486 return ENXIO; /* XXX EINVAL? */
488 ifp = ifindex2ifnet[scopeid];
487 ifp = ifnet_byindex(scopeid);
489 /*XXX assignment to 16bit from 32bit variable */
490 in6->s6_addr16[1] = htons(scopeid & 0xffff);
491 }
492
493 if (ifpp)
494 *ifpp = ifp;
495 }
496

--- 60 unchanged lines hidden ---
488 /*XXX assignment to 16bit from 32bit variable */
489 in6->s6_addr16[1] = htons(scopeid & 0xffff);
490 }
491
492 if (ifpp)
493 *ifpp = ifp;
494 }
495

--- 60 unchanged lines hidden ---