The Pedigree Project 0.1
tcpip.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
25/*
26 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without modification,
30 * are permitted provided that the following conditions are met:
31 *
32 * 1. Redistributions of source code must retain the above copyright notice,
33 * this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright notice,
35 * this list of conditions and the following disclaimer in the documentation
36 * and/or other materials provided with the distribution.
37 * 3. The name of the author may not be used to endorse or promote products
38 * derived from this software without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
41 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
43 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
45 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
48 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49 * OF SUCH DAMAGE.
50 *
51 * This file is part of the lwIP TCP/IP stack.
52 *
53 * Author: Adam Dunkels <adam@sics.se>
54 *
55 */
56#ifndef LWIP_HDR_TCPIP_H
57#define LWIP_HDR_TCPIP_H
58
59#include "lwip/opt.h"
60
61#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
62
63#include "lwip/err.h"
64#include "lwip/timeouts.h"
65#include "lwip/netif.h"
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71#if LWIP_TCPIP_CORE_LOCKING
73extern sys_mutex_t lock_tcpip_core;
75#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
77#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
78#else /* LWIP_TCPIP_CORE_LOCKING */
79#define LOCK_TCPIP_CORE()
80#define UNLOCK_TCPIP_CORE()
81#endif /* LWIP_TCPIP_CORE_LOCKING */
82
83struct pbuf;
84struct netif;
85
87typedef void (*tcpip_init_done_fn)(void *arg);
89typedef void (*tcpip_callback_fn)(void *ctx);
90
91/* Forward declarations */
92struct tcpip_callback_msg;
93
94void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
102
103err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn);
104err_t tcpip_input(struct pbuf *p, struct netif *inp);
105
106err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
108err_t tcpip_callback_wait(tcpip_callback_fn function, void *ctx);
113#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
114
115struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx);
116void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg);
117err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
118
119/* free pbufs or heap memory from another context without blocking */
120err_t pbuf_free_callback(struct pbuf *p);
121err_t mem_free_callback(void *m);
122
123#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS
124err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
125err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
126#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif /* !NO_SYS */
133
134#endif /* LWIP_HDR_TCPIP_H */
s8_t err_t
Definition err.h:76
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition netif.h:181
Definition netif.h:244
Definition pbuf.h:161
struct tcpip_callback_msg * tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx)
Definition tcpip.c:594
void(* tcpip_callback_fn)(void *ctx)
Definition tcpip.h:89
err_t mem_free_callback(void *m)
Definition tcpip.c:790
err_t pbuf_free_callback(struct pbuf *p)
Definition tcpip.c:777
void(* tcpip_init_done_fn)(void *arg)
Definition tcpip.h:87
err_t tcpip_callback_wait(tcpip_callback_fn function, void *ctx)
Definition tcpip.c:365
err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
Definition tcpip.c:236
err_t tcpip_shutdown(void)
Definition tcpip.c:680
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg)
Definition tcpip.c:648
void tcpip_callbackmsg_delete(struct tcpip_callback_msg *msg)
Definition tcpip.c:612
err_t tcpip_trycallback(struct tcpip_callback_msg *msg)
Definition tcpip.c:625
err_t tcpip_input(struct pbuf *p, struct netif *inp)
Definition tcpip.c:286