KwikNet Low Level Services
K
DAK
165
kn_inet_addr kn_inet_addr
Purpose Convert a Dotted Decimal IP Address to Numeric Form
Used by
n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure
Setup Prototype is in file KN_API.H.
#include "KN_LIB.H"
int kn_inet_addr(const char *sp, struct in_addr *inadrp);
Description Sp is a pointer to a string containing an IPv4 address in dotted decimal
form. The string does not have to be terminated by '\0'. Leading
whitespace before the numbers in the IP address will be ignored. The
separating dot must be the first character after each number.
Hence, "254. 76.2. 1abc" is an acceptable input string.
Inadrp is a pointer to a structure into which the numeric IPv4 address in
net endian form will be stored. The BSD structure in_addr is defined
in Treck header file TRSOCKET.H as follows:
struct in_addr {
u_long s_addr; /* IP address (net endian) */
};
Returns 0 if the string contained a full IP address such as "75.4. 34.12abc".
1, 2 or 3 if the string contained a partial IP address such as "75.4.34",
"75.4" or "75" respectively. In each case, the missing fields are assumed
to be 0. For example "75.4" is assumed to be "75.4.0.0".
The resulting IPv4 address in numeric, net endian form is stored in the
IPv4 address structure at
inadrp->s_addr.
Limited error checking is performed. Parsing stops at the first character
which is not acceptable within an IP address or as soon as four dot
separated values are found.
A value greater than
3 is returned if no numeric values are present. The
value
-1 is returned if any of the decimal values encountered are outside
the range 0 to 255.
Note Unlike its BSD counterpart inet_addr(), this KwikNet procedure uses
structure
in_addr to hold the IP address.
Example See example in the description of
kn_dprintf().
See Also
kn_inet_ntoa()
Comments to this Manuals