source: mainline/uspace/srv/net/dhcp/dhcp_std.h@ 053fc2b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 053fc2b was 695b6ff, checked in by Jiri Svoboda <jiri@…>, 12 years ago

Crude DHCP client prototype.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2013 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup dhcp
30 * @{
31 */
32/**
33 * @file
34 * @brief DHCP standard definitions
35 */
36
37#ifndef DHCP_STD_H
38#define DHCP_STD_H
39
40#include <stdint.h>
41
42enum {
43 dhcp_server_port = 67,
44 dhcp_client_port = 68
45};
46
47/** Fixed part of DHCP message */
48typedef struct {
49 /** Message op code */
50 uint8_t op;
51 /** Hardware address type */
52 uint8_t htype;
53 /** Hardware address length */
54 uint8_t hlen;
55 /** Hops */
56 uint8_t hops;
57 /** Transaction ID */
58 uint32_t xid;
59 /** Seconds elapsed since client began address acqusition or renewal */
60 uint16_t secs;
61 /** Flags */
62 uint16_t flags;
63 /** Client IP address */
64 uint32_t ciaddr;
65 /** Your (client) IP address */
66 uint32_t yiaddr;
67 /** IP address of next server */
68 uint32_t siaddr;
69 /** Relay agent IP address */
70 uint32_t giaddr;
71 /** Client hardware address */
72 uint8_t chaddr[16];
73 /** Server host name */
74 uint8_t sname[64];
75 /** Boot file name */
76 uint8_t file[128];
77 /** Magic cookie signalling the start of DHCP options */
78 uint32_t opt_magic;
79} dhcp_hdr_t;
80
81/** Values for dhcp_hdr_t.op */
82enum dhcp_op {
83 op_bootrequest = 1,
84 op_bootreply = 2
85};
86
87/** Values for dhcp_hdr_t.flags */
88enum dhcp_flags {
89 flag_broadcast = 0x80
90};
91
92/** Magic cookie signalling the start of DHCP options field */
93enum {
94 dhcp_opt_magic = (99 << 24) | (130 << 16) | (83 << 8) | 99
95};
96
97enum dhcp_option_code {
98 /** Padding */
99 opt_pad = 0,
100 /** Subnet mask */
101 opt_subnet_mask = 1,
102 /** Router IP address */
103 opt_router = 3,
104 /** Domain name server */
105 opt_dns_server = 6,
106 /** Requested IP address */
107 opt_req_ip_addr = 50,
108 /** DHCP message type */
109 opt_msg_type = 53,
110 /** Server identifier */
111 opt_server_id = 54,
112 /** End */
113 opt_end = 255
114};
115
116/** DHCP message type */
117enum dhcp_msg_type {
118 msg_dhcpdiscover = 1,
119 msg_dhcpoffer = 2,
120 msg_dhcprequest = 3,
121 msg_dhcpdecline = 4,
122 msg_dhcpack = 5,
123 msg_dhcpnak = 6,
124 msg_dhcprelease = 7
125};
126
127#endif
128
129/** @}
130 */
Note: See TracBrowser for help on using the repository browser.