HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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