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

Miscellaneous Library Functions

11.8parseip.c

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

11.8.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 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.

11-28

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B