static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len) { struct Bootp_t *bp = (struct Bootp_t *) pkt; int retval = 0; if (dest != PORT_BOOTPC || src != PORT_BOOTPS) retval = -1; else if (len < sizeof(struct Bootp_t) - OPT_FIELD_SIZE) retval = -2; else if (bp->bp_op != OP_BOOTREQUEST && bp->bp_op != OP_BOOTREPLY && bp->bp_op != DHCP_OFFER && bp->bp_op != DHCP_ACK && bp->bp_op != DHCP_NAK) retval = -3; else if (bp->bp_htype != HWT_ETHER) retval = -4; else if (bp->bp_hlen != HWL_ETHER) retval = -5; else if (!bootp_match_id(NetReadLong((uint *)&bp->bp_id))) retval = -6; debug("Filtering pkt = %d\n", retval); return retval; }
static int check_reply_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len) { struct bootp_hdr *bp = (struct bootp_hdr *)pkt; int retval = 0; if (dest != PORT_BOOTPC || src != PORT_BOOTPS) retval = -1; else if (len < sizeof(struct bootp_hdr) - OPT_FIELD_SIZE) retval = -2; else if (bp->bp_op != OP_BOOTREPLY) retval = -3; else if (bp->bp_htype != HWT_ETHER) retval = -4; else if (bp->bp_hlen != HWL_ETHER) retval = -5; else if (!bootp_match_id(net_read_u32(&bp->bp_id))) retval = -6; else if (memcmp(bp->bp_chaddr, net_ethaddr, HWL_ETHER) != 0) retval = -7; debug("Filtering pkt = %d\n", retval); return retval; }