Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

ipobj.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "ipobj.h"

Go to the source code of this file.

Functions

int ip_familysize (int family)
int ip4_sprintx (char *s, int slen, void *ip4)
int ip6_sprintx (char *s, int slen, void *ip6)
int ip_sprint (char *s, int slen, IPADDRESS *p)
int ip_fprint (FILE *fp, IPADDRESS *p)
static void ip_init (IPADDRESS *p, int family)
IPADDRESSip_new (int family)
void ip_free (IPADDRESS *p)
int ip_family (IPADDRESS *p)
int ip_size (IPADDRESS *p)
int ip_set (IPADDRESS *ia, void *ip, int family)
int ip_get (IPADDRESS *ia, void *ip, int family)
int ip_equal (IPADDRESS *ia, void *ip, int family)
int ip_eq (IPADDRESS *ia, IPADDRESS *ib)
static void ipset_init (IPSET *ipc)
static void ipset6_init (IPSET *ipc)
IPSETipset_new (int family)
IPSETipset_copy (IPSET *ipsp)
void ipset_free (IPSET *ipc)
int ipset_family (IPSET *ipset)
int ipset_add (IPSET *ipc, void *vip, void *vmask, int notflag, int family)
int ipset_contains (IPSET *ipc, void *ip, int family)
int ipset_print (IPSET *ipc)
int ip4_parse (char *ipstr, int network_order, int *not_flag, unsigned *host, unsigned *mask)
int ip4_setparse (IPSET *ipset, char *ipstr)


Function Documentation

int ip4_parse char *  ipstr,
int  network_order,
int *  not_flag,
unsigned *  host,
unsigned *  mask
 

Break an IP4 Address down into its components

Parameters:
ipstr string to parse
use network order for return values (defaults to host order)
not_flag return value if the ip is negated
host ipv4 host argument
mask ipv4 mask argument
Returns:
0 on sucess, else failure parsing the address
Return values:
-3 encountered prematurely
-2 strdup failed
-1 null argument
-4 out of range for CIDR notation

Definition at line 538 of file ipobj.c.

References memcpy, and strstr().

Referenced by ip4_setparse().

int ip4_setparse IPSET ipset,
char *  ipstr
 

Definition at line 687 of file ipobj.c.

References ip4_parse(), ipset_add(), and IPV4_FAMILY.

Referenced by FlowPSParseOption(), and ParseIpList().

int ip4_sprintx char *  s,
int  slen,
void *  ip4
 

Definition at line 43 of file ipobj.c.

References snprintf.

Referenced by ip_sprint(), ipset_print(), and PrintPortscanConf().

int ip6_sprintx char *  s,
int  slen,
void *  ip6
 

Definition at line 60 of file ipobj.c.

References snprintf.

Referenced by ip_sprint(), and ipset_print().

int ip_eq IPADDRESS ia,
IPADDRESS ib
 

Definition at line 226 of file ipobj.c.

References IPADDRESS::family, IPADDRESS::ip, IPV4_FAMILY, IPV4_LEN, IPV6_FAMILY, IPV6_LEN, and memcmp().

int ip_equal IPADDRESS ia,
void *  ip,
int  family
 

Definition at line 206 of file ipobj.c.

References IPADDRESS::family, IPADDRESS::ip, IPV4_FAMILY, IPV4_LEN, IPV6_LEN, and memcmp().

int ip_family IPADDRESS p  ) 
 

Definition at line 157 of file ipobj.c.

References IPADDRESS::family.

int ip_familysize int  family  ) 
 

Definition at line 36 of file ipobj.c.

References IPV4_FAMILY, IPV4_LEN, IPV6_FAMILY, and IPV6_LEN.

Referenced by ip_size().

int ip_fprint FILE *  fp,
IPADDRESS p
 

Definition at line 99 of file ipobj.c.

References ip_sprint().

void ip_free IPADDRESS p  ) 
 

Definition at line 149 of file ipobj.c.

int ip_get IPADDRESS ia,
void *  ip,
int  family
 

Definition at line 189 of file ipobj.c.

References IPADDRESS::family, IPADDRESS::ip, IPV4_FAMILY, IPV4_LEN, IPV6_FAMILY, IPV6_LEN, and memcpy.

static void ip_init IPADDRESS p,
int  family
[static]
 

Definition at line 118 of file ipobj.c.

References IPADDRESS::family.

Referenced by ip_new().

IPADDRESS* ip_new int  family  ) 
 

