Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.6.pdf
Скачиваний:
43
Добавлен:
23.08.2013
Размер:
2.64 Mб
Скачать

Miscellaneous Library Functions

9.6timeouts.c

This file contains a single function, inet_timer(), that you must call at least twice per second if you are using a superloop system. It calls the polling routine for the following protocols:

IP (for fragment reassembly)

TCP

Modem

PPP

DHCP Client

DHCP Server

DNS Client

NAT Router

RIP.

The following code shows a tk_yield() function that uses inet_timer().

/*

**tk_yield() - this is called whenever the program is looping

**waiting for user (or network) input. It handles the various

**background work needed such as polling alarm conditions and

**de-multiplexing incoming packets.

*/

extern void inet_timer(void);

void

 

tk_yield()

 

{

 

#ifdef IN_MENUS

 

kbdio();

/* check for user input for menus */

#endif

 

packet_check();

/* check for newly received packets */

inet_timer();

/* poll all the protocols */

/* give cycles to optional features */

#ifdef PING_APP

 

ping_check();

/* see if ping reply rolled in */

#endif

 

#ifdef SMTP_ALERTS

 

smtpalert_task(); /* email alerter... */ #endif

#ifdef UDPSTEST

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-21

Miscellaneous Library Functions

udp_echo_poll(); /* UDP echo client/server */ #endif

#ifdef TCP_ECHOTEST

tcp_echo_poll(); /* TCP echo client/server */ #endif

}

9-22

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Miscellaneous Library Functions

9.7testmenu.c

This file adds three commands to the diagnostic menus system:

fping

Flood ping.

farp

Flood ARP.

fcount

Set flood count.

These routines allow you to send a large number of ICMP ECHO requests or ARP requests to a target host. The default is for these routines to send 100 requests in quick succession to the current default host. You can change the number of requests using the fcount command, and you can also change the default host using the host command.

Note

Flood ARP must only be used on isolated test networks, as it may disrupt network access for any or all other hosts on the network.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-23