Forked from STM32F7 internet for nucleo F746ZG

Dependents:   Nucleo_F746ZG_Ethernet_MQTT_Ultrasound

Fork of F7_Ethernet by Dieter Graef

Committer:
EmbeddedSam
Date:
Mon Oct 24 12:59:21 2016 +0000
Revision:
2:b4727195c450
Parent:
0:d26c1b55cfca
working with 1 ultrasound sensor approx 10hz update rate on mqtt

Who changed what in which revision?

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