ip_ire.c (7c478bd9) | ip_ire.c (7663b816) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 6 unchanged lines hidden (view full) --- 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26/* Copyright (c) 1990 Mentat Inc. */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 30 31/* --- 6556 unchanged lines hidden (view full) --- 6588 * packet's ultimate destination address, not a router address. 6589 * 6590 * This function is used when the caller wants to know the outbound interface 6591 * and MAC header for a packet given only the address. 6592 */ 6593mblk_t * 6594ip_nexthop_route(const struct sockaddr *target, char *ifname) 6595{ | 24 * Use is subject to license terms. 25 */ 26/* Copyright (c) 1990 Mentat Inc. */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 30 31/* --- 6556 unchanged lines hidden (view full) --- 6588 * packet's ultimate destination address, not a router address. 6589 * 6590 * This function is used when the caller wants to know the outbound interface 6591 * and MAC header for a packet given only the address. 6592 */ 6593mblk_t * 6594ip_nexthop_route(const struct sockaddr *target, char *ifname) 6595{ |
6596 struct nce_s *nce; |
|
6596 ire_t *dir, *gw; 6597 ill_t *ill; 6598 mblk_t *mp; 6599 6600 /* parameter sanity */ 6601 if (ifname == NULL || target == NULL) 6602 return (NULL); 6603 --- 9 unchanged lines hidden (view full) --- 6613 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT|MATCH_IRE_RECURSIVE); 6614 break; 6615 case AF_INET6: 6616 dir = ire_route_lookup_v6( 6617 &((struct sockaddr_in6 *)target)->sin6_addr, 6618 NULL, 6619 0, 0, NULL, &gw, ALL_ZONES, 6620 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT|MATCH_IRE_RECURSIVE); | 6597 ire_t *dir, *gw; 6598 ill_t *ill; 6599 mblk_t *mp; 6600 6601 /* parameter sanity */ 6602 if (ifname == NULL || target == NULL) 6603 return (NULL); 6604 --- 9 unchanged lines hidden (view full) --- 6614 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT|MATCH_IRE_RECURSIVE); 6615 break; 6616 case AF_INET6: 6617 dir = ire_route_lookup_v6( 6618 &((struct sockaddr_in6 *)target)->sin6_addr, 6619 NULL, 6620 0, 0, NULL, &gw, ALL_ZONES, 6621 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT|MATCH_IRE_RECURSIVE); |
6622 if ((dir != NULL) && (dir->ire_nce == NULL)) { 6623 ire_refrele(dir); 6624 dir = NULL; 6625 } |
|
6621 break; 6622 default: 6623 dir = NULL; 6624 break; 6625 } 6626 6627 6628 if (dir == NULL) 6629 return (NULL); 6630 6631 /* Map the IRE to an ILL so we can fill in ifname. */ 6632 ill = ire_to_ill(dir); 6633 if (ill == NULL) { 6634 ire_refrele(dir); 6635 return (NULL); 6636 } 6637 (void) strncpy(ifname, ill->ill_name, LIFNAMSIZ); 6638 6639 /* Return a copy of the header to the caller. */ | 6626 break; 6627 default: 6628 dir = NULL; 6629 break; 6630 } 6631 6632 6633 if (dir == NULL) 6634 return (NULL); 6635 6636 /* Map the IRE to an ILL so we can fill in ifname. */ 6637 ill = ire_to_ill(dir); 6638 if (ill == NULL) { 6639 ire_refrele(dir); 6640 return (NULL); 6641 } 6642 (void) strncpy(ifname, ill->ill_name, LIFNAMSIZ); 6643 6644 /* Return a copy of the header to the caller. */ |
6640 if (dir->ire_fp_mp != NULL) { 6641 if ((mp = dupb(dir->ire_fp_mp)) == NULL) 6642 mp = copyb(dir->ire_fp_mp); 6643 } else if (dir->ire_dlureq_mp != NULL) { 6644 if ((mp = dupb(dir->ire_dlureq_mp)) == NULL) 6645 mp = copyb(dir->ire_dlureq_mp); 6646 } else { 6647 mp = NULL; | 6645 switch (target->sa_family) { 6646 case AF_INET : 6647 if (dir->ire_fp_mp != NULL) { 6648 if ((mp = dupb(dir->ire_fp_mp)) == NULL) 6649 mp = copyb(dir->ire_fp_mp); 6650 } else if (dir->ire_dlureq_mp != NULL) { 6651 if ((mp = dupb(dir->ire_dlureq_mp)) == NULL) 6652 mp = copyb(dir->ire_dlureq_mp); 6653 } else { 6654 mp = NULL; 6655 } 6656 break; 6657 case AF_INET6 : 6658 nce = dir->ire_nce; 6659 if (nce->nce_fp_mp != NULL) { 6660 if ((mp = dupb(nce->nce_fp_mp)) == NULL) 6661 mp = copyb(nce->nce_fp_mp); 6662 } else if (nce->nce_res_mp != NULL) { 6663 if ((mp = dupb(nce->nce_res_mp)) == NULL) 6664 mp = copyb(nce->nce_res_mp); 6665 } else { 6666 mp = NULL; 6667 } 6668 break; |
6648 } 6649 6650 ire_refrele(dir); 6651 return (mp); 6652} 6653 6654 6655/* --- 5 unchanged lines hidden (view full) --- 6661 * 6662 * This function is used when the caller knows the outbound interface (usually 6663 * because it was specified by policy) and only needs the MAC header for a 6664 * packet. 6665 */ 6666mblk_t * 6667ip_nexthop(const struct sockaddr *target, const char *ifname) 6668{ | 6669 } 6670 6671 ire_refrele(dir); 6672 return (mp); 6673} 6674 6675 6676/* --- 5 unchanged lines hidden (view full) --- 6682 * 6683 * This function is used when the caller knows the outbound interface (usually 6684 * because it was specified by policy) and only needs the MAC header for a 6685 * packet. 6686 */ 6687mblk_t * 6688ip_nexthop(const struct sockaddr *target, const char *ifname) 6689{ |
6690 struct nce_s *nce; |
|
6669 ill_walk_context_t ctx; 6670 t_uscalar_t sap; 6671 ire_t *dir, *gw; 6672 ill_t *ill; 6673 mblk_t *mp; 6674 6675 /* parameter sanity */ 6676 if (ifname == NULL || target == NULL) --- 48 unchanged lines hidden (view full) --- 6725 MATCH_IRE_RECURSIVE|MATCH_IRE_IPIF); 6726 break; 6727 case AF_INET6: 6728 dir = ire_route_lookup_v6( 6729 &((struct sockaddr_in6 *)target)->sin6_addr, NULL, 6730 0, 0, ill->ill_ipif, &gw, ALL_ZONES, 6731 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT| 6732 MATCH_IRE_RECURSIVE|MATCH_IRE_IPIF); | 6691 ill_walk_context_t ctx; 6692 t_uscalar_t sap; 6693 ire_t *dir, *gw; 6694 ill_t *ill; 6695 mblk_t *mp; 6696 6697 /* parameter sanity */ 6698 if (ifname == NULL || target == NULL) --- 48 unchanged lines hidden (view full) --- 6747 MATCH_IRE_RECURSIVE|MATCH_IRE_IPIF); 6748 break; 6749 case AF_INET6: 6750 dir = ire_route_lookup_v6( 6751 &((struct sockaddr_in6 *)target)->sin6_addr, NULL, 6752 0, 0, ill->ill_ipif, &gw, ALL_ZONES, 6753 MATCH_IRE_DSTONLY|MATCH_IRE_DEFAULT| 6754 MATCH_IRE_RECURSIVE|MATCH_IRE_IPIF); |
6755 if ((dir != NULL) && (dir->ire_nce == NULL)) { 6756 ire_refrele(dir); 6757 dir = NULL; 6758 } |
|
6733 break; 6734 default: 6735 dir = NULL; 6736 break; 6737 } 6738 6739 ill_refrele(ill); 6740 6741 if (dir == NULL) 6742 return (NULL); 6743 6744 /* Return a copy of the header to the caller. */ | 6759 break; 6760 default: 6761 dir = NULL; 6762 break; 6763 } 6764 6765 ill_refrele(ill); 6766 6767 if (dir == NULL) 6768 return (NULL); 6769 6770 /* Return a copy of the header to the caller. */ |
6745 if (dir->ire_fp_mp != NULL) { 6746 if ((mp = dupb(dir->ire_fp_mp)) == NULL) 6747 mp = copyb(dir->ire_fp_mp); 6748 } else if (dir->ire_dlureq_mp != NULL) { 6749 if ((mp = dupb(dir->ire_dlureq_mp)) == NULL) 6750 mp = copyb(dir->ire_dlureq_mp); 6751 } else { 6752 mp = NULL; | 6771 switch (target->sa_family) { 6772 case AF_INET : 6773 if (dir->ire_fp_mp != NULL) { 6774 if ((mp = dupb(dir->ire_fp_mp)) == NULL) 6775 mp = copyb(dir->ire_fp_mp); 6776 } else if (dir->ire_dlureq_mp != NULL) { 6777 if ((mp = dupb(dir->ire_dlureq_mp)) == NULL) 6778 mp = copyb(dir->ire_dlureq_mp); 6779 } else { 6780 mp = NULL; 6781 } 6782 break; 6783 case AF_INET6 : 6784 nce = dir->ire_nce; 6785 if (nce->nce_fp_mp != NULL) { 6786 if ((mp = dupb(nce->nce_fp_mp)) == NULL) 6787 mp = copyb(nce->nce_fp_mp); 6788 } else if (nce->nce_res_mp != NULL) { 6789 if ((mp = dupb(nce->nce_res_mp)) == NULL) 6790 mp = copyb(nce->nce_res_mp); 6791 } else { 6792 mp = NULL; 6793 } 6794 break; |
6753 } 6754 | 6795 } 6796 |
6755 | |
6756 ire_refrele(dir); 6757 return (mp); 6758} 6759 6760/* 6761 * IRE iterator for inbound and loopback broadcast processing. 6762 * Given an IRE_BROADCAST ire, walk the ires with the same destination 6763 * address, but skip over the passed-in ire. Returns the next ire without --- 216 unchanged lines hidden --- | 6797 ire_refrele(dir); 6798 return (mp); 6799} 6800 6801/* 6802 * IRE iterator for inbound and loopback broadcast processing. 6803 * Given an IRE_BROADCAST ire, walk the ires with the same destination 6804 * address, but skip over the passed-in ire. Returns the next ire without --- 216 unchanged lines hidden --- |