udhcp: optional support for non-standard DHCP ports (+300 bytes when selected)
[oweals/busybox.git] / networking / udhcp / dhcpc.h
1 /* vi: set sw=4 ts=4: */
2 /* dhcpc.h */
3
4 #ifndef _DHCPC_H
5 #define _DHCPC_H
6
7 #define INIT_SELECTING  0
8 #define REQUESTING      1
9 #define BOUND           2
10 #define RENEWING        3
11 #define REBINDING       4
12 #define INIT_REBOOT     5
13 #define RENEW_REQUESTED 6
14 #define RELEASED        7
15
16 struct client_config_t {
17         /* TODO: combine flag fields into single "unsigned opt" */
18         /* (can be set directly to the result of getopt32) */
19         char foreground;                /* Do not fork */
20         char quit_after_lease;          /* Quit after obtaining lease */
21         char release_on_quit;           /* Perform release on quit */
22         char abort_if_no_lease;         /* Abort if no lease */
23         char background_if_no_lease;    /* Fork to background if no lease */
24         const char *interface;          /* The name of the interface to use */
25         char *pidfile;                  /* Optionally store the process ID */
26         const char *script;             /* User script to run at dhcp events */
27         uint8_t *clientid;              /* Optional client id to use */
28         uint8_t *vendorclass;           /* Optional vendor class-id to use */
29         uint8_t *hostname;              /* Optional hostname to use */
30         uint8_t *fqdn;                  /* Optional fully qualified domain name to use */
31         int ifindex;                    /* Index number of the interface to use */
32         uint16_t port;
33         uint8_t arp[6];                 /* Our arp address */
34         uint8_t opt_mask[256 / 8];      /* Bitmask of options to send (-O option) */
35 };
36
37 /* server_config sits in 1st half of bb_common_bufsiz1 */
38 #define client_config (*(struct client_config_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE/2]))
39
40 #if ENABLE_FEATURE_UDHCP_PORT
41 #define CLIENT_PORT (client_config.port)
42 #else
43 #define CLIENT_PORT 68
44 #endif
45
46
47 /*** clientpacket.h ***/
48
49 uint32_t random_xid(void);
50 int send_discover(uint32_t xid, uint32_t requested);
51 int send_selecting(uint32_t xid, uint32_t server, uint32_t requested);
52 #if ENABLE_FEATURE_UDHCPC_ARPING
53 int send_decline(uint32_t xid, uint32_t server, uint32_t requested);
54 #endif
55 int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
56 int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr);
57 int send_release(uint32_t server, uint32_t ciaddr);
58 int get_raw_packet(struct dhcpMessage *payload, int fd);
59
60
61 #endif