GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / net / net_api.h
blobd57363337dc6406659c28f7a91a0722bcbd8c211
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * High-level network API defs File: net_api.h
5 *
6 * This module contains prototypes and constants for the
7 * network (TCP/IP) interface.
8 *
9 * Author: Mitch Lichtenberg (mpl@broadcom.com)
11 *********************************************************************
13 * Copyright 2000,2001,2002,2003
14 * Broadcom Corporation. All rights reserved.
16 * This software is furnished under license and may be used and
17 * copied only in accordance with the following terms and
18 * conditions. Subject to these conditions, you may download,
19 * copy, install, use, modify and distribute modified or unmodified
20 * copies of this software in source and/or binary form. No title
21 * or ownership is transferred hereby.
23 * 1) Any source code used, modified or distributed must reproduce
24 * and retain this copyright notice and list of conditions
25 * as they appear in the source file.
27 * 2) No right is granted to use any trade name, trademark, or
28 * logo of Broadcom Corporation. The "Broadcom Corporation"
29 * name may not be used to endorse or promote products derived
30 * from this software without the prior written permission of
31 * Broadcom Corporation.
33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45 * THE POSSIBILITY OF SUCH DAMAGE.
46 ********************************************************************* */
49 /* *********************************************************************
50 * Constants
51 ********************************************************************* */
53 #ifndef IP_ADDR_LEN
54 #define IP_ADDR_LEN 4
55 #endif
57 /* *********************************************************************
58 * DHCP Protocol
59 ********************************************************************* */
61 typedef struct dhcpreply_s {
62 uint8_t dr_ipaddr[IP_ADDR_LEN];
63 uint8_t dr_netmask[IP_ADDR_LEN];
64 uint8_t dr_gateway[IP_ADDR_LEN];
65 uint8_t dr_nameserver[IP_ADDR_LEN];
66 uint8_t dr_dhcpserver[IP_ADDR_LEN];
67 uint8_t dr_bootserver[IP_ADDR_LEN];
68 char *dr_hostname;
69 char *dr_domainname;
70 char *dr_bootfile;
71 char *dr_rootpath;
72 char *dr_swapserver;
73 char *dr_script;
74 char *dr_options;
75 } dhcpreply_t;
78 int dhcp_bootrequest(dhcpreply_t **reply);
79 void dhcp_free_reply(dhcpreply_t *reply);
80 void dhcp_set_envvars(dhcpreply_t *reply);
82 /* *********************************************************************
83 * IP Layer
84 ********************************************************************* */
86 void ip_uninit(void);
87 int ip_init(char *,uint8_t *);
88 ebuf_t *ip_alloc(void);
89 void ip_free(ebuf_t *buf);
90 int ip_send(ebuf_t *buf,uint8_t *destaddr,uint8_t proto);
91 uint16_t ip_chksum(uint16_t initchksum,uint8_t *ptr,int len);
93 /* *********************************************************************
94 * UDP Layer
95 ********************************************************************* */
97 ebuf_t *udp_alloc(void);
98 void udp_free(ebuf_t *buf);
100 int udp_socket(uint16_t port);
101 int udp_bind(int portnum,uint16_t port);
102 int udp_connect(int portnum,uint16_t port);
103 void udp_close(int portnum);
104 int udp_send(int portnum,ebuf_t *buf,uint8_t *dest);
105 ebuf_t *udp_recv_with_timeout(int portnum,int seconds);
106 ebuf_t *udp_recv(int portnum);
108 /* *********************************************************************
109 * TCP Layer
110 ********************************************************************* */
112 #if CFG_TCP
113 #ifndef TCPFLG_NODELAY
114 #define TCPFLG_NODELAY 1 /* disable nagle */
115 #define TCPFLG_NBIO 2 /* non-blocking I/O */
117 #define TCPSTATUS_NOTCONN 0
118 #define TCPSTATUS_CONNECTING 1
119 #define TCPSTATUS_CONNECTED 2
120 #endif
121 int tcp_socket(void);
122 void tcp_destroy(int portnum);
123 int tcp_connect(int s,uint8_t *dest,uint16_t port);
124 int tcp_close(int s);
125 int tcp_send(int s,uint8_t *buf,int len);
126 int tcp_recv(int s,uint8_t *buf,int len);
127 int tcp_bind(int s,uint16_t port);
128 int tcp_peeraddr(int s,uint8_t *addr,uint16_t *port);
129 int tcp_listen(int s,uint16_t port);
130 int tcp_status(int s,int *connflag,int *rxready,int *rxeof);
131 int tcp_debug(int s,int arg);
132 int tcp_setflags(int s,unsigned int flags);
133 int tcp_getflags(int s,unsigned int *flags);
134 #endif
136 /* *********************************************************************
137 * ARP Layer
138 ********************************************************************* */
140 uint8_t *arp_lookup(uint8_t *destip);
141 void arp_add(uint8_t *destip,uint8_t *desthw);
142 int arp_enumerate(int entrynum,uint8_t *ipaddr,uint8_t *hwaddr);
143 int arp_delete(uint8_t *ipaddr);
145 /* *********************************************************************
146 * Network Configuration
147 ********************************************************************* */
149 #ifndef NET_IPADDR
150 #define NET_IPADDR 0
151 #define NET_NETMASK 1
152 #define NET_GATEWAY 2
153 #define NET_NAMESERVER 3
154 #define NET_HWADDR 4
155 #define NET_DOMAIN 5
156 #define NET_HOSTNAME 6
157 #define NET_SPEED 7
158 #define NET_LOOPBACK 8
159 #endif
160 #define NET_DEVNAME 10
162 uint8_t *net_getparam(int param);
163 int net_setparam(int param,uint8_t *ptr);
164 int net_init(char *devname);
165 void net_uninit(void);
166 void net_setnetvars(void);
168 /* *********************************************************************
169 * DNS
170 ********************************************************************* */
172 int dns_lookup(char *hostname,uint8_t *ipaddr);
174 /* *********************************************************************
175 * ICMP
176 ********************************************************************* */
178 int icmp_ping(uint8_t *dest,int seq,int len);
180 /* *********************************************************************
181 * TFTP
182 ********************************************************************* */
184 extern int tftp_max_retries;
185 extern int tftp_rrq_timeout;
186 extern int tftp_recv_timeout;