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