DHCP Data structures

Example 4-1. DHCP Packet Fields


      typedef struct dhcp
      {
          u_int8_t bp_opcode;
	  u_int8_t bp_htype;
          u_int8_t bp_hlen;
          u_int8_t bp_hops;
          u_int32_t bp_xid;
          u_int16_t bp_secs;
          u_int16_t bp_flags;
          ip4_t bp_ciaddr;
          ip4_t bp_yiaddr;
          ip4_t bp_siaddr;
          ip4_t bp_giaddr;
          u_int8_t bp_chaddr[DHCP_CHADDR_LEN];
          char bp_sname[DHCP_SNAME_LEN];
          char bp_file[DHCP_FILE_LEN];
          u_int8_t bp_options[DHCP_VEND_LEN];
      } dhcp_t;

      

bp_opcode

This is the DHCP packet opcode type. This is typically either a DHCP_REQUEST, DHCP_OFFER, DHCP_REQUEST, or a DHCP_ACK.

bp_htype

This is the hardware address type. This is set to a 1 for 10mb ethernet.

bp_hlen

hardware addr length. This is set to 6 for 10mb ethernet.

bp_hops

The number of hops to the gateway. Nilo sets this to zero, it's optionally used by gateways in cross-gateway booting.

bp_xid

This is the Transaction ID. This is a random number, used to match this boot request with the responses it generates.

bp_secs

This is the number of seconds since Nilo booted.

bp_flags

These are the various flags for this packet. (RFC1532 broadcast, etc...)

bp_ciaddr

This is Nilo's IP address, since it's the client. This is filled in when Nilo in a DHCP_REQUEST knows it's own IP number.

bp_yiaddr

This is Nilo's IP address to be filled in by the server when Nilo doesn't know it's own IP address. (ie bp_ciaddr it zero)

bp_siaddr

This is the server IP address. This is filled in by the server on a DHCP_OFFER.

bp_giaddr

This is the gateway IP address, which is only used for optional cross-gateway booting.

bp_chaddr

This is Nilo's ethernet hardware address.

bp_sname

This is the optional server host name as a null terminated string. This is for compatability with older implementations.

bp_file

This is the boot file name as a fully path qualified, null terminated string. This is the file that will be loaded by the later TFTP session.

bp_options

These are the DHCP options.