Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GordonSin 0:0ed2a7c7190c 1 /**
GordonSin 0:0ed2a7c7190c 2 * @file
GordonSin 0:0ed2a7c7190c 3 * Ethernet Interface Skeleton
GordonSin 0:0ed2a7c7190c 4 *
GordonSin 0:0ed2a7c7190c 5 */
GordonSin 0:0ed2a7c7190c 6
GordonSin 0:0ed2a7c7190c 7 /*
GordonSin 0:0ed2a7c7190c 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
GordonSin 0:0ed2a7c7190c 9 * All rights reserved.
GordonSin 0:0ed2a7c7190c 10 *
GordonSin 0:0ed2a7c7190c 11 * Redistribution and use in source and binary forms, with or without modification,
GordonSin 0:0ed2a7c7190c 12 * are permitted provided that the following conditions are met:
GordonSin 0:0ed2a7c7190c 13 *
GordonSin 0:0ed2a7c7190c 14 * 1. Redistributions of source code must retain the above copyright notice,
GordonSin 0:0ed2a7c7190c 15 * this list of conditions and the following disclaimer.
GordonSin 0:0ed2a7c7190c 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
GordonSin 0:0ed2a7c7190c 17 * this list of conditions and the following disclaimer in the documentation
GordonSin 0:0ed2a7c7190c 18 * and/or other materials provided with the distribution.
GordonSin 0:0ed2a7c7190c 19 * 3. The name of the author may not be used to endorse or promote products
GordonSin 0:0ed2a7c7190c 20 * derived from this software without specific prior written permission.
GordonSin 0:0ed2a7c7190c 21 *
GordonSin 0:0ed2a7c7190c 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
GordonSin 0:0ed2a7c7190c 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
GordonSin 0:0ed2a7c7190c 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
GordonSin 0:0ed2a7c7190c 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
GordonSin 0:0ed2a7c7190c 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
GordonSin 0:0ed2a7c7190c 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
GordonSin 0:0ed2a7c7190c 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
GordonSin 0:0ed2a7c7190c 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
GordonSin 0:0ed2a7c7190c 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
GordonSin 0:0ed2a7c7190c 31 * OF SUCH DAMAGE.
GordonSin 0:0ed2a7c7190c 32 *
GordonSin 0:0ed2a7c7190c 33 * This file is part of the lwIP TCP/IP stack.
GordonSin 0:0ed2a7c7190c 34 *
GordonSin 0:0ed2a7c7190c 35 * Author: Adam Dunkels <adam@sics.se>
GordonSin 0:0ed2a7c7190c 36 *
GordonSin 0:0ed2a7c7190c 37 */
GordonSin 0:0ed2a7c7190c 38
GordonSin 0:0ed2a7c7190c 39 /*
GordonSin 0:0ed2a7c7190c 40 * This file is a skeleton for developing Ethernet network interface
GordonSin 0:0ed2a7c7190c 41 * drivers for lwIP. Add code to the low_level functions and do a
GordonSin 0:0ed2a7c7190c 42 * search-and-replace for the word "ethernetif" to replace it with
GordonSin 0:0ed2a7c7190c 43 * something that better describes your network interface.
GordonSin 0:0ed2a7c7190c 44 */
GordonSin 0:0ed2a7c7190c 45
GordonSin 0:0ed2a7c7190c 46 #include "lwip/opt.h"
GordonSin 0:0ed2a7c7190c 47
GordonSin 0:0ed2a7c7190c 48 #if 0 /* don't build, this is only a skeleton, see previous comment */
GordonSin 0:0ed2a7c7190c 49
GordonSin 0:0ed2a7c7190c 50 #include "lwip/def.h"
GordonSin 0:0ed2a7c7190c 51 #include "lwip/mem.h"
GordonSin 0:0ed2a7c7190c 52 #include "lwip/pbuf.h"
GordonSin 0:0ed2a7c7190c 53 #include "lwip/sys.h"
GordonSin 0:0ed2a7c7190c 54 #include <lwip/stats.h>
GordonSin 0:0ed2a7c7190c 55 #include <lwip/snmp.h>
GordonSin 0:0ed2a7c7190c 56 #include "netif/etharp.h"
GordonSin 0:0ed2a7c7190c 57 #include "netif/ppp_oe.h"
GordonSin 0:0ed2a7c7190c 58
GordonSin 0:0ed2a7c7190c 59 /* Define those to better describe your network interface. */
GordonSin 0:0ed2a7c7190c 60 #define IFNAME0 'e'
GordonSin 0:0ed2a7c7190c 61 #define IFNAME1 'n'
GordonSin 0:0ed2a7c7190c 62
GordonSin 0:0ed2a7c7190c 63 /**
GordonSin 0:0ed2a7c7190c 64 * Helper struct to hold private data used to operate your ethernet interface.
GordonSin 0:0ed2a7c7190c 65 * Keeping the ethernet address of the MAC in this struct is not necessary
GordonSin 0:0ed2a7c7190c 66 * as it is already kept in the struct netif.
GordonSin 0:0ed2a7c7190c 67 * But this is only an example, anyway...
GordonSin 0:0ed2a7c7190c 68 */
GordonSin 0:0ed2a7c7190c 69 struct ethernetif {
GordonSin 0:0ed2a7c7190c 70 struct eth_addr *ethaddr;
GordonSin 0:0ed2a7c7190c 71 /* Add whatever per-interface state that is needed here. */
GordonSin 0:0ed2a7c7190c 72 };
GordonSin 0:0ed2a7c7190c 73
GordonSin 0:0ed2a7c7190c 74 /* Forward declarations. */
GordonSin 0:0ed2a7c7190c 75 static void ethernetif_input(struct netif *netif);
GordonSin 0:0ed2a7c7190c 76
GordonSin 0:0ed2a7c7190c 77 /**
GordonSin 0:0ed2a7c7190c 78 * In this function, the hardware should be initialized.
GordonSin 0:0ed2a7c7190c 79 * Called from ethernetif_init().
GordonSin 0:0ed2a7c7190c 80 *
GordonSin 0:0ed2a7c7190c 81 * @param netif the already initialized lwip network interface structure
GordonSin 0:0ed2a7c7190c 82 * for this ethernetif
GordonSin 0:0ed2a7c7190c 83 */
GordonSin 0:0ed2a7c7190c 84 static void
GordonSin 0:0ed2a7c7190c 85 low_level_init(struct netif *netif)
GordonSin 0:0ed2a7c7190c 86 {
GordonSin 0:0ed2a7c7190c 87 struct ethernetif *ethernetif = netif->state;
GordonSin 0:0ed2a7c7190c 88
GordonSin 0:0ed2a7c7190c 89 /* set MAC hardware address length */
GordonSin 0:0ed2a7c7190c 90 netif->hwaddr_len = ETHARP_HWADDR_LEN;
GordonSin 0:0ed2a7c7190c 91
GordonSin 0:0ed2a7c7190c 92 /* set MAC hardware address */
GordonSin 0:0ed2a7c7190c 93 netif->hwaddr[0] = ;
GordonSin 0:0ed2a7c7190c 94 ...
GordonSin 0:0ed2a7c7190c 95 netif->hwaddr[5] = ;
GordonSin 0:0ed2a7c7190c 96
GordonSin 0:0ed2a7c7190c 97 /* maximum transfer unit */
GordonSin 0:0ed2a7c7190c 98 netif->mtu = 1500;
GordonSin 0:0ed2a7c7190c 99
GordonSin 0:0ed2a7c7190c 100 /* device capabilities */
GordonSin 0:0ed2a7c7190c 101 /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
GordonSin 0:0ed2a7c7190c 102 netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
GordonSin 0:0ed2a7c7190c 103
GordonSin 0:0ed2a7c7190c 104 /* Do whatever else is needed to initialize interface. */
GordonSin 0:0ed2a7c7190c 105 }
GordonSin 0:0ed2a7c7190c 106
GordonSin 0:0ed2a7c7190c 107 /**
GordonSin 0:0ed2a7c7190c 108 * This function should do the actual transmission of the packet. The packet is
GordonSin 0:0ed2a7c7190c 109 * contained in the pbuf that is passed to the function. This pbuf
GordonSin 0:0ed2a7c7190c 110 * might be chained.
GordonSin 0:0ed2a7c7190c 111 *
GordonSin 0:0ed2a7c7190c 112 * @param netif the lwip network interface structure for this ethernetif
GordonSin 0:0ed2a7c7190c 113 * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
GordonSin 0:0ed2a7c7190c 114 * @return ERR_OK if the packet could be sent
GordonSin 0:0ed2a7c7190c 115 * an err_t value if the packet couldn't be sent
GordonSin 0:0ed2a7c7190c 116 *
GordonSin 0:0ed2a7c7190c 117 * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
GordonSin 0:0ed2a7c7190c 118 * strange results. You might consider waiting for space in the DMA queue
GordonSin 0:0ed2a7c7190c 119 * to become availale since the stack doesn't retry to send a packet
GordonSin 0:0ed2a7c7190c 120 * dropped because of memory failure (except for the TCP timers).
GordonSin 0:0ed2a7c7190c 121 */
GordonSin 0:0ed2a7c7190c 122
GordonSin 0:0ed2a7c7190c 123 static err_t
GordonSin 0:0ed2a7c7190c 124 low_level_output(struct netif *netif, struct pbuf *p)
GordonSin 0:0ed2a7c7190c 125 {
GordonSin 0:0ed2a7c7190c 126 struct ethernetif *ethernetif = netif->state;
GordonSin 0:0ed2a7c7190c 127 struct pbuf *q;
GordonSin 0:0ed2a7c7190c 128
GordonSin 0:0ed2a7c7190c 129 initiate transfer();
GordonSin 0:0ed2a7c7190c 130
GordonSin 0:0ed2a7c7190c 131 #if ETH_PAD_SIZE
GordonSin 0:0ed2a7c7190c 132 pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
GordonSin 0:0ed2a7c7190c 133 #endif
GordonSin 0:0ed2a7c7190c 134
GordonSin 0:0ed2a7c7190c 135 for(q = p; q != NULL; q = q->next) {
GordonSin 0:0ed2a7c7190c 136 /* Send the data from the pbuf to the interface, one pbuf at a
GordonSin 0:0ed2a7c7190c 137 time. The size of the data in each pbuf is kept in the ->len
GordonSin 0:0ed2a7c7190c 138 variable. */
GordonSin 0:0ed2a7c7190c 139 send data from(q->payload, q->len);
GordonSin 0:0ed2a7c7190c 140 }
GordonSin 0:0ed2a7c7190c 141
GordonSin 0:0ed2a7c7190c 142 signal that packet should be sent();
GordonSin 0:0ed2a7c7190c 143
GordonSin 0:0ed2a7c7190c 144 #if ETH_PAD_SIZE
GordonSin 0:0ed2a7c7190c 145 pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
GordonSin 0:0ed2a7c7190c 146 #endif
GordonSin 0:0ed2a7c7190c 147
GordonSin 0:0ed2a7c7190c 148 LINK_STATS_INC(link.xmit);
GordonSin 0:0ed2a7c7190c 149
GordonSin 0:0ed2a7c7190c 150 return ERR_OK;
GordonSin 0:0ed2a7c7190c 151 }
GordonSin 0:0ed2a7c7190c 152
GordonSin 0:0ed2a7c7190c 153 /**
GordonSin 0:0ed2a7c7190c 154 * Should allocate a pbuf and transfer the bytes of the incoming
GordonSin 0:0ed2a7c7190c 155 * packet from the interface into the pbuf.
GordonSin 0:0ed2a7c7190c 156 *
GordonSin 0:0ed2a7c7190c 157 * @param netif the lwip network interface structure for this ethernetif
GordonSin 0:0ed2a7c7190c 158 * @return a pbuf filled with the received packet (including MAC header)
GordonSin 0:0ed2a7c7190c 159 * NULL on memory error
GordonSin 0:0ed2a7c7190c 160 */
GordonSin 0:0ed2a7c7190c 161 static struct pbuf *
GordonSin 0:0ed2a7c7190c 162 low_level_input(struct netif *netif)
GordonSin 0:0ed2a7c7190c 163 {
GordonSin 0:0ed2a7c7190c 164 struct ethernetif *ethernetif = netif->state;
GordonSin 0:0ed2a7c7190c 165 struct pbuf *p, *q;
GordonSin 0:0ed2a7c7190c 166 u16_t len;
GordonSin 0:0ed2a7c7190c 167
GordonSin 0:0ed2a7c7190c 168 /* Obtain the size of the packet and put it into the "len"
GordonSin 0:0ed2a7c7190c 169 variable. */
GordonSin 0:0ed2a7c7190c 170 len = ;
GordonSin 0:0ed2a7c7190c 171
GordonSin 0:0ed2a7c7190c 172 #if ETH_PAD_SIZE
GordonSin 0:0ed2a7c7190c 173 len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
GordonSin 0:0ed2a7c7190c 174 #endif
GordonSin 0:0ed2a7c7190c 175
GordonSin 0:0ed2a7c7190c 176 /* We allocate a pbuf chain of pbufs from the pool. */
GordonSin 0:0ed2a7c7190c 177 p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
GordonSin 0:0ed2a7c7190c 178
GordonSin 0:0ed2a7c7190c 179 if (p != NULL) {
GordonSin 0:0ed2a7c7190c 180
GordonSin 0:0ed2a7c7190c 181 #if ETH_PAD_SIZE
GordonSin 0:0ed2a7c7190c 182 pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
GordonSin 0:0ed2a7c7190c 183 #endif
GordonSin 0:0ed2a7c7190c 184
GordonSin 0:0ed2a7c7190c 185 /* We iterate over the pbuf chain until we have read the entire
GordonSin 0:0ed2a7c7190c 186 * packet into the pbuf. */
GordonSin 0:0ed2a7c7190c 187 for(q = p; q != NULL; q = q->next) {
GordonSin 0:0ed2a7c7190c 188 /* Read enough bytes to fill this pbuf in the chain. The
GordonSin 0:0ed2a7c7190c 189 * available data in the pbuf is given by the q->len
GordonSin 0:0ed2a7c7190c 190 * variable.
GordonSin 0:0ed2a7c7190c 191 * This does not necessarily have to be a memcpy, you can also preallocate
GordonSin 0:0ed2a7c7190c 192 * pbufs for a DMA-enabled MAC and after receiving truncate it to the
GordonSin 0:0ed2a7c7190c 193 * actually received size. In this case, ensure the tot_len member of the
GordonSin 0:0ed2a7c7190c 194 * pbuf is the sum of the chained pbuf len members.
GordonSin 0:0ed2a7c7190c 195 */
GordonSin 0:0ed2a7c7190c 196 read data into(q->payload, q->len);
GordonSin 0:0ed2a7c7190c 197 }
GordonSin 0:0ed2a7c7190c 198 acknowledge that packet has been read();
GordonSin 0:0ed2a7c7190c 199
GordonSin 0:0ed2a7c7190c 200 #if ETH_PAD_SIZE
GordonSin 0:0ed2a7c7190c 201 pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
GordonSin 0:0ed2a7c7190c 202 #endif
GordonSin 0:0ed2a7c7190c 203
GordonSin 0:0ed2a7c7190c 204 LINK_STATS_INC(link.recv);
GordonSin 0:0ed2a7c7190c 205 } else {
GordonSin 0:0ed2a7c7190c 206 drop packet();
GordonSin 0:0ed2a7c7190c 207 LINK_STATS_INC(link.memerr);
GordonSin 0:0ed2a7c7190c 208 LINK_STATS_INC(link.drop);
GordonSin 0:0ed2a7c7190c 209 }
GordonSin 0:0ed2a7c7190c 210
GordonSin 0:0ed2a7c7190c 211 return p;
GordonSin 0:0ed2a7c7190c 212 }
GordonSin 0:0ed2a7c7190c 213
GordonSin 0:0ed2a7c7190c 214 /**
GordonSin 0:0ed2a7c7190c 215 * This function should be called when a packet is ready to be read
GordonSin 0:0ed2a7c7190c 216 * from the interface. It uses the function low_level_input() that
GordonSin 0:0ed2a7c7190c 217 * should handle the actual reception of bytes from the network
GordonSin 0:0ed2a7c7190c 218 * interface. Then the type of the received packet is determined and
GordonSin 0:0ed2a7c7190c 219 * the appropriate input function is called.
GordonSin 0:0ed2a7c7190c 220 *
GordonSin 0:0ed2a7c7190c 221 * @param netif the lwip network interface structure for this ethernetif
GordonSin 0:0ed2a7c7190c 222 */
GordonSin 0:0ed2a7c7190c 223 static void
GordonSin 0:0ed2a7c7190c 224 ethernetif_input(struct netif *netif)
GordonSin 0:0ed2a7c7190c 225 {
GordonSin 0:0ed2a7c7190c 226 struct ethernetif *ethernetif;
GordonSin 0:0ed2a7c7190c 227 struct eth_hdr *ethhdr;
GordonSin 0:0ed2a7c7190c 228 struct pbuf *p;
GordonSin 0:0ed2a7c7190c 229
GordonSin 0:0ed2a7c7190c 230 ethernetif = netif->state;
GordonSin 0:0ed2a7c7190c 231
GordonSin 0:0ed2a7c7190c 232 /* move received packet into a new pbuf */
GordonSin 0:0ed2a7c7190c 233 p = low_level_input(netif);
GordonSin 0:0ed2a7c7190c 234 /* no packet could be read, silently ignore this */
GordonSin 0:0ed2a7c7190c 235 if (p == NULL) return;
GordonSin 0:0ed2a7c7190c 236 /* points to packet payload, which starts with an Ethernet header */
GordonSin 0:0ed2a7c7190c 237 ethhdr = p->payload;
GordonSin 0:0ed2a7c7190c 238
GordonSin 0:0ed2a7c7190c 239 switch (htons(ethhdr->type)) {
GordonSin 0:0ed2a7c7190c 240 /* IP or ARP packet? */
GordonSin 0:0ed2a7c7190c 241 case ETHTYPE_IP:
GordonSin 0:0ed2a7c7190c 242 case ETHTYPE_ARP:
GordonSin 0:0ed2a7c7190c 243 #if PPPOE_SUPPORT
GordonSin 0:0ed2a7c7190c 244 /* PPPoE packet? */
GordonSin 0:0ed2a7c7190c 245 case ETHTYPE_PPPOEDISC:
GordonSin 0:0ed2a7c7190c 246 case ETHTYPE_PPPOE:
GordonSin 0:0ed2a7c7190c 247 #endif /* PPPOE_SUPPORT */
GordonSin 0:0ed2a7c7190c 248 /* full packet send to tcpip_thread to process */
GordonSin 0:0ed2a7c7190c 249 if (netif->input(p, netif)!=ERR_OK)
GordonSin 0:0ed2a7c7190c 250 { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
GordonSin 0:0ed2a7c7190c 251 pbuf_free(p);
GordonSin 0:0ed2a7c7190c 252 p = NULL;
GordonSin 0:0ed2a7c7190c 253 }
GordonSin 0:0ed2a7c7190c 254 break;
GordonSin 0:0ed2a7c7190c 255
GordonSin 0:0ed2a7c7190c 256 default:
GordonSin 0:0ed2a7c7190c 257 pbuf_free(p);
GordonSin 0:0ed2a7c7190c 258 p = NULL;
GordonSin 0:0ed2a7c7190c 259 break;
GordonSin 0:0ed2a7c7190c 260 }
GordonSin 0:0ed2a7c7190c 261 }
GordonSin 0:0ed2a7c7190c 262
GordonSin 0:0ed2a7c7190c 263 /**
GordonSin 0:0ed2a7c7190c 264 * Should be called at the beginning of the program to set up the
GordonSin 0:0ed2a7c7190c 265 * network interface. It calls the function low_level_init() to do the
GordonSin 0:0ed2a7c7190c 266 * actual setup of the hardware.
GordonSin 0:0ed2a7c7190c 267 *
GordonSin 0:0ed2a7c7190c 268 * This function should be passed as a parameter to netif_add().
GordonSin 0:0ed2a7c7190c 269 *
GordonSin 0:0ed2a7c7190c 270 * @param netif the lwip network interface structure for this ethernetif
GordonSin 0:0ed2a7c7190c 271 * @return ERR_OK if the loopif is initialized
GordonSin 0:0ed2a7c7190c 272 * ERR_MEM if private data couldn't be allocated
GordonSin 0:0ed2a7c7190c 273 * any other err_t on error
GordonSin 0:0ed2a7c7190c 274 */
GordonSin 0:0ed2a7c7190c 275 err_t
GordonSin 0:0ed2a7c7190c 276 ethernetif_init(struct netif *netif)
GordonSin 0:0ed2a7c7190c 277 {
GordonSin 0:0ed2a7c7190c 278 struct ethernetif *ethernetif;
GordonSin 0:0ed2a7c7190c 279
GordonSin 0:0ed2a7c7190c 280 LWIP_ASSERT("netif != NULL", (netif != NULL));
GordonSin 0:0ed2a7c7190c 281
GordonSin 0:0ed2a7c7190c 282 ethernetif = mem_malloc(sizeof(struct ethernetif));
GordonSin 0:0ed2a7c7190c 283 if (ethernetif == NULL) {
GordonSin 0:0ed2a7c7190c 284 LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n"));
GordonSin 0:0ed2a7c7190c 285 return ERR_MEM;
GordonSin 0:0ed2a7c7190c 286 }
GordonSin 0:0ed2a7c7190c 287
GordonSin 0:0ed2a7c7190c 288 #if LWIP_NETIF_HOSTNAME
GordonSin 0:0ed2a7c7190c 289 /* Initialize interface hostname */
GordonSin 0:0ed2a7c7190c 290 netif->hostname = "lwip";
GordonSin 0:0ed2a7c7190c 291 #endif /* LWIP_NETIF_HOSTNAME */
GordonSin 0:0ed2a7c7190c 292
GordonSin 0:0ed2a7c7190c 293 /*
GordonSin 0:0ed2a7c7190c 294 * Initialize the snmp variables and counters inside the struct netif.
GordonSin 0:0ed2a7c7190c 295 * The last argument should be replaced with your link speed, in units
GordonSin 0:0ed2a7c7190c 296 * of bits per second.
GordonSin 0:0ed2a7c7190c 297 */
GordonSin 0:0ed2a7c7190c 298 NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
GordonSin 0:0ed2a7c7190c 299
GordonSin 0:0ed2a7c7190c 300 netif->state = ethernetif;
GordonSin 0:0ed2a7c7190c 301 netif->name[0] = IFNAME0;
GordonSin 0:0ed2a7c7190c 302 netif->name[1] = IFNAME1;
GordonSin 0:0ed2a7c7190c 303 /* We directly use etharp_output() here to save a function call.
GordonSin 0:0ed2a7c7190c 304 * You can instead declare your own function an call etharp_output()
GordonSin 0:0ed2a7c7190c 305 * from it if you have to do some checks before sending (e.g. if link
GordonSin 0:0ed2a7c7190c 306 * is available...) */
GordonSin 0:0ed2a7c7190c 307 netif->output = etharp_output;
GordonSin 0:0ed2a7c7190c 308 netif->linkoutput = low_level_output;
GordonSin 0:0ed2a7c7190c 309
GordonSin 0:0ed2a7c7190c 310 ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
GordonSin 0:0ed2a7c7190c 311
GordonSin 0:0ed2a7c7190c 312 /* initialize the hardware */
GordonSin 0:0ed2a7c7190c 313 low_level_init(netif);
GordonSin 0:0ed2a7c7190c 314
GordonSin 0:0ed2a7c7190c 315 return ERR_OK;
GordonSin 0:0ed2a7c7190c 316 }
GordonSin 0:0ed2a7c7190c 317
GordonSin 0:0ed2a7c7190c 318 #endif /* 0 */