Lines Matching refs:gctx

255 static void	allocifctx(struct bootpc_globalcontext *gctx);
267 static int bootpc_call(struct bootpc_globalcontext *gctx,
274 struct bootpc_globalcontext *gctx, struct thread *td);
278 struct bootpc_globalcontext *gctx);
280 static int bootpc_received(struct bootpc_globalcontext *gctx,
339 allocifctx(struct bootpc_globalcontext *gctx) in allocifctx() argument
344 ifctx->xid = gctx->xid; in allocifctx()
350 gctx->xid += 0x100; in allocifctx()
351 STAILQ_INSERT_TAIL(&gctx->interfaces, ifctx, next); in allocifctx()
385 bootpc_received(struct bootpc_globalcontext *gctx, in bootpc_received() argument
397 (void) bootpc_tag(&gctx->tmptag, &gctx->reply, in bootpc_received()
398 gctx->replylen, in bootpc_received()
402 if (gctx->tmptag.badopt != 0) in bootpc_received()
405 p = bootpc_tag(&gctx->tmptag, &gctx->reply, in bootpc_received()
406 gctx->replylen, TAG_DHCP_MSGTYPE); in bootpc_received()
434 (bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_received()
437 bootpc_tag(&gctx->tmptag, &gctx->reply, in bootpc_received()
438 gctx->replylen, in bootpc_received()
442 bcopy(&gctx->reply, &ifctx->reply, gctx->replylen); in bootpc_received()
443 ifctx->replylen = gctx->replylen; in bootpc_received()
460 p = bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_received()
462 if (p != NULL && gctx->tmptag.taglen == 4) { in bootpc_received()
470 ifctx->gotrootpath = (bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_received()
473 ifctx->gotgw = (bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_received()
476 ifctx->gotnetmask = (bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_received()
483 bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) in bootpc_call() argument
568 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) { in bootpc_call()
570 bootpc_tag(&gctx->tmptag, &ifctx->reply, in bootpc_call()
576 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) { in bootpc_call()
682 aio.iov_base = (caddr_t) &gctx->reply; in bootpc_call()
683 aio.iov_len = sizeof(gctx->reply); in bootpc_call()
690 auio.uio_resid = sizeof(gctx->reply); in bootpc_call()
696 gctx->secs = time_second - gctx->starttime; in bootpc_call()
697 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) { in bootpc_call()
702 ifctx->call.secs = htons(gctx->secs); in bootpc_call()
708 len = sizeof(gctx->reply) - auio.uio_resid; in bootpc_call()
713 gctx->replylen = len; in bootpc_call()
716 if (gctx->reply.op != BOOTP_REPLY) in bootpc_call()
720 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) { in bootpc_call()
721 if (gctx->reply.xid != ifctx->call.xid) in bootpc_call()
725 if (gctx->reply.hlen != ifctx->call.hlen) in bootpc_call()
729 if (bcmp(gctx->reply.chaddr, in bootpc_call()
738 s = bootpc_tag(&gctx->tmptag, in bootpc_call()
739 &gctx->reply, in bootpc_call()
740 gctx->replylen, in bootpc_call()
761 print_in_addr(gctx->reply.siaddr); in bootpc_call()
762 if (gctx->reply.giaddr.s_addr != in bootpc_call()
765 print_in_addr(gctx->reply.giaddr); in bootpc_call()
767 if (bootpc_received(gctx, ifctx) != 0) { in bootpc_call()
780 gctx->any_root_overrides) { in bootpc_call()
791 if (gctx->secs > BOOTP_TIMEOUT && BOOTP_TIMEOUT > 0) in bootpc_call()
796 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_call()
808 gctx->gotrootpath = gotrootpath; in bootpc_call()
819 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_call()
827 if (gctx->gotrootpath != 0) { in bootpc_call()
835 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_call()
917 struct bootpc_globalcontext *gctx, struct thread *td) in bootpc_adjust_interface() argument
1329 struct bootpc_globalcontext *gctx) in bootpc_decode_reply() argument
1354 (void) bootpc_tag(&gctx->tmptag, in bootpc_decode_reply()
1357 if ((gctx->tmptag.overload & OVERLOAD_SNAME) == 0) in bootpc_decode_reply()
1360 if ((gctx->tmptag.overload & OVERLOAD_FILE) == 0) in bootpc_decode_reply()
1366 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1369 if (gctx->tag.taglen != 4) in bootpc_decode_reply()
1371 gctx->tag.taglen); in bootpc_decode_reply()
1379 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1383 if (gctx->tag.taglen % 4) in bootpc_decode_reply()
1384 panic("bootpc: Router Len is %d", gctx->tag.taglen); in bootpc_decode_reply()
1385 if (gctx->tag.taglen > 0) { in bootpc_decode_reply()
1391 gctx->gotgw = 1; in bootpc_decode_reply()
1410 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1422 if (gctx->setrootfs != NULL) { in bootpc_decode_reply()
1432 gctx->gotrootpath = 1; in bootpc_decode_reply()
1433 gctx->setrootfs = ifctx; in bootpc_decode_reply()
1435 p = bootpc_tag(&gctx->tag, &ifctx->reply, in bootpc_decode_reply()
1446 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1449 if (gctx->tag.taglen >= MAXHOSTNAMELEN) in bootpc_decode_reply()
1452 if (gctx->sethostname != NULL) { in bootpc_decode_reply()
1460 gctx->sethostname = ifctx; in bootpc_decode_reply()
1463 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1472 p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen, in bootpc_decode_reply()
1516 struct bootpc_globalcontext *gctx; /* Global BOOTP context */ in bootpc_init() local
1557 gctx = malloc(sizeof(*gctx), M_TEMP, M_WAITOK | M_ZERO); in bootpc_init()
1558 STAILQ_INIT(&gctx->interfaces); in bootpc_init()
1559 gctx->xid = ~0xFFFF; in bootpc_init()
1560 gctx->starttime = time_second; in bootpc_init()
1568 gctx->any_root_overrides = 1; in bootpc_init()
1570 gctx->any_root_overrides = testenv("vfs.root.mountfrom"); in bootpc_init()
1580 allocifctx(gctx); in bootpc_init()
1602 allocifctx(gctx); in bootpc_init()
1606 ifctx = STAILQ_FIRST(&gctx->interfaces); in bootpc_init()
1644 if (STAILQ_EMPTY(&gctx->interfaces) || in bootpc_init()
1645 STAILQ_FIRST(&gctx->interfaces)->ifp == NULL) { in bootpc_init()
1664 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1667 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1670 error = bootpc_call(gctx, td); in bootpc_init()
1677 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1679 bootpc_decode_reply(nd, ifctx, gctx); in bootpc_init()
1682 if (gctx->gotrootpath == 0 && gctx->any_root_overrides == 0) in bootpc_init()
1686 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1687 bootpc_adjust_interface(ifctx, gctx, td); in bootpc_init()
1691 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1695 STAILQ_FOREACH(ifctx, &gctx->interfaces, next) in bootpc_init()
1702 if (gctx->gotrootpath != 0) { in bootpc_init()
1717 if (gctx->any_root_overrides == 0) in bootpc_init()
1736 while((ifctx = STAILQ_FIRST(&gctx->interfaces)) != NULL) { in bootpc_init()
1737 STAILQ_REMOVE_HEAD(&gctx->interfaces, next); in bootpc_init()
1740 free(gctx, M_TEMP); in bootpc_init()