18 lines
369 B
C
18 lines
369 B
C
|
#include "netfuncs.h"
|
||
|
|
||
|
#include <stdio.h>
|
||
|
|
||
|
unsigned int ip2int(const char *s)
|
||
|
{
|
||
|
int ip[4];
|
||
|
sscanf(s, "%d.%d.%d.%d", ip, ip + 1, ip + 2, ip + 3);
|
||
|
return ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3];
|
||
|
}
|
||
|
|
||
|
static const char *int2ip(unsigned int ip)
|
||
|
{
|
||
|
static char s[16];
|
||
|
sprintf(s, "%d.%d.%d.%d", ip >> 24, ip << 8 >> 24, ip << 16 >> 24, ip << 24 >> 24);
|
||
|
return s;
|
||
|
}
|