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

Miscellaneous Library Functions

9.2.4ns_printf()

This function is used to report network statistics.

Syntax

int ns_printf(void *vio, char *format, …)

where:

vio

Is a generic input/output pointer.

format Is a format string like printf().

Is a list of arguments, as described by format.

Return value

Returns one of the following:

chars is the number of characters printed, if successful.

value negative value, if not successful.

Usage

The ns_printf() function is used by the various network statistics printing routines within the stack to report current counter values. The vio argument is a pointer to a GenericIO structure, which can be used to direct output to different streams, such as the debug console or a TELNET socket.

9-10

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

ARM DUI 0144B

Miscellaneous Library Functions

9.2.5panic()

This function is used to indicate a nonrecoverable fault within the system.

Syntax

void panic(char *msg)

where:

msg

Is an informative message indicating the nature of the problem.

Return value

None.

Usage

This function uses dprintf() to print the message string passed, attempts to trap to the debugger using dtrap(), and then halts the system by calling netexit(). You must modify this code if you want your system to restart (warm boot) after such a failure.

ARM DUI 0144B

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

9-11

Miscellaneous Library Functions

9.2.6print_eth()

This function is used to format an Ethernet address as an ASCII string for printing.

Syntax

char *print_eth(char *addr, char spacer)

where:

addr

Points to the 6-byte Ethernet address.

spacer Is the character to be used between each octet.

Return value

Returns a pointer to a statically allocated buffer containing a null-terminated ASCII string that represents the Ethernet address pointed to by addr.

Usage

This function is useful for formatting Ethernet MAC addresses. It returns a pointer to a static buffer containing the MAC address represented as a string of six 2-digit hexadecimal numbers. Each number is separated from the next by the character spacer. The complete string of six numbers is null-terminated. If spacer is passed as \0, no spacing characters are inserted into the output string and the resulting string is 12 characters long. If spacer is nonzero, the resulting string is 17 characters long.

9-12

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

ARM DUI 0144B

Miscellaneous Library Functions

9.2.7print_ipad()

This function is used to format an IP address as an ASCII string for printing.

Syntax

char *print_ipad(unsigned long ipaddr)

where:

ipaddr Is the network address to be printed, in network byte order.

Return value

Returns a pointer to a statically allocated buffer containing a null-terminated ASCII string that represents the Internet address passed in ipaddr.

Usage

This function returns a pointer to a static buffer that contains the dotted quad notation for the IP address passed. The IP address is expected to be in network byte order (big-endian).

9.2.8print_uptime()

This function is used to format a time value as an ASCII string for printing.

Syntax

char *print_uptime(unsigned long timetick)

where:

timetick Is the number of ticks to be translated to an uptime string.

Return value

Returns a pointer to a statically allocated buffer containing a null-terminated ASCII string that represents the time value passed in timetick.

Usage

This function takes a time value, timetick, in centiseconds and returns a pointer to a static buffer containing an uptime string that indicates the number of days, hours, minutes, and seconds represented.

ARM DUI 0144B

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

9-13

Miscellaneous Library Functions

9.2.9std_in()

This function inputs a character from the standard input channel.

Syntax

int std_in(long s)

where:

s

Is the index of the input device (unused by std_in()).

Return value

Returns one of the following:

0

If no character is available from the standard input channel.

char

The character typed, if a character is available.

Usage

The std_in() function is used with a GenericIO structure to allow the menus system to receive input from the standard input channel.

9-14

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

ARM DUI 0144B