Watt-32 tcp/ip  2.2 dev-rel.10
Functions
netaddr.c File Reference

Go to the source code of this file.

Functions

char *W32_CALL _inet_ntoa (char *s, DWORD ip)
 Convert an IP-address 'ip' into a string. More...
 
DWORD W32_CALL _inet_addr (const char *s)
 Convert a string into an IP-address. More...
 
DWORD W32_CALL aton (const char *str)
 Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address. More...
 
DWORD W32_CALL aton_dotless (const char *str)
 Converts `[dotless]' or `dotless' to 32 bit long (host order) More...
 
BOOL W32_CALL isaddr (const char *str)
 Check if 'str' is simply an ip address. More...
 
BOOL W32_CALL isaddr_dotless (const char *str, DWORD *ip)
 Check if 'str' is a dotless ip address. More...
 
char *W32_CALL inet_ntoa (struct in_addr addr)
 
const char * _inet_atoeth (const char *src, eth_address *p_eth)
 Parse string "ether-addr, ip-addr". More...
 
char *W32_CALL inet_ntoa_r (struct in_addr addr, char *buf, int buflen)
 
int W32_CALL inet_aton (const char *name, struct in_addr *addr)
 
u_long W32_CALL inet_addr (const char *addr)
 
u_long W32_CALL inet_network (const char *name)
 
u_long W32_CALL inet_netof (struct in_addr addr)
 Return the network number from an internet address; handles class A/B/C network #'s.
 
u_long W32_CALL inet_lnaof (struct in_addr addr)
 Return the local network address portion of an internet address; handles class A/B/C network number formats only. More...
 
struct in_addr W32_CALL inet_makeaddr (u_long net, u_long host)
 Formulate an Internet address from network + host (with subnet address). More...
 
const char * _inet6_ntoa (const void *ip)
 Convert an IPv6-address 'ip' into a string. More...
 
const ip6_address * _inet6_addr (const char *str)
 Convert a string 'str' into an IPv6-address. More...
 
int W32_CALL ascii2addr (int af, const char *ascii, void *result)
 
char *W32_CALL addr2ascii (int af, const void *addrp, int len, char *buf)
 
BOOL W32_CALL priv_addr (DWORD ip)
 
int mask_len (DWORD mask)
 
static DWORD bit_set (DWORD v)
 
int check_mask (DWORD mask)
 
int check_mask2 (const char *mask)
 

Detailed Description

Provide some more BSD address functions. Gisle Vanem, Oct 12, 1995

inet_network() is Copyright (c) 1983, 1993 The Regents of the University of California. All rights reserved.

ascii2address() and addr2ascii() are Copyright 1996 Massachusetts Institute of Technology

Version
v0.0
Date
Jan 11, 1991
Author
E. Engelke
Version
v0.2
Date
Apr 10, 1995
Author
G. Vanem, function priv_addr()
Version
v0.3
Date
Nov 12, 2003
Author
G. Vanem, some functions moved from now obsolete udp_nds.c.

Definition in file netaddr.c.

Function Documentation

const ip6_address* _inet6_addr ( const char *  str)

Convert a string 'str' into an IPv6-address.

Return values
staticbuffer for address.
NULL'str' isn't a valid IPv6 address.

Definition at line 419 of file netaddr.c.

References inet_pton().

const char* _inet6_ntoa ( const void ip)

Convert an IPv6-address 'ip' into a string.

Return values
staticstring.
Warning
Not reentrant.

Definition at line 401 of file netaddr.c.

References inet_ntop().

DWORD W32_CALL _inet_addr ( const char *  s)

Convert a string into an IP-address.

Return values
addresson host order.
0string isn't a (dotless) address.

Definition at line 69 of file netaddr.c.

References aton(), isaddr(), and isaddr_dotless().

const char* _inet_atoeth ( const char *  src,
eth_address *  p_eth 
)

Parse string "ether-addr, ip-addr".

DOSX == 0: Assumes 'src' contain only legal hex-codes and ':' separators (or '-' too for DOSX). Doesn't waste precious memory using sscanf() if DOSX==0.

Read 'src', dump to ethernet buffer ('*p_eth') and return pointer to "ip-addr".

Definition at line 205 of file netaddr.c.

References atox(), and strltrim().

char* W32_CALL _inet_ntoa ( char *  s,
DWORD  ip 
)

Convert an IP-address 'ip' into a string.

Return values
'p'.
Note
'ip' is on host order. Use 4 buffers in round-robin.

Definition at line 43 of file netaddr.c.

DWORD W32_CALL aton ( const char *  str)

Converts [a.b.c.d] or a.b.c.d to 32 bit IPv4 address.

Return values
0on error (safer than -1)
IPv4address (host order)

Definition at line 86 of file netaddr.c.

DWORD W32_CALL aton_dotless ( const char *  str)

Converts `[dotless]' or `dotless' to 32 bit long (host order)

Return values
0on error (safer than -1)

Definition at line 115 of file netaddr.c.

References isaddr_dotless().

u_long W32_CALL inet_lnaof ( struct in_addr  addr)

Return the local network address portion of an internet address; handles class A/B/C network number formats only.

Note
return value is host-order.

Definition at line 360 of file netaddr.c.

struct in_addr W32_CALL inet_makeaddr ( u_long  net,
u_long  host 
)

Formulate an Internet address from network + host (with subnet address).

Note
'net' is on host-order.

Definition at line 377 of file netaddr.c.

BOOL W32_CALL isaddr ( const char *  str)

Check if 'str' is simply an ip address.

Accepts 'a.b.c.d' or '[a.b.c.d]' forms.

Return values
TRUEif 'str' is an IPv4 address.

Definition at line 128 of file netaddr.c.

BOOL W32_CALL isaddr_dotless ( const char *  str,
DWORD *  ip 
)

Check if 'str' is a dotless ip address.

Accept "[ 0-9\[\]]+". Doesn't accept octal base.

Return values
TRUEif 'str' is a dotless address.

Definition at line 148 of file netaddr.c.

BOOL W32_CALL priv_addr ( DWORD  ip)

Check if 'ip' is a private addresses in the "black-hole range" (ref. RFC-1918):

10.0.0.0 - 10.255.255.255 172.16.0.0 - 172.31.255.255 192.168.0.0 - 192.168.255.255

Todo:
: rewrite using mask_len().

Definition at line 516 of file netaddr.c.

References aton().