2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 14:25:41 +00:00

Merge changes between 3.0rc7 and 3.0rc8pl2.

This commit is contained in:
Ted Lemon
2001-06-27 00:31:20 +00:00
parent 07b958004f
commit d758ad8cac
99 changed files with 5909 additions and 2698 deletions

View File

@@ -4,7 +4,7 @@
way... */
/*
* Copyright (c) 1995-1999 Internet Software Consortium.
* Copyright (c) 1995-2001 Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,7 @@
#ifndef lint
static char copyright[] =
"$Id: inet.c,v 1.8 2000/03/17 03:59:01 mellon Exp $ Copyright (c) 1995-1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: inet.c,v 1.9 2001/06/27 00:29:51 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -183,3 +183,60 @@ char *piaddr (addr)
}
return pbuf;
}
char *piaddr1 (addr)
struct iaddr addr;
{
static char pbuf [4 * 16];
char *s = pbuf;
int i;
if (addr.len == 0) {
strcpy (s, "<null address>");
}
for (i = 0; i < addr.len; i++) {
sprintf (s, "%s%d", i ? "." : "", addr.iabuf [i]);
s += strlen (s);
}
return pbuf;
}
char *piaddrmask (struct iaddr addr, struct iaddr mask,
const char *file, int line)
{
char *s, *t;
int i, mw;
unsigned len;
for (i = 0; i < 32; i++) {
if (!mask.iabuf [3 - i / 8])
i += 7;
else if (mask.iabuf [3 - i / 8] & (1 << (i % 8)))
break;
}
mw = 32 - i;
len = mw > 9 ? 2 : 1;
len += 4; /* three dots and a slash. */
for (i = 0; i < (mw / 8) + 1; i++) {
if (addr.iabuf [i] > 99)
len += 3;
else if (addr.iabuf [i] > 9)
len += 2;
else
len++;
}
s = dmalloc (len + 1, file, line);
if (!s)
return s;
t = s;
sprintf (t, "%d", addr.iabuf [0]);
t += strlen (t);
for (i = 1; i < (mw / 8) + 1; i++) {
sprintf (t, ".%d", addr.iabuf [i]);
t += strlen (t);
}
*t++ = '/';
sprintf (t, "%d", mw);
return s;
}