There is important information about booting non-ack images in docs/UPDATING. ack/aout-format images can't be built any more, and booting clang/ELF-format ones is a little different. Updating to the new boot monitor is recommended. Changes in this commit: . drop boot monitor -> allowing dropping ack support . facility to copy ELF boot files to /boot so that old boot monitor can still boot fairly easily, see UPDATING . no more ack-format libraries -> single-case libraries . some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases . drop several ack toolchain commands, but not all support commands (e.g. aal is gone but acksize is not yet). . a few libc files moved to netbsd libc dir . new /bin/date as minix date used code in libc/ . test compile fix . harmonize includes . /usr/lib is no longer special: without ack, /usr/lib plays no kind of special bootstrapping role any more and bootstrapping is done exclusively through packages, so releases depend even less on the state of the machine making them now. . rename nbsd_lib* to lib* . reduce mtree
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/* dhcp_gettag() Author: Kees J. Bot
|
|
* 1 Dec 2000
|
|
*/
|
|
#define nil ((void*)0)
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <net/hton.h>
|
|
#include <net/gen/in.h>
|
|
#include <net/gen/dhcp.h>
|
|
|
|
#define arraysize(a) (sizeof(a) / sizeof((a)[0]))
|
|
|
|
int dhcp_gettag(dhcp_t *dp, int searchtag, u8_t **pdata, size_t *plen)
|
|
{
|
|
/* Find a tag in the options field, or possibly in the file or sname
|
|
* fields. Return true iff found, and return the data and/or length if
|
|
* their pointers are non-null.
|
|
*/
|
|
u8_t *p;
|
|
u8_t *optfield[3];
|
|
size_t optlen[3];
|
|
int i, tag, len;
|
|
|
|
/* The DHCP magic number must be correct, or no tags. */
|
|
if (dp->magic != DHCP_MAGIC) return 0;
|
|
|
|
optfield[0]= dp->options;
|
|
optlen[0]= arraysize(dp->options);
|
|
optfield[1]= dp->file;
|
|
optlen[1]= 0; /* Unknown if used for options yet. */
|
|
optfield[2]= dp->sname;
|
|
optlen[2]= 0;
|
|
|
|
for (i= 0; i < 3; i++) {
|
|
p= optfield[i];
|
|
while (p < optfield[i] + optlen[i]) {
|
|
tag= *p++;
|
|
if (tag == 255) break;
|
|
len= tag == 0 ? 0 : *p++;
|
|
if (tag == searchtag) {
|
|
if (pdata != nil) *pdata= p;
|
|
if (plen != nil) *plen= len;
|
|
return 1;
|
|
}
|
|
if (tag == DHCP_TAG_OVERLOAD) {
|
|
/* There are also options in the file or sname field. */
|
|
if (*p & 1) optlen[1]= arraysize(dp->file);
|
|
if (*p & 2) optlen[1]= arraysize(dp->sname);
|
|
}
|
|
p += len;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|