dhcp.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef _DHCP_H
  2. #define _DHCP_H
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Portions Copyright (c) 1983, 1993 by
  36. * The Regents of the University of California. All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. * -
  62. * Portions Copyright (c) 1993 by Digital Equipment Corporation.
  63. *
  64. * Permission to use, copy, modify, and distribute this software for any
  65. * purpose with or without fee is hereby granted, provided that the above
  66. * copyright notice and this permission notice appear in all copies, and that
  67. * the name of Digital Equipment Corporation not be used in advertising or
  68. * publicity pertaining to distribution of the document or software without
  69. * specific, written prior permission.
  70. *
  71. * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  72. * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  73. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  74. * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  75. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  76. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  77. * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  78. * SOFTWARE.
  79. */
  80. /*
  81. * $Log$
  82. * Revision 1.1 2003/11/03 16:19:38 haraldkipp
  83. * First release
  84. *
  85. */
  86. #include "types.h"
  87. /*!
  88. * \addtogroup xgDhcp
  89. */
  90. /*@{*/
  91. #define DHCP_SERVERPORT 0x4300
  92. #define DHCP_CLIENTPORT 0x4400
  93. #define DHCPOPT_PAD 0
  94. #define DHCPOPT_NETMASK 1
  95. #define DHCPOPT_GATEWAY 3
  96. #define DHCPOPT_DNS 6
  97. #define DHCPOPT_HOSTNAME 12
  98. #define DHCPOPT_DOMAIN 15
  99. #define DHCPOPT_BROADCAST 28
  100. #define DHCPOPT_REQUESTIP 50
  101. #define DHCPOPT_LEASETIME 51
  102. #define DHCPOPT_MSGTYPE 53
  103. #define DHCPOPT_SID 54
  104. #define DHCPOPT_RENEWALTIME 58
  105. #define DHCPOPT_REBINDTIME 59
  106. #define DHCPOPT_END 255
  107. #define DHCP_DISCOVER 1
  108. #define DHCP_OFFER 2
  109. #define DHCP_REQUEST 3
  110. #define DHCP_DECLINE 4
  111. #define DHCP_ACK 5
  112. #define DHCP_NAK 6
  113. #define DHCP_RELEASE 7
  114. #define DHCP_INFORM 8
  115. /*
  116. * DHCP message structure according to RFC 2131.
  117. */
  118. typedef struct bootp {
  119. u_char bp_op; /*!< \brief Packet opcode type: 1=request, 2=reply */
  120. u_char bp_htype; /*!< \brief Hardware address type: 1=Ethernet */
  121. u_char bp_hlen; /*!< \brief Hardware address length: 6 for Ethernet */
  122. u_char bp_hops; /*!< \brief Gateway hops */
  123. u_long bp_xid; /*!< \brief Transaction ID */
  124. u_short bp_secs; /*!< \brief Seconds since boot began */
  125. u_short bp_flags; /*!< \brief RFC1532 broadcast, etc. */
  126. u_long bp_ciaddr; /*!< \brief Client IP address */
  127. u_long bp_yiaddr; /*!< \brief 'Your' IP address */
  128. u_long bp_siaddr; /*!< \brief Server IP address */
  129. u_long bp_giaddr; /*!< \brief Gateway IP address */
  130. u_char bp_chaddr[16]; /*!< \brief Client hardware address */
  131. char bp_sname[64]; /*!< \brief Server host name */
  132. char bp_file[128]; /*!< \brief Boot file name */
  133. u_long bp_cookie; /*!< \brief Cookie */
  134. u_char bp_options[312]; /*!< \brief Vendor-specific area */
  135. } BOOTPHDR;
  136. /*@}*/
  137. extern int DhcpQuery(void);
  138. #endif