• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/odhcpd/src/dhcpv4.h

  1 /**
  2  *   Copyright (C) 2012 Steven Barth <steven@midlink.org>
  3  *   Copyright (C) 2016 Hans Dedecker <dedeckeh@gmail.com>
  4  *
  5  *   This program is free software; you can redistribute it and/or modify
  6  *   it under the terms of the GNU General Public License version 2
  7  *   as published by the Free Software Foundation.
  8  *
  9  *   This program is distributed in the hope that it will be useful,
 10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  *   GNU General Public License version 2 for more details.
 13  *
 14  */
 15 #pragma once
 16 
 17 #define DHCPV4_CLIENT_PORT 68
 18 #define DHCPV4_SERVER_PORT 67
 19 
 20 #define DHCPV4_FLAG_BROADCAST  0x8000
 21 
 22 #define DHCPV4_MIN_PACKET_SIZE 300
 23 
 24 enum dhcpv4_op {
 25         DHCPV4_BOOTREQUEST = 1,
 26         DHCPV4_BOOTREPLY = 2
 27 };
 28 
 29 enum dhcpv4_msg {
 30         DHCPV4_MSG_DISCOVER = 1,
 31         DHCPV4_MSG_OFFER = 2,
 32         DHCPV4_MSG_REQUEST = 3,
 33         DHCPV4_MSG_DECLINE = 4,
 34         DHCPV4_MSG_ACK = 5,
 35         DHCPV4_MSG_NAK = 6,
 36         DHCPV4_MSG_RELEASE = 7,
 37         DHCPV4_MSG_INFORM = 8,
 38         DHCPV4_MSG_FORCERENEW = 9,
 39 };
 40 
 41 enum dhcpv4_opt {
 42         DHCPV4_OPT_PAD = 0,
 43         DHCPV4_OPT_NETMASK = 1,
 44         DHCPV4_OPT_ROUTER = 3,
 45         DHCPV4_OPT_DNSSERVER = 6,
 46         DHCPV4_OPT_DOMAIN = 15,
 47         DHCPV4_OPT_MTU = 26,
 48         DHCPV4_OPT_BROADCAST = 28,
 49         DHCPV4_OPT_NTPSERVER = 42,
 50         DHCPV4_OPT_LEASETIME = 51,
 51         DHCPV4_OPT_MESSAGE = 53,
 52         DHCPV4_OPT_SERVERID = 54,
 53         DHCPV4_OPT_REQOPTS = 55,
 54         DHCPV4_OPT_RENEW = 58,
 55         DHCPV4_OPT_REBIND = 59,
 56         DHCPV4_OPT_IPADDRESS = 50,
 57         DHCPV4_OPT_HOSTNAME = 12,
 58         DHCPV4_OPT_REQUEST = 17,
 59         DHCPV4_OPT_USER_CLASS = 77,
 60         DHCPV4_OPT_AUTHENTICATION = 90,
 61         DHCPV4_OPT_SEARCH_DOMAIN = 119,
 62         DHCPV4_OPT_FORCERENEW_NONCE_CAPABLE = 145,
 63         DHCPV4_OPT_END = 255,
 64 };
 65 
 66 struct dhcpv4_message {
 67         uint8_t op;
 68         uint8_t htype;
 69         uint8_t hlen;
 70         uint8_t hops;
 71         uint32_t xid;
 72         uint16_t secs;
 73         uint16_t flags;
 74         struct in_addr ciaddr;
 75         struct in_addr yiaddr;
 76         struct in_addr siaddr;
 77         struct in_addr giaddr;
 78         uint8_t chaddr[16];
 79         char sname[64];
 80         char file[128];
 81         uint8_t options[312];
 82 };
 83 
 84 struct dhcpv4_auth_forcerenew {
 85         uint8_t protocol;
 86         uint8_t algorithm;
 87         uint8_t rdm;
 88         uint32_t replay[2];
 89         uint8_t type;
 90         uint8_t key[16];
 91 } _packed;
 92 
 93 struct dhcpv4_option {
 94         uint8_t type;
 95         uint8_t len;
 96         uint8_t data[];
 97 };
 98 
 99 
100 #define dhcpv4_for_each_option(start, end, opt)\
101         for (opt = (struct dhcpv4_option*)(start); \
102                 &opt[1] <= (struct dhcpv4_option*)(end) && \
103                         &opt->data[opt->len] <= (end); \
104                 opt = (struct dhcpv4_option*)&opt->data[opt->len])
105 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt