null_ether.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2009 by egnite GmbH
  3. *
  4. * 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. * $Id$
  36. */
  37. #include <cfg/os.h>
  38. #include <net/if_var.h>
  39. #include <net/ether.h>
  40. #include <netinet/if_ether.h>
  41. #include <dev/null_ether.h>
  42. /*!
  43. * \addtogroup xgNullEther
  44. */
  45. /*@{*/
  46. /*!
  47. * \brief Send Ethernet packet.
  48. *
  49. * This null devices silently discards all outgoing packets.
  50. *
  51. * \param dev Identifies the device to use.
  52. * \param nb Network buffer structure containing the packet to be sent.
  53. * The structure must have been allocated by a previous
  54. * call NutNetBufAlloc().
  55. *
  56. * \return Always 0.
  57. */
  58. int NullEtherOutput(NUTDEVICE * dev, NETBUF * nb)
  59. {
  60. return 0;
  61. }
  62. /*!
  63. * \brief Initialize Ethernet hardware.
  64. *
  65. * \param dev Identifies the device to initialize.
  66. *
  67. * \return Always 0.
  68. */
  69. int NullEtherInit(NUTDEVICE * dev)
  70. {
  71. return 0;
  72. }
  73. /*!
  74. * \brief Network interface information structure.
  75. *
  76. * Used to call.
  77. */
  78. static IFNET ifn_eth0 = {
  79. IFT_ETHER, /*!< \brief Interface type, if_type. */
  80. 0, /*!< \brief Interface flags, if_flags. */
  81. {0, 0, 0, 0, 0, 0}, /*!< \brief Hardware net address, if_mac. */
  82. 0, /*!< \brief IP address, if_local_ip. */
  83. 0, /*!< \brief Remote IP address for point to point, if_remote_ip. */
  84. 0, /*!< \brief IP network mask, if_mask. */
  85. ETHERMTU, /*!< \brief Maximum size of a transmission unit, if_mtu. */
  86. 0, /*!< \brief Packet identifier, if_pkt_id. */
  87. 0, /*!< \brief Linked list of arp entries, arpTable. */
  88. 0, /*!< \brief Linked list of multicast address entries, if_mcast. */
  89. NutEtherInput, /*!< \brief Routine to pass received data to, if_recv(). */
  90. NullEtherOutput, /*!< \brief Driver output routine, if_send(). */
  91. NutEtherOutput, /*!< \brief Media output routine, if_output(). */
  92. NULL /*!< \brief Interface specific control function, if_ioctl(). */
  93. #ifdef NUT_PERFMON
  94. , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  95. #endif
  96. };
  97. /*!
  98. * \brief Device information structure.
  99. *
  100. * A pointer to this structure must be passed to NutRegisterDevice()
  101. * to bind this Ethernet device driver to the Nut/OS kernel.
  102. * An application may then call NutNetIfConfig() with the name \em eth0
  103. * of this driver to initialize the network interface.
  104. *
  105. */
  106. NUTDEVICE devNullEther = {
  107. 0, /*!< \brief Pointer to next device. */
  108. {'e', 't', 'h', '0', 0, 0, 0, 0, 0}, /*!< \brief Unique device name. */
  109. IFTYP_NET, /*!< \brief Type of device. */
  110. 0, /*!< \brief Base address. */
  111. 0, /*!< \brief First interrupt number. */
  112. &ifn_eth0, /*!< \brief Interface control block. */
  113. NULL, /*!< \brief Driver control block. */
  114. NullEtherInit, /*!< \brief Driver initialization routine. */
  115. 0, /*!< \brief Driver specific control function. */
  116. 0, /*!< \brief Read from device. */
  117. 0, /*!< \brief Write to device. */
  118. #ifdef __HARVARD_ARCH__
  119. 0, /*!< \brief Write from program space data to device. */
  120. #endif
  121. 0, /*!< \brief Open a device or file. */
  122. 0, /*!< \brief Close a device or file. */
  123. 0, /*!< \brief Request file size. */
  124. 0, /*!< \brief Select function, optional, not yet implemented */
  125. };
  126. /*@}*/