confnet.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #ifndef _SYS_CONFNET_H_
  2. #define _SYS_CONFNET_H_
  3. /*
  4. * Copyright (C) 2001-2006 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 THE COPYRIGHT HOLDERS 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 THE
  23. * COPYRIGHT OWNER 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. * \file sys/confnet.h
  36. * \brief Header file for network configuration.
  37. *
  38. * \verbatim
  39. *
  40. * $Log$
  41. * Revision 1.6 2008/10/05 16:47:04 haraldkipp
  42. * Removed attribute 'packed' from typedef.
  43. *
  44. * Revision 1.5 2008/08/11 07:00:25 haraldkipp
  45. * BSD types replaced by stdint types (feature request #1282721).
  46. *
  47. * Revision 1.4 2006/05/25 09:17:28 haraldkipp
  48. * Allow configuration of location used in non-volatile memory.
  49. * API documentation updated and corrected.
  50. *
  51. * Revision 1.3 2006/03/16 15:25:34 haraldkipp
  52. * Changed human readable strings from uint8_t to char to stop GCC 4 from
  53. * nagging about signedness.
  54. *
  55. * Revision 1.2 2006/01/23 17:34:29 haraldkipp
  56. * Configuration structures must be packed.
  57. *
  58. * Revision 1.1.1.1 2003/05/09 14:41:18 haraldkipp
  59. * Initial using 3.2.1
  60. *
  61. * Revision 1.4 2003/02/04 18:00:52 harald
  62. * Version 3 released
  63. *
  64. * Revision 1.3 2002/06/26 17:29:28 harald
  65. * First pre-release with 2.4 stack
  66. *
  67. * \endverbatim
  68. */
  69. #include <sys/types.h>
  70. #include <cfg/eeprom.h>
  71. #include <stdint.h>
  72. /*!
  73. * \addtogroup xgConfNet
  74. */
  75. /*@{*/
  76. /*!
  77. * \brief Non-volatile memory location.
  78. *
  79. * Offset into non-volatile memory, where Nut/Net stores the network
  80. * configuration. The default may be overridden by the Configurator.
  81. */
  82. #ifndef CONFNET_EE_OFFSET
  83. #define CONFNET_EE_OFFSET 64
  84. #endif
  85. #ifndef CONFNET_MAX_IF
  86. #define CONFNET_MAX_IF 1
  87. #endif
  88. /*!
  89. * \brief Network configuration type.
  90. */
  91. typedef struct _CONFNET CONFNET;
  92. /*!
  93. * \struct _CONFNET confnet.h sys/confnet.h
  94. * \brief Network configuration structure.
  95. *
  96. * Applications may directly access the global variable \ref confnet to
  97. * read or modify the current network configuration.
  98. */
  99. struct NUT_PACKED_TYPE _CONFNET {
  100. /*! \brief Size of this structure.
  101. *
  102. * Used by Nut/Net to verify, that the structure contents is valid
  103. * after reading it from non-volatile memory.
  104. */
  105. uint8_t cd_size;
  106. /*! \brief Magic cookie.
  107. *
  108. * Contains the device name of the network interface.
  109. */
  110. char cd_name[9];
  111. /*! \brief Ethernet MAC address.
  112. *
  113. * Unique Ethernet address of the network interface.
  114. */
  115. uint8_t cdn_mac[6];
  116. /*! \brief Last used IP address.
  117. *
  118. * Each time Nut/Net receives an IP address during boot, it
  119. * will store the address in here.
  120. *
  121. * If no fixed IP address has been configured (cdn_cip_addr
  122. * contains 0.0.0.0) and if no DHCP server is available, then
  123. * Nut/Net will use this one, if it is not 0.0.0.0.
  124. */
  125. uint32_t cdn_ip_addr;
  126. /*! \brief IP netmask.
  127. *
  128. * The netmask is used to determine which machines are
  129. * available in the local network.
  130. */
  131. uint32_t cdn_ip_mask;
  132. /*! \brief Default route.
  133. *
  134. * Nut/Net will redirect IP packets to this node, if the
  135. * target IP is not located in the local network.
  136. */
  137. uint32_t cdn_gateway;
  138. /*! \brief Configured IP address.
  139. *
  140. * If this address is set to 0.0.0.0, Nut/Net will try
  141. * to obtain one from the DHCP server.
  142. */
  143. uint32_t cdn_cip_addr;
  144. };
  145. extern CONFNET confnet;
  146. /*@}*/
  147. #endif