23a48c7cfe
Addresses are now stored as uchar[16] instead of ulong, with enough room for IPv6. Generic IP functions have been removed from devip.c and replaced by libip, imported from Plan 9. Names and addresses are resolved using either gethostbyname() or getaddrinfo() functions. On Windows, IPv6 name resolution is not enabled, because mingw32 doesn't provide inet_ntop(). R=rsc http://codereview.appspot.com/6408044
39 lines
880 B
C
39 lines
880 B
C
enum
|
|
{
|
|
IPaddrlen= 16,
|
|
IPv4addrlen= 4,
|
|
IPv4off= 12,
|
|
};
|
|
|
|
uchar* defmask(uchar*);
|
|
void maskip(uchar*, uchar*, uchar*);
|
|
int eipfmt(Fmt*);
|
|
int isv4(uchar*);
|
|
vlong parseip(uchar*, char*);
|
|
vlong parseipmask(uchar*, char*);
|
|
char* v4parseip(uchar*, char*);
|
|
char* v4parsecidr(uchar*, uchar*, char*);
|
|
|
|
void hnputv(void*, uvlong);
|
|
void hnputl(void*, uint);
|
|
void hnputs(void*, ushort);
|
|
uvlong nhgetv(void*);
|
|
uint nhgetl(void*);
|
|
ushort nhgets(void*);
|
|
|
|
int v6tov4(uchar*, uchar*);
|
|
void v4tov6(uchar*, uchar*);
|
|
|
|
#define ipcmp(x, y) memcmp(x, y, IPaddrlen)
|
|
#define ipmove(x, y) memmove(x, y, IPaddrlen)
|
|
|
|
extern uchar IPv4bcast[IPaddrlen];
|
|
extern uchar IPv4bcastobs[IPaddrlen];
|
|
extern uchar IPv4allsys[IPaddrlen];
|
|
extern uchar IPv4allrouter[IPaddrlen];
|
|
extern uchar IPnoaddr[IPaddrlen];
|
|
extern uchar v4prefix[IPaddrlen];
|
|
extern uchar IPallbits[IPaddrlen];
|
|
|
|
#define CLASS(p) ((*(uchar*)(p))>>6)
|