Definition at line 129 of file ipobj.c.

References ip_init(), IPV4_FAMILY, IPV4_LEN, IPV6_FAMILY, IPV6_LEN, and NULL.

int ip_set IPADDRESS ia,
void *  ip,
int  family
 

Definition at line 173 of file ipobj.c.

References IPADDRESS::family, IPADDRESS::ip, IPV4_FAMILY, IPV4_LEN, IPV6_FAMILY, IPV6_LEN, and memcpy.

int ip_size IPADDRESS p  ) 
 

Definition at line 165 of file ipobj.c.

References IPADDRESS::family, and ip_familysize().

Referenced by MakePortscanPkt().

int ip_sprint char *  s,
int  slen,
IPADDRESS p
 

Definition at line 80 of file ipobj.c.

References IPADDRESS::family, IPADDRESS::ip, ip4_sprintx(), ip6_sprintx(), IPV4_FAMILY, and IPV6_FAMILY.

Referenced by ip_fprint().

static void ipset6_init IPSET ipc  )  [static]
 

Definition at line 280 of file ipobj.c.

References IPSET::cidr_list, IPSET::family, IPV6_FAMILY, and sflist_init().

Referenced by ipset_new().

int ipset_add IPSET ipc,
void *  vip,
void *  vmask,
int  notflag,
int  family
 

Definition at line 362 of file ipobj.c.

References IPSET::cidr_list, IPSET::family, CIDRBLOCK::ip, CIDRBLOCK6::ip, IPV4_FAMILY, IPV6_FAMILY, IPV6_LEN, CIDRBLOCK::mask, CIDRBLOCK6::mask, memcpy, CIDRBLOCK::notflag, CIDRBLOCK6::notflag, sflist_add_head(), and sflist_add_tail().

Referenced by ip4_setparse(), and ipset_copy().

int ipset_contains IPSET ipc,
void *  ip,
int  family
 

Definition at line 410 of file ipobj.c.

References IPSET::cidr_list, IPSET::family, CIDRBLOCK::ip, CIDRBLOCK6::ip, IPV4_FAMILY, IPV6_FAMILY, IPV6_LEN, CIDRBLOCK::mask, CIDRBLOCK6::mask, memcmp(), CIDRBLOCK::notflag, CIDRBLOCK6::notflag, sflist_first(), and sflist_next().

Referenced by flowps_is_ignored_ipv4(), ps_filter_ignore(), ps_ignore_ip(), server_stats_add_ipv4(), server_stats_contains(), and server_stats_hitcount_ipv4().

IPSET* ipset_copy IPSET ipsp  ) 
 

Definition at line 305 of file ipobj.c.

References IPSET::cidr_list, CIDRBLOCK::ip, CIDRBLOCK6::ip, ipset_add(), ipset_family(), ipset_new(), IPV4_FAMILY, CIDRBLOCK::mask, CIDRBLOCK6::mask, CIDRBLOCK::notflag, CIDRBLOCK6::notflag, NULL, sflist_first(), and sflist_next().

Referenced by server_stats_init().

int ipset_family IPSET ipset  ) 
 

Definition at line 354 of file ipobj.c.

References IPSET::family.

Referenced by ipset_copy(), and server_stats_init().

void ipset_free IPSET ipc  ) 
 

Definition at line 346 of file ipobj.c.

References IPSET::cidr_list, and sflist_free().

Referenced by server_stats_destroy().

static void ipset_init IPSET ipc  )  [static]
 

Definition at line 271 of file ipobj.c.

References IPSET::cidr_list, IPSET::family, IPV4_FAMILY, and sflist_init().

Referenced by ipset_new().

IPSET* ipset_new int  family  ) 
 

Definition at line 289 of file ipobj.c.

References ipset6_init(), ipset_init(), and IPV4_FAMILY.

Referenced by FlowPSParseOption(), ipset_copy(), and ParseIpList().

int ipset_print IPSET ipc  ) 
 

Definition at line 470 of file ipobj.c.

References IPSET::cidr_list, IPSET::family, CIDRBLOCK::ip, CIDRBLOCK6::ip, ip4_sprintx(), ip6_sprintx(), IPV4_FAMILY, IPV6_FAMILY, CIDRBLOCK::mask, CIDRBLOCK6::mask, CIDRBLOCK::notflag, CIDRBLOCK6::notflag, sflist_first(), and sflist_next().


Generated on Sun May 14 14:51:26 2006 by  doxygen 1.4.2