"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 2 | /* options.h */ |
| 3 | #ifndef _OPTIONS_H |
| 4 | #define _OPTIONS_H |
| 5 | |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 6 | #define TYPE_MASK 0x0F |
| 7 | |
| 8 | enum { |
| 9 | OPTION_IP=1, |
| 10 | OPTION_IP_PAIR, |
| 11 | OPTION_STRING, |
Denis Vlasenko | 5066473 | 2007-02-27 21:15:08 +0000 | [diff] [blame^] | 12 | #if ENABLE_FEATURE_RFC3397 |
| 13 | OPTION_STR1035, /* RFC1035 compressed domain name list */ |
| 14 | #endif |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 15 | OPTION_BOOLEAN, |
| 16 | OPTION_U8, |
| 17 | OPTION_U16, |
| 18 | OPTION_S16, |
| 19 | OPTION_U32, |
| 20 | OPTION_S32 |
| 21 | }; |
| 22 | |
| 23 | #define OPTION_REQ 0x10 /* have the client request this option */ |
| 24 | #define OPTION_LIST 0x20 /* There can be a list of 1 or more of these */ |
| 25 | |
| 26 | struct dhcp_option { |
Denis Vlasenko | e175ff2 | 2006-09-26 17:41:00 +0000 | [diff] [blame] | 27 | char name[12]; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 28 | char flags; |
| 29 | uint8_t code; |
| 30 | }; |
| 31 | |
Denis Vlasenko | c90c3f3 | 2006-11-23 12:57:49 +0000 | [diff] [blame] | 32 | extern const struct dhcp_option dhcp_options[]; |
| 33 | extern const unsigned char option_lengths[]; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 34 | |
| 35 | uint8_t *get_option(struct dhcpMessage *packet, int code); |
| 36 | int end_option(uint8_t *optionptr); |
| 37 | int add_option_string(uint8_t *optionptr, uint8_t *string); |
| 38 | int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data); |
Denis Vlasenko | 5066473 | 2007-02-27 21:15:08 +0000 | [diff] [blame^] | 39 | #if ENABLE_FEATURE_RFC3397 |
| 40 | char *dname_dec(const uint8_t *cstr, int clen, const char *pre); |
| 41 | uint8_t *dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen); |
| 42 | #endif |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 43 | |
| 44 | #endif |