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

Miscellaneous Library Functions

9.4parseip.c

The parseip.c file implements only one function, parse_ipad().

9.4.1parseip()

This function is used to parse a string containing a dotted-quad IP address (for example, 192.168.117.43) and return it as an ip_addr value.

Syntax

char *parse_ipad(ip_addr *ipout, unsigned *sbits, char *stringin)

where:

ipout Is a pointer to an ip_addr that will contain the return value.

sbits Is a pointer to a location that will contain the number of subnet bits corresponding to the class of the network address passed.

stringin Is a pointer to the string to be parsed.

Return value

Returns one of the following:

NULL

If successful, that is, if the string passed was fully parsed.

pointer A pointer to a string describing the problem if not successful, that is, if the string passed could not be fully parsed.

Usage

The parse_ipad() function understands that network addresses with zeroes in them may be abbreviated. For example, 127.1 is expanded to the address 127.0.0.1. The parse_ipad() function also fills in the number of subnet bits corresponding to the class of the network address in the location pointed to by sbits. That is, *sbits will be set to 8 if the address is class A, 16 for class B, and 24 for a class C.

9-18

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

ARM DUI 0144B