Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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