Stripped down version of Segundos NetService library (http://mbed.org/users/segundo/libraries/NetServices ). I have removed all NetServices, and all functions which had been disabled. Use this version when you need only pure TCP or UDP functions - this library compiles faster.

Dependencies:   lwip lwip-sys

Dependents:   christmasLights device_server pop3demo device_server_udp ... more

Committer:
hlipka
Date:
Mon Jan 10 21:03:11 2011 +0000
Revision:
0:8b387bed54c2
initial version

Who changed what in which revision?

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