1 | /* $Id: bootp.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NAT - BOOTP/DHCP server emulation (declarations/defines).
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* bootp/dhcp defines */
|
---|
19 |
|
---|
20 | #define BOOTP_SERVER 67
|
---|
21 | #define BOOTP_CLIENT 68
|
---|
22 |
|
---|
23 | #define BOOTP_REQUEST 1
|
---|
24 | #define BOOTP_REPLY 2
|
---|
25 |
|
---|
26 | #define RFC1533_COOKIE 99, 130, 83, 99
|
---|
27 | #define RFC1533_PAD 0
|
---|
28 | #define RFC1533_NETMASK 1
|
---|
29 | #define RFC1533_TIMEOFFSET 2
|
---|
30 | #define RFC1533_GATEWAY 3
|
---|
31 | #define RFC1533_TIMESERVER 4
|
---|
32 | #define RFC1533_IEN116NS 5
|
---|
33 | #define RFC1533_DNS 6
|
---|
34 | #define RFC1533_LOGSERVER 7
|
---|
35 | #define RFC1533_COOKIESERVER 8
|
---|
36 | #define RFC1533_LPRSERVER 9
|
---|
37 | #define RFC1533_IMPRESSSERVER 10
|
---|
38 | #define RFC1533_RESOURCESERVER 11
|
---|
39 | #define RFC1533_HOSTNAME 12
|
---|
40 | #define RFC1533_BOOTFILESIZE 13
|
---|
41 | #define RFC1533_MERITDUMPFILE 14
|
---|
42 | #define RFC1533_DOMAINNAME 15
|
---|
43 | #define RFC1533_SWAPSERVER 16
|
---|
44 | #define RFC1533_ROOTPATH 17
|
---|
45 | #define RFC1533_EXTENSIONPATH 18
|
---|
46 | #define RFC1533_IPFORWARDING 19
|
---|
47 | #define RFC1533_IPSOURCEROUTING 20
|
---|
48 | #define RFC1533_IPPOLICYFILTER 21
|
---|
49 | #define RFC1533_IPMAXREASSEMBLY 22
|
---|
50 | #define RFC1533_IPTTL 23
|
---|
51 | #define RFC1533_IPMTU 24
|
---|
52 | #define RFC1533_IPMTUPLATEAU 25
|
---|
53 | #define RFC1533_INTMTU 26
|
---|
54 | #define RFC1533_INTLOCALSUBNETS 27
|
---|
55 | #define RFC1533_INTBROADCAST 28
|
---|
56 | #define RFC1533_INTICMPDISCOVER 29
|
---|
57 | #define RFC1533_INTICMPRESPOND 30
|
---|
58 | #define RFC1533_INTROUTEDISCOVER 31
|
---|
59 | #define RFC1533_INTROUTESOLICIT 32
|
---|
60 | #define RFC1533_INTSTATICROUTES 33
|
---|
61 | #define RFC1533_LLTRAILERENCAP 34
|
---|
62 | #define RFC1533_LLARPCACHETMO 35
|
---|
63 | #define RFC1533_LLETHERNETENCAP 36
|
---|
64 | #define RFC1533_TCPTTL 37
|
---|
65 | #define RFC1533_TCPKEEPALIVETMO 38
|
---|
66 | #define RFC1533_TCPKEEPALIVEGB 39
|
---|
67 | #define RFC1533_NISDOMAIN 40
|
---|
68 | #define RFC1533_NISSERVER 41
|
---|
69 | #define RFC1533_NTPSERVER 42
|
---|
70 | #define RFC1533_VENDOR 43
|
---|
71 | #define RFC1533_NBNS 44
|
---|
72 | #define RFC1533_NBDD 45
|
---|
73 | #define RFC1533_NBNT 46
|
---|
74 | #define RFC1533_NBSCOPE 47
|
---|
75 | #define RFC1533_XFS 48
|
---|
76 | #define RFC1533_XDM 49
|
---|
77 |
|
---|
78 | #define RFC2132_REQ_ADDR 50
|
---|
79 | #define RFC2132_LEASE_TIME 51
|
---|
80 | #define RFC2132_MSG_TYPE 53
|
---|
81 | #define RFC2132_SRV_ID 54
|
---|
82 | #define RFC2132_PARAM_LIST 55
|
---|
83 | #define RFC2132_MAX_SIZE 57
|
---|
84 | #define RFC2132_RENEWAL_TIME 58
|
---|
85 | #define RFC2132_REBIND_TIME 59
|
---|
86 |
|
---|
87 | #define DHCPDISCOVER 1
|
---|
88 | #define DHCPOFFER 2
|
---|
89 | #define DHCPREQUEST 3
|
---|
90 | #define DHCPDECLINE 4
|
---|
91 | #define DHCPACK 5
|
---|
92 | #define DHCPNAK 6
|
---|
93 | #define DHCPRELEASE 7
|
---|
94 | #define DHCPINFORM 8
|
---|
95 |
|
---|
96 | #define RFC1533_VENDOR_MAJOR 0
|
---|
97 | #define RFC1533_VENDOR_MINOR 0
|
---|
98 |
|
---|
99 | #define RFC1533_VENDOR_MAGIC 128
|
---|
100 | #define RFC1533_VENDOR_ADDPARM 129
|
---|
101 | #define RFC1533_VENDOR_ETHDEV 130
|
---|
102 | #define RFC1533_VENDOR_HOWTO 132
|
---|
103 | #define RFC1533_VENDOR_MNUOPTS 160
|
---|
104 | #define RFC1533_VENDOR_SELECTION 176
|
---|
105 | #define RFC1533_VENDOR_MOTD 184
|
---|
106 | #define RFC1533_VENDOR_NUMOFMOTD 8
|
---|
107 | #define RFC1533_VENDOR_IMG 192
|
---|
108 | #define RFC1533_VENDOR_NUMOFIMG 16
|
---|
109 |
|
---|
110 | #define RFC1533_END 255
|
---|
111 | #define BOOTP_VENDOR_LEN 64
|
---|
112 | #define DHCP_OPT_LEN 312
|
---|
113 |
|
---|
114 | /* RFC 2131 */
|
---|
115 | struct bootp_t
|
---|
116 | {
|
---|
117 | struct ip ip; /**< header: IP header */
|
---|
118 | struct udphdr udp; /**< header: UDP header */
|
---|
119 | uint8_t bp_op; /**< opcode (BOOTP_REQUEST, BOOTP_REPLY) */
|
---|
120 | uint8_t bp_htype; /**< hardware type */
|
---|
121 | uint8_t bp_hlen; /**< hardware address length */
|
---|
122 | uint8_t bp_hops; /**< hop count */
|
---|
123 | uint32_t bp_xid; /**< transaction ID */
|
---|
124 | uint16_t bp_secs; /**< numnber of seconds */
|
---|
125 | uint16_t bp_flags; /**< flags (DHCP_FLAGS_B) */
|
---|
126 | struct in_addr bp_ciaddr; /**< client IP address */
|
---|
127 | struct in_addr bp_yiaddr; /**< your IP address */
|
---|
128 | struct in_addr bp_siaddr; /**< server IP address */
|
---|
129 | struct in_addr bp_giaddr; /**< gateway IP address */
|
---|
130 | uint8_t bp_hwaddr[16]; /** client hardware address */
|
---|
131 | uint8_t bp_sname[64]; /** server host name */
|
---|
132 | uint8_t bp_file[128]; /** boot filename */
|
---|
133 | uint8_t bp_vend[DHCP_OPT_LEN]; /**< vendor specific info */
|
---|
134 | };
|
---|
135 |
|
---|
136 |
|
---|
137 | #define DHCP_FLAGS_B (1<<15) /**< B, broadcast */
|
---|
138 | struct bootp_ext
|
---|
139 | {
|
---|
140 | uint8_t bpe_tag;
|
---|
141 | uint8_t bpe_len;
|
---|
142 | };
|
---|
143 |
|
---|
144 | void bootp_input(PNATState, struct mbuf *m);
|
---|
145 | int bootp_cache_lookup_ip_by_ether(PNATState, const uint8_t *, uint32_t *);
|
---|
146 | int bootp_cache_lookup_ether_by_ip(PNATState, uint32_t, uint8_t *);
|
---|
147 | int bootp_dhcp_init(PNATState);
|
---|
148 | int bootp_dhcp_fini(PNATState);
|
---|