GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / net / net_ip.h
blob40594d8fcc9c248786bac04e2947bcdd7fdb3dec
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * IP Protocol Definitions File: net_ip.h
5 *
6 * This is the main include file for the CFE network stack.
7 *
8 * Author: Mitch Lichtenberg (mpl@broadcom.com)
9 *
10 *********************************************************************
12 * Copyright 2000,2001,2002,2003
13 * Broadcom Corporation. All rights reserved.
15 * This software is furnished under license and may be used and
16 * copied only in accordance with the following terms and
17 * conditions. Subject to these conditions, you may download,
18 * copy, install, use, modify and distribute modified or unmodified
19 * copies of this software in source and/or binary form. No title
20 * or ownership is transferred hereby.
22 * 1) Any source code used, modified or distributed must reproduce
23 * and retain this copyright notice and list of conditions
24 * as they appear in the source file.
26 * 2) No right is granted to use any trade name, trademark, or
27 * logo of Broadcom Corporation. The "Broadcom Corporation"
28 * name may not be used to endorse or promote products derived
29 * from this software without the prior written permission of
30 * Broadcom Corporation.
32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
44 * THE POSSIBILITY OF SUCH DAMAGE.
45 ********************************************************************* */
49 /* *********************************************************************
50 * Global info
51 ********************************************************************* */
53 #ifndef IP_ADDR_LEN
54 #define IP_ADDR_LEN 4
55 #endif
57 typedef struct ip_info_s ip_info_t;
59 typedef struct net_info_s {
60 /* Configuration info for IP interface */
61 uint8_t ip_addr[IP_ADDR_LEN];
62 uint8_t ip_netmask[IP_ADDR_LEN];
63 uint8_t ip_gateway[IP_ADDR_LEN];
64 uint8_t ip_nameserver[IP_ADDR_LEN];
65 char *ip_domain;
66 char *ip_hostname;
67 } net_info_t;
69 /* *********************************************************************
70 * ARP Information
71 ********************************************************************* */
73 int _arp_lookup_and_send(ip_info_t *ipi,ebuf_t *buf,uint8_t *dest);
74 void _arp_timer_tick(ip_info_t *ipi);
75 int _arp_init(ip_info_t *ipi);
76 void _arp_uninit(ip_info_t *ipi);
77 void _arp_add(ip_info_t *ipi,uint8_t *destip,uint8_t *desthw);
78 void _arp_send_gratuitous(ip_info_t *ipi);
79 uint8_t *_arp_lookup(ip_info_t *ipi,uint8_t *destip);
80 int _arp_enumerate(ip_info_t *ipi,int entrynum,uint8_t *ipaddr,uint8_t *hwaddr);
81 int _arp_delete(ip_info_t *ipi,uint8_t *ipaddr);
84 /* *********************************************************************
85 * IP protocol
86 ********************************************************************* */
89 #define IPPROTO_TCP 6
90 #define IPPROTO_UDP 17
91 #define IPPROTO_ICMP 1
93 int _ip_send(ip_info_t *ipi,ebuf_t *buf,uint8_t *destaddr,uint8_t proto);
94 ip_info_t *_ip_init(ether_info_t *);
95 void _ip_timer_tick(ip_info_t *ipi);
96 void _ip_uninit(ip_info_t *ipi);
97 ebuf_t *_ip_alloc(ip_info_t *ipi);
98 void _ip_free(ip_info_t *ipi,ebuf_t *buf);
99 void _ip_getaddr(ip_info_t *ipi,uint8_t *buf);
100 uint8_t *_ip_getparam(ip_info_t *ipinfo,int param);
101 int _ip_setparam(ip_info_t *ipinfo,int param,uint8_t *ptr);
102 uint16_t ip_chksum(uint16_t initcksum,uint8_t *ptr,int len);
103 void _ip_deregister(ip_info_t *ipinfo,int proto);
104 void _ip_register(ip_info_t *ipinfo,
105 int proto,
106 int (*cb)(void *ref,ebuf_t *buf,uint8_t *dst,uint8_t *src),void *ref);
109 #define ip_mask(dest,a,b) (dest)[0] = (a)[0] & (b)[0] ; \
110 (dest)[1] = (a)[1] & (b)[1] ; \
111 (dest)[2] = (a)[2] & (b)[2] ; \
112 (dest)[3] = (a)[3] & (b)[3]
114 #define ip_compareaddr(a,b) memcmp(a,b,IP_ADDR_LEN)
116 #define ip_addriszero(a) (((a)[0]|(a)[1]|(a)[2]|(a)[3]) == 0)
117 #define ip_addrisbcast(a) ((a[0] == 0xFF) && (a[1] == 0xFF) && (a[2] == 0xFF) && (a[3] == 0xFF))
119 #ifndef NET_IPADDR
120 #define NET_IPADDR 0
121 #define NET_NETMASK 1
122 #define NET_GATEWAY 2
123 #define NET_NAMESERVER 3
124 #define NET_HWADDR 4
125 #define NET_DOMAIN 5
126 #define NET_HOSTNAME 6
127 #define NET_SPEED 7
128 #define NET_LOOPBACK 8
129 #endif
131 /* *********************************************************************
132 * UDP Protocol
133 ********************************************************************* */
135 typedef struct udp_info_s udp_info_t;
137 int _udp_socket(udp_info_t *info,uint16_t port);
138 void _udp_close(udp_info_t *info,int s);
139 int _udp_send(udp_info_t *info,int s,ebuf_t *buf,uint8_t *dest);
140 udp_info_t *_udp_init(ip_info_t *ipi,void *ref);
141 void _udp_uninit(udp_info_t *info);
142 int _udp_bind(udp_info_t *info,int s,uint16_t port);
143 int _udp_connect(udp_info_t *info,int s,uint16_t port);
144 ebuf_t *_udp_recv(udp_info_t *info,int s);
145 ebuf_t *_udp_alloc(udp_info_t *info);
146 void _udp_free(udp_info_t *info,ebuf_t *buf);
148 /* *********************************************************************
149 * ICMP protocol
150 ********************************************************************* */
152 typedef struct icmp_info_s icmp_info_t;
154 icmp_info_t *_icmp_init(ip_info_t *ipi);
155 void _icmp_uninit(icmp_info_t *icmp);
157 int _icmp_ping(icmp_info_t *icmp,uint8_t *ipaddr,int seq,int len);