The Pedigree Project 0.1
netifapi.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 * Redistribution and use in source and binary forms, with or without modification,
27 * are permitted provided that the following conditions are met:
28 *
29 * 1. Redistributions of source code must retain the above copyright notice,
30 * this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright notice,
32 * this list of conditions and the following disclaimer in the documentation
33 * and/or other materials provided with the distribution.
34 * 3. The name of the author may not be used to endorse or promote products
35 * derived from this software without specific prior written permission.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
40 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
45 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
46 * OF SUCH DAMAGE.
47 *
48 * This file is part of the lwIP TCP/IP stack.
49 *
50 */
51#ifndef LWIP_HDR_NETIFAPI_H
52#define LWIP_HDR_NETIFAPI_H
53
54#include "lwip/opt.h"
55
56#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
57
58#include "lwip/sys.h"
59#include "lwip/netif.h"
60#include "lwip/dhcp.h"
61#include "lwip/autoip.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68#if LWIP_MPU_COMPATIBLE
69#define NETIFAPI_IPADDR_DEF(type, m) type m
70#else /* LWIP_MPU_COMPATIBLE */
71#define NETIFAPI_IPADDR_DEF(type, m) const type * m
72#endif /* LWIP_MPU_COMPATIBLE */
73
74typedef void (*netifapi_void_fn)(struct netif *netif);
75typedef err_t (*netifapi_errt_fn)(struct netif *netif);
76
77struct netifapi_msg {
78 struct tcpip_api_call_data call;
79 struct netif *netif;
80 union {
81 struct {
82#if LWIP_IPV4
83 NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr);
84 NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask);
85 NETIFAPI_IPADDR_DEF(ip4_addr_t, gw);
86#endif /* LWIP_IPV4 */
87 void *state;
88 netif_init_fn init;
89 netif_input_fn input;
90 } add;
91 struct {
92 netifapi_void_fn voidfunc;
93 netifapi_errt_fn errtfunc;
94 } common;
95 } msg;
96};
97
98
99/* API for application */
100err_t netifapi_netif_add(struct netif *netif,
101#if LWIP_IPV4
102 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
103#endif /* LWIP_IPV4 */
104 void *state, netif_init_fn init, netif_input_fn input);
105
106#if LWIP_IPV4
107err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr,
108 const ip4_addr_t *netmask, const ip4_addr_t *gw);
109#endif /* LWIP_IPV4*/
110
111err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
112 netifapi_errt_fn errtfunc);
113
115#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
117#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
119#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
121#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
123#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
125#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
126
133#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
135#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
137#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL)
139#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew)
141#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release)
142
149#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
151#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif /* LWIP_NETIF_API */
158
159#endif /* LWIP_HDR_NETIFAPI_H */
s8_t err_t
Definition err.h:76
#define LWIP_IPV4
Definition opt.h:659
err_t(* netif_init_fn)(struct netif *netif)
Definition netif.h:174
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition netif.h:181
Definition netif.h:244