routing_events.c revision 6ba597c56d749c61b4f783157f63196d7b2445f0
5aefb6555731130ca4fd295960123d71f2d21fe8rie * CDDL HEADER START
5aefb6555731130ca4fd295960123d71f2d21fe8rie * The contents of this file are subject to the terms of the
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Common Development and Distribution License (the "License").
5aefb6555731130ca4fd295960123d71f2d21fe8rie * You may not use this file except in compliance with the License.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5aefb6555731130ca4fd295960123d71f2d21fe8rie * See the License for the specific language governing permissions
5aefb6555731130ca4fd295960123d71f2d21fe8rie * and limitations under the License.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * When distributing Covered Code, include this CDDL HEADER in each
5aefb6555731130ca4fd295960123d71f2d21fe8rie * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * If applicable, add the following below this CDDL HEADER, with the
5aefb6555731130ca4fd295960123d71f2d21fe8rie * fields enclosed by brackets "[]" replaced with your own identifying
5aefb6555731130ca4fd295960123d71f2d21fe8rie * information: Portions Copyright [yyyy] [name of copyright owner]
5aefb6555731130ca4fd295960123d71f2d21fe8rie * CDDL HEADER END
ba2be53024c0b999e74ba9adcd7d80fec5df8c57ab * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5aefb6555731130ca4fd295960123d71f2d21fe8rie * Use is subject to license terms.
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * routing_events.c - this file contains routines to retrieve routing socket
981a172d53aeb81520fcfecf6ab2615277c7bd18ab * events and package them for high level processing.
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic void printaddrs(int, void *);
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic char *printaddr(void **);
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic void *getaddr(int, int, void *);
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic void setaddr(int, int *, void *, struct sockaddr *);
981a172d53aeb81520fcfecf6ab2615277c7bd18ab /* Routing information. */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab /* Interface information. */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab /* Interface address information. */
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic int seq = 0;
981a172d53aeb81520fcfecf6ab2615277c7bd18abstatic const char *
981a172d53aeb81520fcfecf6ab2615277c7bd18ab static char typestr[12]; /* strlen("type ") + enough for an int */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab switch (type) {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab return ("NEWADDR");
981a172d53aeb81520fcfecf6ab2615277c7bd18ab return ("DELADDR");
5aefb6555731130ca4fd295960123d71f2d21fe8rie return ("CHGADDR");
5aefb6555731130ca4fd295960123d71f2d21fe8rie return ("FREEADDR");
5aefb6555731130ca4fd295960123d71f2d21fe8rie return ("IFINFO");
5aefb6555731130ca4fd295960123d71f2d21fe8rie (void) snprintf(typestr, sizeof (typestr), "type %d", type);
5aefb6555731130ca4fd295960123d71f2d21fe8rie/* ARGSUSED0 */
5aefb6555731130ca4fd295960123d71f2d21fe8riestatic void *
981a172d53aeb81520fcfecf6ab2615277c7bd18ab for (;;) {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab } else if (n == -1) {
981a172d53aeb81520fcfecf6ab2615277c7bd18ab /* Low likelihood. What's recovery path? */
981a172d53aeb81520fcfecf6ab2615277c7bd18ab "routing socket but message claims to be "
5aefb6555731130ca4fd295960123d71f2d21fe8rie /* Ignore routing socket messages for 0.0.0.0 */
5aefb6555731130ca4fd295960123d71f2d21fe8rie /*LINTED*/
5aefb6555731130ca4fd295960123d71f2d21fe8rie "tossing message for 0.0.0.0");
5aefb6555731130ca4fd295960123d71f2d21fe8rie * We don't use the lladdr in this structure so we can
5aefb6555731130ca4fd295960123d71f2d21fe8rie * run over it.
5aefb6555731130ca4fd295960123d71f2d21fe8rie "routing_events_v4: unhandled type %d",
5aefb6555731130ca4fd295960123d71f2d21fe8rie /* Create and enqueue IF_STATE event */
39773e466ff90ce703d7f52f3267d7e96c09c6f5ab * We don't use the lladdr in this structure so we can
c6c9aed4d309e3d11be652b85e3bf8bb72f20c87ab * run over it.
5aefb6555731130ca4fd295960123d71f2d21fe8rie "routing_events_v4: unhandled type %d",
return (NULL);
n, v6_sock);
case RTM_NEWADDR:
case RTM_DELADDR:
case RTM_CHGADDR:
case RTM_FREEADDR:
case RTM_IFINFO:
return (NULL);
int af;
icfg_close(h);
switch (family) {
case AF_UNSPEC:
sizeof (buffer));
case AF_INET:
sizeof (buffer));
case AF_INET6:
sizeof (buffer));
case AF_LINK:
return (buffer);
if (mask == 0)
switch (family) {
case AF_UNSPEC:
case AF_INET:
case AF_INET6:
case AF_LINK:
void *p = addresses;
return (NULL);
if (i & mask)
nextaddr(&p);
case AF_INET:
case AF_INET6:
case AF_LINK: