[ab0c689] | 1 | @c |
---|
| 2 | @c Written by Eric Norum |
---|
| 3 | @c |
---|
[6449498] | 4 | @c COPYRIGHT (c) 1988-2002. |
---|
[ab0c689] | 5 | @c On-Line Applications Research Corporation (OAR). |
---|
| 6 | @c All rights reserved. |
---|
| 7 | @c |
---|
| 8 | @c $Id$ |
---|
| 9 | @c |
---|
| 10 | |
---|
[071536e] | 11 | @chapter Using Networking in an RTEMS Application |
---|
[ab0c689] | 12 | |
---|
| 13 | @section Makefile changes |
---|
| 14 | @subsection Including the required managers |
---|
[4b8bf95] | 15 | The FreeBSD networking code requires several RTEMS managers |
---|
[ab0c689] | 16 | in the application: |
---|
| 17 | |
---|
| 18 | @example |
---|
| 19 | MANAGERS = io event semaphore |
---|
| 20 | @end example |
---|
| 21 | |
---|
| 22 | @subsection Increasing the size of the heap |
---|
| 23 | The networking tasks allocate a lot of memory. For most applications |
---|
| 24 | the heap should be at least 256 kbytes. |
---|
| 25 | The amount of memory set aside for the heap can be adjusted by setting |
---|
| 26 | the @code{CFLAGS_LD} definition as shown below: |
---|
| 27 | |
---|
| 28 | @example |
---|
| 29 | CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0x80000 |
---|
| 30 | @end example |
---|
| 31 | |
---|
| 32 | This sets aside 512 kbytes of memory for the heap. |
---|
| 33 | |
---|
| 34 | @section System Configuration |
---|
| 35 | |
---|
| 36 | The networking tasks allocate some RTEMS objects. These |
---|
| 37 | must be accounted for in the application configuration table. The following |
---|
| 38 | lists the requirements. |
---|
| 39 | |
---|
| 40 | @table @b |
---|
| 41 | @item TASKS |
---|
| 42 | One network task plus a receive and transmit task for each device. |
---|
| 43 | |
---|
| 44 | @item SEMAPHORES |
---|
| 45 | One network semaphore plus one syslog mutex semaphore if the application uses |
---|
| 46 | openlog/syslog. |
---|
| 47 | |
---|
| 48 | @item EVENTS |
---|
| 49 | The network stack uses @code{RTEMS_EVENT_24} and @code{RTEMS_EVENT_25}. |
---|
| 50 | This has no effect on the application configuration, but |
---|
| 51 | application tasks which call the network functions should not |
---|
| 52 | use these events for other purposes. |
---|
| 53 | |
---|
| 54 | @end table |
---|
| 55 | |
---|
| 56 | @section Initialization |
---|
| 57 | @subsection Additional include files |
---|
| 58 | The source file which declares the network configuration |
---|
| 59 | structures and calls the network initialization function must include |
---|
| 60 | |
---|
| 61 | @example |
---|
[d778b4a] | 62 | #include <rtems/rtems_bsdnet.h> |
---|
[ab0c689] | 63 | @end example |
---|
| 64 | |
---|
[33bbd74] | 65 | @subsection Network Configuration |
---|
[ab0c689] | 66 | The network configuration is specified by declaring |
---|
[33bbd74] | 67 | and initializing the @code{rtems_bsdnet_config} |
---|
[d9de76f] | 68 | structure. |
---|
[ab0c689] | 69 | |
---|
[33bbd74] | 70 | @example |
---|
| 71 | @group |
---|
| 72 | struct rtems_bsdnet_config @{ |
---|
| 73 | /* |
---|
| 74 | * This entry points to the head of the ifconfig chain. |
---|
| 75 | */ |
---|
| 76 | struct rtems_bsdnet_ifconfig *ifconfig; |
---|
| 77 | |
---|
| 78 | /* |
---|
| 79 | * This entry should be rtems_bsdnet_do_bootp if BOOTP |
---|
| 80 | * is being used to configure the network, and NULL |
---|
| 81 | * if BOOTP is not being used. |
---|
| 82 | */ |
---|
| 83 | void (*bootp)(void); |
---|
| 84 | |
---|
| 85 | /* |
---|
| 86 | * The remaining items can be initialized to 0, in |
---|
| 87 | * which case the default value will be used. |
---|
| 88 | */ |
---|
| 89 | rtems_task_priority network_task_priority; /* 100 */ |
---|
| 90 | unsigned long mbuf_bytecount; /* 64 kbytes */ |
---|
| 91 | unsigned long mbuf_cluster_bytecount; /* 128 kbytes */ |
---|
| 92 | char *hostname; /* BOOTP */ |
---|
| 93 | char *domainname; /* BOOTP */ |
---|
| 94 | char *gateway; /* BOOTP */ |
---|
| 95 | char *log_host; /* BOOTP */ |
---|
| 96 | char *name_server[3]; /* BOOTP */ |
---|
| 97 | char *ntp_server[3]; /* BOOTP */ |
---|
| 98 | @}; |
---|
| 99 | @end group |
---|
| 100 | @end example |
---|
| 101 | |
---|
[ab0c689] | 102 | The structure entries are described in the following table. |
---|
[df4eb76e] | 103 | If your application uses BOOTP/DHCP to obtain network configuration |
---|
[ab0c689] | 104 | information and if you are happy with the default values described |
---|
| 105 | below, you need to provide only the first two entries in this structure. |
---|
| 106 | |
---|
| 107 | @table @code |
---|
| 108 | |
---|
| 109 | @item struct rtems_bsdnet_ifconfig *ifconfig |
---|
| 110 | A pointer to the first configuration structure of the first network |
---|
| 111 | device. This structure is described in the following section. |
---|
| 112 | You must provide a value for this entry since there is no default value for it. |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | @item void (*bootp)(void) |
---|
| 116 | This entry should be set to @code{rtems_bsdnet_do_bootp} |
---|
[df4eb76e] | 117 | if your application will use BOOTP/DHCP |
---|
| 118 | to obtain network configuration information. |
---|
[ab0c689] | 119 | It should be set to @code{NULL} |
---|
[df4eb76e] | 120 | if your application does not use BOOTP/DHCP. |
---|
[ab0c689] | 121 | |
---|
| 122 | |
---|
| 123 | @item int network_task_priority |
---|
| 124 | The priority at which the network task and network device |
---|
| 125 | receive and transmit tasks will run. |
---|
| 126 | If a value of 0 is specified the tasks will run at priority 100. |
---|
| 127 | |
---|
| 128 | @item unsigned long mbuf_bytecount |
---|
| 129 | The number of bytes to allocate from the heap for use as mbufs. |
---|
| 130 | If a value of 0 is specified, 64 kbytes will be allocated. |
---|
| 131 | |
---|
| 132 | @item unsigned long mbuf_cluster_bytecount |
---|
| 133 | The number of bytes to allocate from the heap for use as mbuf clusters. |
---|
| 134 | If a value of 0 is specified, 128 kbytes will be allocated. |
---|
| 135 | |
---|
| 136 | @item char *hostname |
---|
| 137 | The host name of the system. |
---|
[a83dd861] | 138 | If this, or any of the following, entries are @code{NULL} the value |
---|
[df4eb76e] | 139 | may be obtained from a BOOTP/DHCP server. |
---|
[ab0c689] | 140 | |
---|
| 141 | @item char *domainname |
---|
| 142 | The name of the Internet domain to which the system belongs. |
---|
| 143 | |
---|
| 144 | @item char *gateway |
---|
| 145 | The Internet host number of the network gateway machine, |
---|
| 146 | specified in `dotted decimal' (@code{129.128.4.1}) form. |
---|
| 147 | |
---|
| 148 | @item char *log_host |
---|
| 149 | The Internet host number of the machine to which @code{syslog} messages |
---|
| 150 | will be sent. |
---|
| 151 | |
---|
[a83dd861] | 152 | @item char *name_server[3] |
---|
| 153 | The Internet host numbers of up to three machines to be used as |
---|
[ab0c689] | 154 | Internet Domain Name Servers. |
---|
| 155 | |
---|
[19e87bbb] | 156 | @item char *ntp_server[3] |
---|
[33bbd74] | 157 | The Internet host numbers of up to three machines to be used as |
---|
| 158 | Network Time Protocol (NTP) Servers. |
---|
| 159 | |
---|
| 160 | @end table |
---|
| 161 | |
---|
| 162 | In addition, the following fields in the @code{rtems_bsdnet_ifconfig} |
---|
| 163 | are of interest. |
---|
| 164 | |
---|
| 165 | @table @b |
---|
| 166 | |
---|
[4b8bf95] | 167 | @item int port |
---|
| 168 | The I/O port number (ex: 0x240) on which the external Ethernet |
---|
| 169 | can be accessed. |
---|
| 170 | |
---|
| 171 | @item int irno |
---|
| 172 | The interrupt number of the external Ethernet controller. |
---|
| 173 | |
---|
| 174 | @item int bpar |
---|
| 175 | The address of the shared memory on the external Ethernet controller. |
---|
| 176 | |
---|
| 177 | |
---|
[ab0c689] | 178 | @end table |
---|
| 179 | |
---|
| 180 | @subsection Network device configuration |
---|
| 181 | Network devices are specified and configured by declaring and initializing a |
---|
[19e87bbb] | 182 | @code{struct rtems_bsdnet_ifconfig} structure for each network device. |
---|
[ab0c689] | 183 | |
---|
| 184 | The structure entries are described in the following table. An application |
---|
| 185 | which uses a single network interface, gets network configuration information |
---|
[df4eb76e] | 186 | from a BOOTP/DHCP server, and uses the default values for all driver |
---|
[ab0c689] | 187 | parameters needs to initialize only the first two entries in the |
---|
| 188 | structure. |
---|
| 189 | |
---|
| 190 | @table @code |
---|
| 191 | @item char *name |
---|
| 192 | The full name of the network device. This name consists of the |
---|
| 193 | driver name and the unit number (e.g. @code{"scc1"}). |
---|
[d9de76f] | 194 | The @code{bsp.h} include file usually defines RTEMS_BSP_NETWORK_DRIVER_NAME as |
---|
| 195 | the name of the primary (or only) network driver. |
---|
[ab0c689] | 196 | |
---|
| 197 | @item int (*attach)(struct rtems_bsdnet_ifconfig *conf) |
---|
| 198 | The address of the driver @code{attach} function. The network |
---|
| 199 | initialization function calls this function to configure the driver and |
---|
| 200 | attach it to the network stack. |
---|
[d9de76f] | 201 | The @code{bsp.h} include file usually defines RTEMS_BSP_NETWORK_DRIVER_ATTACH as |
---|
| 202 | the name of the attach function of the primary (or only) network driver. |
---|
[ab0c689] | 203 | |
---|
| 204 | @item struct rtems_bsdnet_ifconfig *next |
---|
| 205 | A pointer to the network device configuration structure for the next network |
---|
| 206 | interface, or @code{NULL} if this is the configuration structure of the |
---|
| 207 | last network interface. |
---|
| 208 | |
---|
| 209 | @item char *ip_address |
---|
| 210 | The Internet address of the device, |
---|
| 211 | specified in `dotted decimal' (@code{129.128.4.2}) form, or @code{NULL} |
---|
| 212 | if the device configuration information is being obtained from a |
---|
[df4eb76e] | 213 | BOOTP/DHCP server. |
---|
[ab0c689] | 214 | |
---|
| 215 | @item char *ip_netmask |
---|
| 216 | The Internet inetwork mask of the device, |
---|
| 217 | specified in `dotted decimal' (@code{255.255.255.0}) form, or @code{NULL} |
---|
| 218 | if the device configuration information is being obtained from a |
---|
[df4eb76e] | 219 | BOOTP/DHCP server. |
---|
[ab0c689] | 220 | |
---|
| 221 | |
---|
| 222 | @item void *hardware_address |
---|
| 223 | The hardware address of the device, or @code{NULL} if the driver is |
---|
| 224 | to obtain the hardware address in some other way (usually by reading |
---|
| 225 | it from the device or from the bootstrap ROM). |
---|
| 226 | |
---|
| 227 | @item int ignore_broadcast |
---|
| 228 | Zero if the device is to accept broadcast packets, non-zero if the device |
---|
| 229 | is to ignore broadcast packets. |
---|
| 230 | |
---|
| 231 | @item int mtu |
---|
| 232 | The maximum transmission unit of the device, or zero if the driver |
---|
| 233 | is to choose a default value (typically 1500 for Ethernet devices). |
---|
| 234 | |
---|
| 235 | @item int rbuf_count |
---|
| 236 | The number of receive buffers to use, or zero if the driver is to |
---|
| 237 | choose a default value |
---|
| 238 | |
---|
| 239 | @item int xbuf_count |
---|
| 240 | The number of transmit buffers to use, or zero if the driver is to |
---|
| 241 | choose a default value |
---|
| 242 | Keep in mind that some network devices may use 4 or more |
---|
| 243 | transmit descriptors for a single transmit buffer. |
---|
| 244 | |
---|
| 245 | @end table |
---|
| 246 | |
---|
[d9de76f] | 247 | A complete network configuration specification can be as simple as the one |
---|
| 248 | shown in the following example. |
---|
| 249 | This configuration uses a single network interface, gets |
---|
| 250 | network configuration information |
---|
[df4eb76e] | 251 | from a BOOTP/DHCP server, and uses the default values for all driver |
---|
[d9de76f] | 252 | parameters. |
---|
| 253 | |
---|
| 254 | @example |
---|
| 255 | static struct rtems_bsdnet_ifconfig netdriver_config = @{ |
---|
| 256 | RTEMS_BSP_NETWORK_DRIVER_NAME, |
---|
| 257 | RTEMS_BSP_NETWORK_DRIVER_ATTACH |
---|
| 258 | @}; |
---|
| 259 | struct rtems_bsdnet_config rtems_bsdnet_config = @{ |
---|
| 260 | &netdriver_config, |
---|
| 261 | rtems_bsdnet_do_bootp, |
---|
| 262 | @}; |
---|
| 263 | @end example |
---|
| 264 | |
---|
[ab0c689] | 265 | |
---|
| 266 | @subsection Network initialization |
---|
[d7f33012] | 267 | The networking tasks must be started before any network I/O operations |
---|
| 268 | can be performed. This is done by calling: |
---|
| 269 | |
---|
| 270 | |
---|
[ab0c689] | 271 | @example |
---|
| 272 | rtems_bsdnet_initialize_network (); |
---|
| 273 | @end example |
---|
| 274 | |
---|
[a83dd861] | 275 | This function is declared in @code{rtems/rtems_bsdnet.h}. |
---|
[d7f33012] | 276 | t returns 0 on success and -1 on failure with an error code |
---|
| 277 | in @code{errno}. It is not possible to undo the effects of |
---|
| 278 | a partial initialization, though, so the function can be |
---|
| 279 | called only once irregardless of the return code. Consequently, |
---|
| 280 | if the condition for the failure can be corrected, the |
---|
| 281 | system must be reset to permit another network initialization |
---|
| 282 | attempt. |
---|
[a83dd861] | 283 | |
---|
| 284 | |
---|
[ab0c689] | 285 | |
---|
[f3482e3] | 286 | @section Application Programming Interface |
---|
| 287 | |
---|
[ab0c689] | 288 | The RTEMS network package provides almost a complete set of BSD network |
---|
| 289 | services. The network functions work like their BSD counterparts |
---|
| 290 | with the following exceptions: |
---|
| 291 | |
---|
[071536e] | 292 | @itemize @bullet |
---|
[ab0c689] | 293 | @item A given socket can be read or written by only one task at a time. |
---|
[f3482e3] | 294 | |
---|
[0ed9ac7] | 295 | @item The @code{select} function only works for file descriptors associated |
---|
| 296 | with sockets. |
---|
[f3482e3] | 297 | |
---|
[ab0c689] | 298 | @item You must call @code{openlog} before calling any of the @code{syslog} functions. |
---|
[f3482e3] | 299 | |
---|
[ab0c689] | 300 | @item @b{Some of the network functions are not thread-safe.} |
---|
| 301 | For example the following functions return a pointer to a static |
---|
| 302 | buffer which remains valid only until the next call: |
---|
| 303 | |
---|
| 304 | @table @code |
---|
| 305 | @item gethostbyaddr |
---|
| 306 | @item gethostbyname |
---|
| 307 | @item inet_ntoa |
---|
| 308 | (@code{inet_ntop} is thread-safe, though). |
---|
| 309 | @end table |
---|
[f3482e3] | 310 | |
---|
| 311 | @item The RTEMS network package gathers statistics. |
---|
| 312 | |
---|
| 313 | @item Addition of a mechanism to "tap onto" an interface |
---|
| 314 | and monitor every packet received and transmitted. |
---|
| 315 | |
---|
| 316 | @item Addition of @code{SO_SNDWAKEUP} and @code{SO_RCVWAKEUP} socket options. |
---|
| 317 | |
---|
[ab0c689] | 318 | @end itemize |
---|
| 319 | |
---|
[f3482e3] | 320 | Some of the new features are discussed in more detail in the following |
---|
| 321 | sections. |
---|
| 322 | |
---|
[071536e] | 323 | @subsection Network Statistics |
---|
[f3482e3] | 324 | |
---|
| 325 | There are a number of functions to print statistics gathered by |
---|
| 326 | the network stack. |
---|
[a83dd861] | 327 | These function are declared in @code{rtems/rtems_bsdnet.h}. |
---|
[f3482e3] | 328 | |
---|
[ab0c689] | 329 | @table @code |
---|
| 330 | @item rtems_bsdnet_show_if_stats |
---|
| 331 | Display statistics gathered by network interfaces. |
---|
| 332 | |
---|
| 333 | @item rtems_bsdnet_show_ip_stats |
---|
| 334 | Display IP packet statistics. |
---|
| 335 | |
---|
| 336 | @item rtems_bsdnet_show_icmp_stats |
---|
| 337 | Display ICMP packet statistics. |
---|
| 338 | |
---|
| 339 | @item rtems_bsdnet_show_tcp_stats |
---|
| 340 | Display TCP packet statistics. |
---|
| 341 | |
---|
| 342 | @item rtems_bsdnet_show_udp_stats |
---|
| 343 | Display UDP packet statistics. |
---|
| 344 | |
---|
| 345 | @item rtems_bsdnet_show_mbuf_stats |
---|
| 346 | Display mbuf statistics. |
---|
| 347 | |
---|
| 348 | @item rtems_bsdnet_show_inet_routes |
---|
| 349 | Display the routing table. |
---|
| 350 | |
---|
| 351 | @end table |
---|
[cdd26ca2] | 352 | |
---|
[f3482e3] | 353 | @subsection Tapping Into an Interface |
---|
| 354 | |
---|
| 355 | RTEMS add two new ioctls to the BSD networking code: |
---|
[cdd26ca2] | 356 | SIOCSIFTAP and SIOCGIFTAP. These may be used to set and get a |
---|
| 357 | @i{tap function}. The tap function will be called for every |
---|
| 358 | Ethernet packet received by the interface. |
---|
| 359 | |
---|
| 360 | These are called like other interface ioctls, such as SIOCSIFADDR. |
---|
| 361 | When setting the tap function with SIOCSIFTAP, set the ifr_tap field |
---|
| 362 | of the ifreq struct to the tap function. When retrieving the tap |
---|
| 363 | function with SIOCGIFTAP, the current tap function will be returned in |
---|
| 364 | the ifr_tap field. To stop tapping packets, call SIOCSIFTAP with a |
---|
| 365 | ifr_tap field of 0. |
---|
| 366 | |
---|
| 367 | The tap function is called like this: |
---|
| 368 | |
---|
| 369 | @example |
---|
| 370 | int tap (struct ifnet *, struct ether_header *, struct mbuf *) |
---|
| 371 | @end example |
---|
| 372 | |
---|
| 373 | The tap function should return 1 if the packet was fully handled, in |
---|
| 374 | which case the caller will simply discard the mbuf. The tap function |
---|
| 375 | should return 0 if the packet should be passed up to the higher |
---|
| 376 | networking layers. |
---|
| 377 | |
---|
| 378 | The tap function is called with the network semaphore locked. It must |
---|
| 379 | not make any calls on the application levels of the networking level |
---|
| 380 | itself. It is safe to call other non-networking RTEMS functions. |
---|
| 381 | |
---|
[f3482e3] | 382 | @subsection Socket Options |
---|
| 383 | |
---|
| 384 | RTEMS adds two new @code{SOL_SOCKET} level options for @code{setsockopt} and |
---|
| 385 | @code{getsockopt}: @code{SO_SNDWAKEUP} and @code{SO_RCVWAKEUP}. For both, the |
---|
| 386 | option value should point to a sockwakeup structure. The sockwakeup |
---|
| 387 | structure has the following fields: |
---|
| 388 | |
---|
| 389 | @example |
---|
| 390 | @group |
---|
| 391 | void (*sw_pfn) (struct socket *, caddr_t); |
---|
| 392 | caddr_t sw_arg; |
---|
| 393 | @end group |
---|
| 394 | @end example |
---|
| 395 | |
---|
| 396 | These options are used to set a function to be called when there is |
---|
[461caa5c] | 397 | data available from the socket (@code{SO_RCVWAKEUP}) and when there is space |
---|
| 398 | available to accept data written to the socket (@code{SO_SNDWAKEUP}). |
---|
[f3482e3] | 399 | |
---|
[461caa5c] | 400 | If @code{setsockopt} is called with the @code{SO_RCVWAKEUP} option, and the |
---|
[f3482e3] | 401 | @code{sw_pfn} field is not zero, then when there is data |
---|
| 402 | available to be read from |
---|
| 403 | the socket, the function pointed to by the @code{sw_pfn} field will be |
---|
| 404 | called. A pointer to the socket structure will be passed as the first |
---|
[461caa5c] | 405 | argument to the function. The @code{sw_arg} field set by the |
---|
| 406 | @code{SO_RCVWAKEUP} call will be passed as the second argument to the function. |
---|
| 407 | |
---|
| 408 | If @code{setsockopt} is called with the @code{SO_SNDWAKEUP} |
---|
| 409 | function, and the @code{sw_pfn} field is not zero, then when |
---|
| 410 | there is space available to accept data written to the socket, |
---|
| 411 | the function pointed to by the @code{sw_pfn} field |
---|
[f3482e3] | 412 | will be called. The arguments passed to the function will be as with |
---|
| 413 | @code{SO_SNDWAKEUP}. |
---|
| 414 | |
---|
| 415 | When the function is called, the network semaphore will be locked. |
---|
| 416 | The function must be careful not to call any networking functions. It |
---|
| 417 | is OK to call an RTEMS function; for example, it is OK to send an |
---|
| 418 | RTEMS event. |
---|
| 419 | |
---|
| 420 | The purpose of these functions is to permit a more efficient |
---|
| 421 | alternative to the select call when dealing with a large number of |
---|
| 422 | sockets. |
---|
| 423 | |
---|
[aba138b] | 424 | @subsection Adding an IP Alias |
---|
| 425 | |
---|
| 426 | The following code snippet adds an IP alias: |
---|
| 427 | |
---|
| 428 | @example |
---|
| 429 | void addAlias(const char *pName, const char *pAddr, const char *pMask) |
---|
| 430 | @{ |
---|
| 431 | struct ifaliasreq aliasreq; |
---|
| 432 | struct sockaddr_in *in; |
---|
| 433 | |
---|
| 434 | /* initialize alias request */ |
---|
| 435 | memset(&aliasreq, 0, sizeof(aliasreq)); |
---|
| 436 | sprintf(aliasreq.ifra_name, pName); |
---|
| 437 | |
---|
| 438 | /* initialize alias address */ |
---|
| 439 | in = (struct sockaddr_in *)&aliasreq.ifra_addr; |
---|
| 440 | in->sin_family = AF_INET; |
---|
| 441 | in->sin_len = sizeof(aliasreq.ifra_addr); |
---|
| 442 | in->sin_addr.s_addr = inet_addr(pAddr); |
---|
| 443 | |
---|
| 444 | /* initialize alias mask */ |
---|
| 445 | in = (struct sockaddr_in *)&aliasreq.ifra_mask; |
---|
| 446 | in->sin_family = AF_INET; |
---|
| 447 | in->sin_len = sizeof(aliasreq.ifra_mask); |
---|
| 448 | in->sin_addr.s_addr = inet_addr(pMask); |
---|
| 449 | |
---|
| 450 | /* call to setup the alias */ |
---|
| 451 | rtems_bsdnet_ifconfig(pName, SIOCAIFADDR, &aliasreq); |
---|
| 452 | @} |
---|
| 453 | @end example |
---|
| 454 | |
---|
| 455 | Thanks to @uref{mailto:imikes@@poliac.com,Mike Seirs} for this example |
---|
| 456 | code. |
---|
| 457 | |
---|
[33bbd74] | 458 | @subsection Time Synchronization Using NTP |
---|
| 459 | |
---|
| 460 | @example |
---|
| 461 | int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority); |
---|
| 462 | @end example |
---|
| 463 | |
---|
| 464 | If the interval argument is 0 the routine synchronizes the RTEMS time-of-day |
---|
| 465 | clock with the first NTP server in the rtems_bsdnet_ntpserve array and |
---|
| 466 | returns. The priority argument is ignored. |
---|
| 467 | |
---|
| 468 | If the interval argument is greater than 0, the routine also starts an |
---|
| 469 | RTEMS task at the specified priority and polls the NTP server every |
---|
| 470 | `interval' seconds. NOTE: This mode of operation has not yet been |
---|
| 471 | implemented. |
---|
| 472 | |
---|
| 473 | On successful synchronization of the RTEMS time-of-day clock the routine |
---|
| 474 | returns 0. If an error occurs a message is printed and the routine returns -1 |
---|
| 475 | with an error code in errno. |
---|
| 476 | There is no timeout -- if there is no response from an NTP server the |
---|
| 477 | routine will wait forever. |
---|
| 478 | |
---|
| 479 | |
---|
| 480 | |
---|
[f3482e3] | 481 | |
---|