source: rtems/cpukit/libnetworking/rtems/rtems_bsdnet.h @ b90307a

4.104.114.84.95
Last change on this file since b90307a was 4787739, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/03/05 at 05:35:38

2005-02-03 Ralf Corsepius <ralf.corsepius@…>

PR 755/rtems

  • libnetworking/rtems_glue.c: Rename rtems_bsdnet_nameservers to _rtems_bsdnet_nameservers. Rename rtems_bsdnet_ntpservers to _rtems_bsdnet_ntpservers. Add new rtems_bsdnet_nameservers, rtems_bsdnet_ntpservers as pointers to _rtems_bsdnet_*servers arrays.
  • libnetworking/rtems/rtems_bsdnet_internal.h: Remove rtems_bsdnet_nameserver, rtems_bsdnet_nameserver_count.
  • libnetworking/rtems/rtems_bsdnet.h: Remove rtems_bsdnet_ntpserver, rtems_bsdnet_ntp_count.
  • libnetworking/rtems/bsdnet/servers.h: New.
  • libnetworking/opt_ipsec.h: New (BSD compatibility).
  • libnetworking/Makefile.am: Reflect changes above.
  • Property mode set to 100644
File size: 7.5 KB
Line 
1/**
2 * @file rtems/rtems_bsdnet.h
3 */
4 
5/*
6 *  $Id$
7 */
8
9#ifndef _RTEMS_BSDNET_H
10#define _RTEMS_BSDNET_H
11
12#include <rtems.h>
13
14/*
15 *  If this file is included from inside the Network Stack proper or
16 *  a device driver, then __INSIDE_RTEMS_BSD_TCPIP_STACK__ should be
17 *  defined.  This triggers a number of internally used definitions.
18 */
19
20#if defined(__INSIDE_RTEMS_BSD_TCPIP_STACK__)
21#undef _COMPILING_BSD_KERNEL_
22#undef _KERNEL
23#undef INET
24#undef NFS
25#undef DIAGNOSTIC
26#undef BOOTP_COMPAT
27
28#define _COMPILING_BSD_KERNEL_
29#define _KERNEL
30#define INET
31#define NFS
32#define DIAGNOSTIC
33#define BOOTP_COMPAT
34#endif
35
36/*
37 * Values that may be obtained by BOOTP
38 */
39extern struct in_addr rtems_bsdnet_bootp_server_address;
40extern char *rtems_bsdnet_bootp_server_name;
41extern char *rtems_bsdnet_bootp_boot_file_name;
42extern char *rtems_bsdnet_bootp_cmdline;
43extern long rtems_bsdnet_timeoffset;
44
45/*
46 * Manipulate routing tables
47 */
48struct sockaddr;
49struct rtentry;
50int rtems_bsdnet_rtrequest (
51    int req,
52    struct sockaddr *dst,
53    struct sockaddr *gateway,
54    struct sockaddr *netmask,
55    int flags,
56    struct rtentry **net_nrt);
57
58/*
59 * Diagnostics
60 */
61void rtems_bsdnet_show_inet_routes (void);
62void rtems_bsdnet_show_mbuf_stats (void);
63void rtems_bsdnet_show_if_stats (void);
64void rtems_bsdnet_show_ip_stats (void);
65void rtems_bsdnet_show_icmp_stats (void);
66void rtems_bsdnet_show_udp_stats (void);
67void rtems_bsdnet_show_tcp_stats (void);
68
69/*
70 * Network configuration
71 */
72struct rtems_bsdnet_ifconfig {
73        /*
74         * These three entries must be supplied for each interface.
75         */
76        char            *name;
77
78        /*
79         * This function now handles attaching and detaching an interface.
80         * The parameter attaching indicates the operation being invoked.
81         * For older attach functions which do not have the extra parameter
82         * it will be ignored.
83         */
84        int             (*attach)(struct rtems_bsdnet_ifconfig *conf, int attaching);
85
86        /*
87         * Link to next interface
88         */
89        struct rtems_bsdnet_ifconfig *next;
90
91        /*
92         * The following entries may be obtained
93         * from BOOTP or explicitily supplied.
94         */
95        char            *ip_address;
96        char            *ip_netmask;
97        void            *hardware_address;
98
99        /*
100         * The driver assigns defaults values to the following
101         * entries if they are not explicitly supplied.
102         */
103        int             ignore_broadcast;
104        int             mtu;
105        int             rbuf_count;
106        int             xbuf_count;
107
108        /*
109         * For external ethernet controller board the following
110         * parameters are needed
111         */
112        unsigned int    port;   /* port of the board */
113        unsigned int    irno;   /* irq of the board */
114        unsigned int    bpar;   /* memory of the board */
115
116  /*
117   * Driver control block pointer. Typcially this points to the driver's
118   * controlling structure. You set this when you have the structure allocated
119   * externally to the driver.
120   */
121  void *drv_ctrl;
122
123};
124
125struct rtems_bsdnet_config {
126        /*
127         * This entry points to the head of the ifconfig chain.
128         */
129        struct rtems_bsdnet_ifconfig *ifconfig;
130
131        /*
132         * This entry should be rtems_bsdnet_do_bootp if BOOTP
133         * is being used to configure the network, and NULL
134         * if BOOTP is not being used.
135         */
136        void                    (*bootp)(void);
137
138        /*
139         * The remaining items can be initialized to 0, in
140         * which case the default value will be used.
141         */
142        rtems_task_priority     network_task_priority;  /* 100          */
143        unsigned long           mbuf_bytecount;         /* 64 kbytes    */
144        unsigned long           mbuf_cluster_bytecount; /* 128 kbytes   */
145        char                    *hostname;              /* BOOTP        */
146        char                    *domainname;            /* BOOTP        */
147        char                    *gateway;               /* BOOTP        */
148        char                    *log_host;              /* BOOTP        */
149        char                    *name_server[3];        /* BOOTP        */
150        char                    *ntp_server[3];         /* BOOTP        */
151};
152
153/*
154 * Default global device configuration structure. This is scanned
155 * by the initialize network function. Check the network demo's for
156 * an example of the structure. Like the RTEMS configuration tables,
157 * they are not part of RTEMS but part of your application or bsp
158 * code.
159 */
160extern struct rtems_bsdnet_config rtems_bsdnet_config;
161
162/*
163 * Initialise the BSD stack, attach and `up' interfaces
164 * in the `rtems_bsdnet_config'. RTEMS must already be initialised.
165 */
166int rtems_bsdnet_initialize_network (void);
167
168/*
169 * Dynamic interface control. Drivers must free any resources such as
170 * memory, interrupts, io regions claimed during the `attach' and/or
171 * `up' operations when asked to `detach'.
172 * You must configure the interface after attaching it.
173 */
174void rtems_bsdnet_attach (struct rtems_bsdnet_ifconfig *ifconfig);
175void rtems_bsdnet_detach (struct rtems_bsdnet_ifconfig *ifconfig);
176
177/*
178 * Interface configuration. The commands are listed in `sys/sockio.h'.
179 */
180int rtems_bsdnet_ifconfig (const char *ifname, uint32_t   cmd, void *param);
181
182void rtems_bsdnet_do_bootp (void);
183void rtems_bsdnet_do_bootp_and_rootfs (void);
184
185/* NTP tuning parameters */
186extern int rtems_bsdnet_ntp_retry_count;
187extern int rtems_bsdnet_ntp_timeout_secs;
188extern int rtems_bsdnet_ntp_bcast_timeout_secs;
189
190
191struct timestamp {
192        rtems_unsigned32        integer;
193        rtems_unsigned32        fraction;
194};
195
196/* Data is passed in network byte order */
197struct ntpPacketSmall {
198        rtems_unsigned8         li_vn_mode;
199        rtems_unsigned8         stratum;
200        rtems_signed8           poll_interval;
201        rtems_signed8           precision;
202        rtems_signed32          root_delay;
203        rtems_signed32          root_dispersion;
204        char                    reference_identifier[4];
205        struct timestamp        reference_timestamp;
206        struct timestamp        originate_timestamp;
207        struct timestamp        receive_timestamp;
208        struct timestamp        transmit_timestamp;
209};
210
211/* NOTE: packet data is *only* accessible from the callback
212 *
213 * 'callback' is invoked twice, once prior to sending a request
214 * to the server and one more time after receiving a valid reply.
215 * This allows for the user to measure round-trip times.
216 *
217 * Semantics of the 'state' parameter:
218 *
219 *    state ==  1:  1st call, just prior to sending request. The
220 *                  packet has been set up already but may be
221 *                  modified by the callback (e.g. to set the originate
222 *                  timestamp).
223 *    state == -1:  1st call - no request will be sent but we'll
224 *                  wait for a reply from a broadcast server. The
225 *                  packet has not been set up.
226 *    state ==  0:  2nd call. The user is responsible for keeping track
227 *                  of the 'state' during the first call in order to
228 *                  know if it makes sense to calculate 'round-trip' times.
229 *
230 * RETURN VALUE: the callback should return 0 if processing the packet was
231 *               successful and -1 on error in which case rtems_bsdnet_get_ntp()
232 *                               may try another server.
233 */
234typedef int (*rtems_bsdnet_ntp_callback_t)(
235        struct ntpPacketSmall  *packet,
236        int                     state,
237        void                   *usr_data);
238
239/* Obtain time from a NTP server and call user callback to process data;
240 * socket parameter may be -1 to request the routine to open and close its own socket.
241 * Networking parameters as configured are used...
242 *
243 * It is legal to pass a NULL callback pointer. In this case, a default callback
244 * is used which determines the current time by contacting an NTP server. The current
245 * time is converted to a 'struct timespec' (seconds/nanoseconds) and passed into *usr_data.
246 * The caller is responsible for providing a memory area >= sizeof(struct timespec).
247 *
248 * RETURNS: 0 on success, -1 on failure.
249 */
250int rtems_bsdnet_get_ntp(int socket, rtems_bsdnet_ntp_callback_t callback, void *usr_data);
251
252int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority);
253
254/*
255 * Callback to report BSD malloc starvation.
256 * The default implementation just prints a message but an application
257 * can provide its own version.
258 */
259void rtems_bsdnet_malloc_starvation(void);
260
261#endif /* _RTEMS_BSDNET_H */
Note: See TracBrowser for help on using the repository browser.