confnet.h 4.6 KB

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