ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:f9b6112278fe 1 /*
DieterGraef 0:f9b6112278fe 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
DieterGraef 0:f9b6112278fe 3 * All rights reserved.
DieterGraef 0:f9b6112278fe 4 *
DieterGraef 0:f9b6112278fe 5 * Redistribution and use in source and binary forms, with or without modification,
DieterGraef 0:f9b6112278fe 6 * are permitted provided that the following conditions are met:
DieterGraef 0:f9b6112278fe 7 *
DieterGraef 0:f9b6112278fe 8 * 1. Redistributions of source code must retain the above copyright notice,
DieterGraef 0:f9b6112278fe 9 * this list of conditions and the following disclaimer.
DieterGraef 0:f9b6112278fe 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
DieterGraef 0:f9b6112278fe 11 * this list of conditions and the following disclaimer in the documentation
DieterGraef 0:f9b6112278fe 12 * and/or other materials provided with the distribution.
DieterGraef 0:f9b6112278fe 13 * 3. The name of the author may not be used to endorse or promote products
DieterGraef 0:f9b6112278fe 14 * derived from this software without specific prior written permission.
DieterGraef 0:f9b6112278fe 15 *
DieterGraef 0:f9b6112278fe 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
DieterGraef 0:f9b6112278fe 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
DieterGraef 0:f9b6112278fe 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
DieterGraef 0:f9b6112278fe 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
DieterGraef 0:f9b6112278fe 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
DieterGraef 0:f9b6112278fe 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
DieterGraef 0:f9b6112278fe 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
DieterGraef 0:f9b6112278fe 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
DieterGraef 0:f9b6112278fe 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
DieterGraef 0:f9b6112278fe 25 * OF SUCH DAMAGE.
DieterGraef 0:f9b6112278fe 26 *
DieterGraef 0:f9b6112278fe 27 * This file is part of the lwIP TCP/IP stack.
DieterGraef 0:f9b6112278fe 28 *
DieterGraef 0:f9b6112278fe 29 * Author: Adam Dunkels <adam@sics.se>
DieterGraef 0:f9b6112278fe 30 *
DieterGraef 0:f9b6112278fe 31 */
DieterGraef 0:f9b6112278fe 32 #ifndef __LWIP_NETBUF_H__
DieterGraef 0:f9b6112278fe 33 #define __LWIP_NETBUF_H__
DieterGraef 0:f9b6112278fe 34
DieterGraef 0:f9b6112278fe 35 #include "lwip/opt.h"
DieterGraef 0:f9b6112278fe 36 #include "lwip/pbuf.h"
DieterGraef 0:f9b6112278fe 37 #include "lwip/ip_addr.h"
DieterGraef 0:f9b6112278fe 38
DieterGraef 0:f9b6112278fe 39 #ifdef __cplusplus
DieterGraef 0:f9b6112278fe 40 extern "C" {
DieterGraef 0:f9b6112278fe 41 #endif
DieterGraef 0:f9b6112278fe 42
DieterGraef 0:f9b6112278fe 43 /** This netbuf has dest-addr/port set */
DieterGraef 0:f9b6112278fe 44 #define NETBUF_FLAG_DESTADDR 0x01
DieterGraef 0:f9b6112278fe 45 /** This netbuf includes a checksum */
DieterGraef 0:f9b6112278fe 46 #define NETBUF_FLAG_CHKSUM 0x02
DieterGraef 0:f9b6112278fe 47
DieterGraef 0:f9b6112278fe 48 struct netbuf {
DieterGraef 0:f9b6112278fe 49 struct pbuf *p, *ptr;
DieterGraef 0:f9b6112278fe 50 ip_addr_t addr;
DieterGraef 0:f9b6112278fe 51 u16_t port;
DieterGraef 0:f9b6112278fe 52 #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
DieterGraef 0:f9b6112278fe 53 #if LWIP_CHECKSUM_ON_COPY
DieterGraef 0:f9b6112278fe 54 u8_t flags;
DieterGraef 0:f9b6112278fe 55 #endif /* LWIP_CHECKSUM_ON_COPY */
DieterGraef 0:f9b6112278fe 56 u16_t toport_chksum;
DieterGraef 0:f9b6112278fe 57 #if LWIP_NETBUF_RECVINFO
DieterGraef 0:f9b6112278fe 58 ip_addr_t toaddr;
DieterGraef 0:f9b6112278fe 59 #endif /* LWIP_NETBUF_RECVINFO */
DieterGraef 0:f9b6112278fe 60 #endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */
DieterGraef 0:f9b6112278fe 61 };
DieterGraef 0:f9b6112278fe 62
DieterGraef 0:f9b6112278fe 63 /* Network buffer functions: */
DieterGraef 0:f9b6112278fe 64 struct netbuf * netbuf_new (void);
DieterGraef 0:f9b6112278fe 65 void netbuf_delete (struct netbuf *buf);
DieterGraef 0:f9b6112278fe 66 void * netbuf_alloc (struct netbuf *buf, u16_t size);
DieterGraef 0:f9b6112278fe 67 void netbuf_free (struct netbuf *buf);
DieterGraef 0:f9b6112278fe 68 err_t netbuf_ref (struct netbuf *buf,
DieterGraef 0:f9b6112278fe 69 const void *dataptr, u16_t size);
DieterGraef 0:f9b6112278fe 70 void netbuf_chain (struct netbuf *head,
DieterGraef 0:f9b6112278fe 71 struct netbuf *tail);
DieterGraef 0:f9b6112278fe 72
DieterGraef 0:f9b6112278fe 73 err_t netbuf_data (struct netbuf *buf,
DieterGraef 0:f9b6112278fe 74 void **dataptr, u16_t *len);
DieterGraef 0:f9b6112278fe 75 s8_t netbuf_next (struct netbuf *buf);
DieterGraef 0:f9b6112278fe 76 void netbuf_first (struct netbuf *buf);
DieterGraef 0:f9b6112278fe 77
DieterGraef 0:f9b6112278fe 78
DieterGraef 0:f9b6112278fe 79 #define netbuf_copy_partial(buf, dataptr, len, offset) \
DieterGraef 0:f9b6112278fe 80 pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
DieterGraef 0:f9b6112278fe 81 #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
DieterGraef 0:f9b6112278fe 82 #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
DieterGraef 0:f9b6112278fe 83 #define netbuf_len(buf) ((buf)->p->tot_len)
DieterGraef 0:f9b6112278fe 84 #define netbuf_fromaddr(buf) (&((buf)->addr))
DieterGraef 0:f9b6112278fe 85 #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
DieterGraef 0:f9b6112278fe 86 #define netbuf_fromport(buf) ((buf)->port)
DieterGraef 0:f9b6112278fe 87 #if LWIP_NETBUF_RECVINFO
DieterGraef 0:f9b6112278fe 88 #define netbuf_destaddr(buf) (&((buf)->toaddr))
DieterGraef 0:f9b6112278fe 89 #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
DieterGraef 0:f9b6112278fe 90 #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
DieterGraef 0:f9b6112278fe 91 #endif /* LWIP_NETBUF_RECVINFO */
DieterGraef 0:f9b6112278fe 92 #if LWIP_CHECKSUM_ON_COPY
DieterGraef 0:f9b6112278fe 93 #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
DieterGraef 0:f9b6112278fe 94 (buf)->toport_chksum = chksum; } while(0)
DieterGraef 0:f9b6112278fe 95 #endif /* LWIP_CHECKSUM_ON_COPY */
DieterGraef 0:f9b6112278fe 96
DieterGraef 0:f9b6112278fe 97 #ifdef __cplusplus
DieterGraef 0:f9b6112278fe 98 }
DieterGraef 0:f9b6112278fe 99 #endif
DieterGraef 0:f9b6112278fe 100
DieterGraef 0:f9b6112278fe 101 #endif /* __LWIP_NETBUF_H__ */