Deleted Added
full compact
in6_src.c (120856) in6_src.c (120913)
1/* $FreeBSD: head/sys/netinet6/in6_src.c 120856 2003-10-06 14:02:09Z ume $ */
1/* $FreeBSD: head/sys/netinet6/in6_src.c 120913 2003-10-08 18:26:08Z ume $ */
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

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

269 * so doesn't check out IFF_LOOPBACK.
270 */
271
272 if (ro->ro_rt) {
273 ia6 = in6_ifawithscope(ro->ro_rt->rt_ifa->ifa_ifp, dst);
274 if (ia6 == 0) /* xxx scope error ?*/
275 ia6 = ifatoia6(ro->ro_rt->rt_ifa);
276 }
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

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

269 * so doesn't check out IFF_LOOPBACK.
270 */
271
272 if (ro->ro_rt) {
273 ia6 = in6_ifawithscope(ro->ro_rt->rt_ifa->ifa_ifp, dst);
274 if (ia6 == 0) /* xxx scope error ?*/
275 ia6 = ifatoia6(ro->ro_rt->rt_ifa);
276 }
277#if 0
278 /*
279 * xxx The followings are necessary? (kazu)
280 * I don't think so.
281 * It's for SO_DONTROUTE option in IPv4.(jinmei)
282 */
283 if (ia6 == 0) {
277 if (ia6 == 0) {
284 struct sockaddr_in6 sin6 = {sizeof(sin6), AF_INET6, 0};
285
286 sin6->sin6_addr = *dst;
287
288 ia6 = ifatoia6(ifa_ifwithdstaddr(sin6tosa(&sin6)));
289 if (ia6 == 0)
290 ia6 = ifatoia6(ifa_ifwithnet(sin6tosa(&sin6)));
291 if (ia6 == 0)
292 return (0);
293 return (&satosin6(&ia6->ia_addr)->sin6_addr);
294 }
295#endif /* 0 */
296 if (ia6 == 0) {
297 *errorp = EHOSTUNREACH; /* no route */
298 return (0);
299 }
300 return (&satosin6(&ia6->ia_addr)->sin6_addr);
301 }
302
303 *errorp = EADDRNOTAVAIL;
304 return (0);

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

417 inp->inp_lport = 0;
418 return (EAGAIN);
419 }
420
421 return (0);
422}
423
424/*
278 *errorp = EHOSTUNREACH; /* no route */
279 return (0);
280 }
281 return (&satosin6(&ia6->ia_addr)->sin6_addr);
282 }
283
284 *errorp = EADDRNOTAVAIL;
285 return (0);

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

398 inp->inp_lport = 0;
399 return (EAGAIN);
400 }
401
402 return (0);
403}
404
405/*
425 * generate kernel-internal form (scopeid embedded into s6_addr16[1]).
406 * Generate kernel-internal form (scopeid embedded into s6_addr16[1]).
426 * If the address scope of is link-local, embed the interface index in the
427 * address. The routine determines our precedence
428 * between advanced API scope/interface specification and basic API
429 * specification.
430 *
407 * If the address scope of is link-local, embed the interface index in the
408 * address. The routine determines our precedence
409 * between advanced API scope/interface specification and basic API
410 * specification.
411 *
431 * this function should be nuked in the future, when we get rid of
432 * embedded scopeid thing.
412 * This function should be nuked in the future, when we get rid of embedded
413 * scopeid thing.
433 *
434 * XXX actually, it is over-specification to return ifp against sin6_scope_id.
435 * there can be multiple interfaces that belong to a particular scope zone
436 * (in specification, we have 1:N mapping between a scope zone and interfaces).
437 * we may want to change the function to return something other than ifp.
438 */
439int
440in6_embedscope(in6, sin6, in6p, ifpp)

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

484 in6p->in6p_moptions->im6o_multicast_ifp) {
485 ifp = in6p->in6p_moptions->im6o_multicast_ifp;
486 in6->s6_addr16[1] = htons(ifp->if_index);
487 } else if (scopeid) {
488 /* boundary check */
489 if (scopeid < 0 || if_index < scopeid)
490 return ENXIO; /* XXX EINVAL? */
491 ifp = ifnet_byindex(scopeid);
414 *
415 * XXX actually, it is over-specification to return ifp against sin6_scope_id.
416 * there can be multiple interfaces that belong to a particular scope zone
417 * (in specification, we have 1:N mapping between a scope zone and interfaces).
418 * we may want to change the function to return something other than ifp.
419 */
420int
421in6_embedscope(in6, sin6, in6p, ifpp)

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

465 in6p->in6p_moptions->im6o_multicast_ifp) {
466 ifp = in6p->in6p_moptions->im6o_multicast_ifp;
467 in6->s6_addr16[1] = htons(ifp->if_index);
468 } else if (scopeid) {
469 /* boundary check */
470 if (scopeid < 0 || if_index < scopeid)
471 return ENXIO; /* XXX EINVAL? */
472 ifp = ifnet_byindex(scopeid);
492 /*XXX assignment to 16bit from 32bit variable */
473 /* XXX assignment to 16bit from 32bit variable */
493 in6->s6_addr16[1] = htons(scopeid & 0xffff);
494 }
495
496 if (ifpp)
497 *ifpp = ifp;
498 }
499
500 return 0;

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

542 sin6->sin6_scope_id = scopeid;
543 }
544 }
545
546 return 0;
547}
548
549/*
474 in6->s6_addr16[1] = htons(scopeid & 0xffff);
475 }
476
477 if (ifpp)
478 *ifpp = ifp;
479 }
480
481 return 0;

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

523 sin6->sin6_scope_id = scopeid;
524 }
525 }
526
527 return 0;
528}
529
530/*
550 * just clear the embedded scope identifer.
531 * just clear the embedded scope identifier.
551 * XXX: currently used for bsdi4 only as a supplement function.
552 */
553void
554in6_clearscope(addr)
555 struct in6_addr *addr;
556{
557 if (IN6_IS_SCOPE_LINKLOCAL(addr))
558 addr->s6_addr16[1] = 0;
559}
532 * XXX: currently used for bsdi4 only as a supplement function.
533 */
534void
535in6_clearscope(addr)
536 struct in6_addr *addr;
537{
538 if (IN6_IS_SCOPE_LINKLOCAL(addr))
539 addr->s6_addr16[1] = 0;
540}