[systemd-devel] [PATCH 01/28] dhcp: Add DHCP protocol structures and initial defines
Lennart Poettering
lennart at poettering.net
Wed Nov 13 15:52:32 PST 2013
On Wed, 13.11.13 23:22, Patrik Flykt (patrik.flykt at linux.intel.com) wrote:
> +struct DHCPMessage {
> + uint8_t op;
> + uint8_t htype;
> + uint8_t hlen;
> + uint8_t hops;
> + uint32_t xid;
> + uint16_t secs;
> + uint16_t flags;
> + uint32_t ciaddr;
> + uint32_t yiaddr;
> + uint32_t siaddr;
> + uint32_t giaddr;
> + uint8_t chaddr[16];
> + uint8_t sname[64];
> + uint8_t file[128];
> +} __attribute__((packed));
Use _packed_ please!
> +#define BOOTREQUEST 1
> +#define BOOTREPLY 2
> +
> +#define DHCP_DISCOVER 1
> +#define DHCP_OFFER 2
> +#define DHCP_REQUEST 3
> +#define DHCP_DECLINE 4
> +#define DHCP_ACK 5
> +#define DHCP_NAK 6
> +#define DHCP_RELEASE 7
> +
> +#define DHCP_OVERLOAD_FILE 1
> +#define DHCP_OVERLOAD_SNAME 2
> +
> +#define DHCP_OPTION_PAD 0
> +#define DHCP_OPTION_SUBNET_MASK 1
> +#define DHCP_OPTION_ROUTER 3
> +#define DHCP_OPTION_DOMAIN_NAME_SERVER 6
> +#define DHCP_OPTION_HOST_NAME 12
> +#define DHCP_OPTION_DOMAIN_NAME 15
> +#define DHCP_OPTION_NTP_SERVER 42
> +#define DHCP_OPTION_REQUESTED_IP_ADDRESS 50
> +#define DHCP_OPTION_OVERLOAD 52
> +#define DHCP_OPTION_MESSAGE_TYPE 53
> +#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55
> +#define DHCP_OPTION_END 255
For defines like these I'd really suggest using anonymous enums. It's a
good thing if the compiler knows these things, not just the
pre-processor...
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list