Lines Matching refs:bp

208 static struct mbuf *dhcp_create_msg(PNATState pData, struct bootp_t *bp, struct mbuf *m, uint8_t type)
215 memcpy(eh->h_source, bp->bp_hwaddr, ETH_ALEN); /* XXX: if_encap just swap source with dest */
222 rbp->bp_xid = bp->bp_xid; /* see table 3 of rfc2131*/
223 rbp->bp_flags = bp->bp_flags; /* figure 2 of rfc2131 */
224 rbp->bp_giaddr.s_addr = bp->bp_giaddr.s_addr;
231 memcpy(rbp->bp_hwaddr, bp->bp_hwaddr, 6);
352 static int dhcp_send_nack(PNATState pData, struct bootp_t *bp, BOOTPClient *bc, struct mbuf *m)
356 dhcp_create_msg(pData, bp, m, DHCPNAK);
360 static int dhcp_send_ack(PNATState pData, struct bootp_t *bp, BOOTPClient *bc, struct mbuf *m, int fDhcpRequest)
364 dhcp_create_msg(pData, bp, m, DHCPACK);
369 static int dhcp_send_offer(PNATState pData, struct bootp_t *bp, BOOTPClient *bc, struct mbuf *m)
373 dhcp_create_msg(pData, bp, m, DHCPOFFER);
400 static int dhcp_decode_request(PNATState pData, struct bootp_t *bp, struct mbuf *m)
411 req_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR);
412 server_ip = dhcp_find_option(&bp->bp_vend[0], RFC2132_SRV_ID);
414 bc = find_addr(pData, &daddr, bp->bp_hwaddr);
426 || bp->bp_ciaddr.s_addr != INADDR_ANY)
432 Assert((bp->bp_ciaddr.s_addr == INADDR_ANY));
435 Assert((bp->bp_xid == bc->xid));
448 if (bp->bp_flags & RT_H2N_U16_C(DHCP_FLAGS_B))
470 Assert((server_ip == NULL && req_ip == NULL && bp->bp_ciaddr.s_addr != INADDR_ANY));
473 || bp->bp_ciaddr.s_addr == INADDR_ANY)
480 Assert((bc->addr.s_addr == bp->bp_ciaddr.s_addr));
485 if ((bp->bp_ciaddr.s_addr & RT_H2N_U32(pData->netmask)) != pData->special_addr.s_addr)
487 LogRel(("NAT: Client %RTnaipv4 requested IP -- sending NAK\n", bp->bp_ciaddr));
488 offReply = dhcp_send_nack(pData, bp, bc, m);
499 Assert((bp->bp_hlen == ETH_ALEN));
500 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen);
501 bc->addr.s_addr = bp->bp_ciaddr.s_addr;
522 || bp->bp_ciaddr.s_addr != INADDR_ANY)
531 offReply = dhcp_send_nack(pData, bp, bc, m);
545 Assert((bp->bp_hlen == ETH_ALEN));
546 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen);
563 offReply = dhcp_send_ack(pData, bp, bc, m, /* fDhcpRequest=*/ 1);
567 static int dhcp_decode_discover(PNATState pData, struct bootp_t *bp, int fDhcpDiscover, struct mbuf *m)
575 bc = find_addr(pData, &daddr, bp->bp_hwaddr);
585 memcpy(bc->macaddr, bp->bp_hwaddr, 6);
588 bc->xid = bp->bp_xid;
590 offReply = dhcp_send_offer(pData, bp, bc, m);
595 bc = find_addr(pData, &daddr, bp->bp_hwaddr);
603 offReply = dhcp_send_ack(pData, bp, bc, m, /* fDhcpRequest=*/ 0);
610 static int dhcp_decode_release(PNATState pData, struct bootp_t *bp)
612 int rc = release_addr(pData, &bp->bp_ciaddr);
615 &bp->bp_ciaddr));
683 static void dhcp_decode(PNATState pData, struct bootp_t *bp, const uint8_t *buf, int size)
700 pu8RawDhcpObject = dhcp_find_option(bp->bp_vend, RFC2132_MSG_TYPE);
725 parameter_list = dhcp_find_option(&bp->bp_vend[0], RFC2132_PARAM_LIST);
752 rc = dhcp_decode_discover(pData, bp, fDhcpDiscover, m);
758 rc = dhcp_decode_request(pData, bp, m);
764 dhcp_decode_release(pData, bp);
772 pu8RawDhcpObject = dhcp_find_option(&bp->bp_vend[0], RFC2132_REQ_ADDR);
806 bootp_reply(pData, m, rc, bp->bp_flags);
846 struct bootp_t *bp = mtod(m, struct bootp_t *);
848 if (bp->bp_op == BOOTP_REQUEST)
849 dhcp_decode(pData, bp, bp->bp_vend, DHCP_OPT_LEN);