* Copyright (c) 1983, 1989 The Regents of the University of California.
* All rights reserved.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
*/
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)route.c 5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)route.c 5.26 (Berkeley) %G%";
#endif /* not lint */
-#include <paths.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
+#include <paths.h>
struct keytab {
char *kt_cp;
int locking, lockrest, debugonly;
struct sockaddr_in sin = { sizeof(sin), AF_INET };
struct rt_metrics rt_metrics;
+u_long rtm_inits;
struct in_addr inet_makeaddr();
char *malloc(), *routename(), *netname();
extern char *iso_ntoa(), *link_ntoa();
exit(1);
}
+
main(argc, argv)
int argc;
char *argv[];
caseof(K_RTT, RTV_RTT, rmx_rtt);
caseof(K_RTTVAR, RTV_RTTVAR, rmx_rttvar);
}
+ rtm_inits |= flag;
if (lockrest || locking)
rt_metrics.rmx_locks |= flag;
if (locking)
m_rtmsg.m_rtm.rtm_seq = ++seq;
m_rtmsg.m_rtm.rtm_addrs = rtm_addrs;
m_rtmsg.m_rtm.rtm_rmx = rt_metrics;
+ m_rtmsg.m_rtm.rtm_inits = rtm_inits;
#define ROUND(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
#define NEXTADDR(w, u) { if (rtm_addrs & (w)) {l = (u).sa.sa_len;\
}
fflush(stdout);
}
-
-/*
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)linkaddr.c 5.1 (Berkeley) 4/1/90";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef AF_LINK
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <net/if_dl.h>
-#endif
-/* States*/
-#define NAMING 0
-#define GOTONE 1
-#define GOTTWO 2
-#define RESET 3
-/* Inputs */
-#define DIGIT (4*0)
-#define END (4*1)
-#define DELIM (4*2)
-#define LETTER (4*3)
-
-link_addr(addr, sdl)
-register char *addr;
-register struct sockaddr_dl *sdl;
-{
- register char *cp = sdl->sdl_data;
- char *cplim = sdl->sdl_len + (char *)sdl;
- register int byte = 0, state = NAMING, new;
-
- bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1);
- sdl->sdl_family = AF_LINK;
- do {
- state &= ~LETTER;
- if ((*addr >= '0') && (*addr <= '9')) {
- new = *addr - '0';
- } else if ((*addr >= 'a') && (*addr <= 'f')) {
- new = *addr - 'a' + 10;
- } else if ((*addr >= 'A') && (*addr <= 'F')) {
- new = *addr - 'A' + 10;
- } else if (*addr == 0) {
- state |= END;
- } else if (state == NAMING &&
- (((*addr >= 'A') && (*addr <= 'Z')) ||
- ((*addr >= 'a') && (*addr <= 'z'))))
- state |= LETTER;
- else
- state |= DELIM;
- addr++;
- switch (state /* | INPUT */) {
- case NAMING | DIGIT:
- case NAMING | LETTER:
- *cp++ = addr[-1]; continue;
- case NAMING | DELIM:
- state = RESET; sdl->sdl_nlen = cp - sdl->sdl_data; continue;
- case GOTTWO | DIGIT:
- *cp++ = byte; /*FALLTHROUGH*/
- case RESET | DIGIT:
- state = GOTONE; byte = new; continue;
- case GOTONE | DIGIT:
- state = GOTTWO; byte = new + (byte << 4); continue;
- default: /* | DELIM */
- state = RESET; *cp++ = byte; byte = 0; continue;
- case GOTONE | END:
- case GOTTWO | END:
- *cp++ = byte; /* FALLTHROUGH */
- case RESET | END:
- break;
- }
- break;
- } while (cp < cplim);
- sdl->sdl_alen = cp - LLADDR(sdl);
- new = cp - (char *)sdl;
- if (new > sizeof(*sdl))
- sdl->sdl_len = new;
- return;
-}
-static char hexlist[] = "0123456789abcdef";
-
-char *
-link_ntoa(sdl)
-register struct sockaddr_dl *sdl;
-{
- static char obuf[64];
- register char *out = obuf;
- register int i;
- register u_char *in = (u_char *)LLADDR(sdl);
- u_char *inlim = in + sdl->sdl_nlen;
- int firsttime = 1;
-
- if (sdl->sdl_nlen) {
- bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen);
- out += sdl->sdl_nlen;
- *out++ = ':';
- }
- while (in < inlim) {
- if (firsttime) firsttime = 0; else *out++ = '.';
- i = *in++;
- if (i > 0xf) {
- out[1] = hexlist[i & 0xf];
- i >>= 4;
- out[0] = hexlist[i];
- out += 2;
- } else
- *out++ = hexlist[i];
- }
- *out = 0;
- return(obuf);
-}