netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
libipq.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <libipq/libipq.h>
#include <netinet/in.h>
#include <linux/netfilter.h>
Include dependency graph for libipq.c:

Data Structures

struct  ipq_errmap_t
 

Macros

#define IPQ_MAXERR   IPQ_ERR_PROTOCOL
 

Enumerations

enum  {
  IPQ_ERR_NONE = 0,
  IPQ_ERR_IMPL,
  IPQ_ERR_HANDLE,
  IPQ_ERR_SOCKET,
  IPQ_ERR_BIND,
  IPQ_ERR_BUFFER,
  IPQ_ERR_RECV,
  IPQ_ERR_NLEOF,
  IPQ_ERR_ADDRLEN,
  IPQ_ERR_STRUNC,
  IPQ_ERR_RTRUNC,
  IPQ_ERR_NLRECV,
  IPQ_ERR_SEND,
  IPQ_ERR_SUPP,
  IPQ_ERR_RECVBUF,
  IPQ_ERR_TIMEOUT,
  IPQ_ERR_PROTOCOL
}
 

Functions

struct ipq_handleipq_create_handle (uint32_t flags, uint32_t protocol)
 
int ipq_destroy_handle (struct ipq_handle *h)
 
int ipq_set_mode (const struct ipq_handle *h, uint8_t mode, size_t range)
 
ssize_t ipq_read (const struct ipq_handle *h, unsigned char *buf, size_t len, int timeout)
 
int ipq_message_type (const unsigned char *buf)
 
int ipq_get_msgerr (const unsigned char *buf)
 
ipq_packet_msg_tipq_get_packet (const unsigned char *buf)
 
int ipq_set_verdict (const struct ipq_handle *h, ipq_id_t id, unsigned int verdict, size_t data_len, unsigned char *buf)
 
int ipq_ctl (const struct ipq_handle *h, int request,...)
 
char * ipq_errstr (void)
 
void ipq_perror (const char *s)
 

Variables

struct ipq_errmap_t ipq_errmap []
 

Macro Definition Documentation

#define IPQ_MAXERR   IPQ_ERR_PROTOCOL

Enumeration Type Documentation

anonymous enum
Enumerator
IPQ_ERR_NONE 
IPQ_ERR_IMPL 
IPQ_ERR_HANDLE 
IPQ_ERR_SOCKET 
IPQ_ERR_BIND 
IPQ_ERR_BUFFER 
IPQ_ERR_RECV 
IPQ_ERR_NLEOF 
IPQ_ERR_ADDRLEN 
IPQ_ERR_STRUNC 
IPQ_ERR_RTRUNC 
IPQ_ERR_NLRECV 
IPQ_ERR_SEND 
IPQ_ERR_SUPP 
IPQ_ERR_RECVBUF 
IPQ_ERR_TIMEOUT 
IPQ_ERR_PROTOCOL 

Function Documentation

int ipq_ctl ( const struct ipq_handle h,
int  request,
  ... 
)
int ipq_destroy_handle ( struct ipq_handle h)

References ipq_handle::fd.

char* ipq_errstr ( void  )

Referenced by ipq_perror().

Here is the caller graph for this function:

int ipq_get_msgerr ( const unsigned char *  buf)

References nlmsgerr::error, and NLMSG_DATA.

ipq_packet_msg_t* ipq_get_packet ( const unsigned char *  buf)

References NLMSG_DATA.

int ipq_message_type ( const unsigned char *  buf)
void ipq_perror ( const char *  s)

References ipq_errstr().

Here is the call graph for this function:

ssize_t ipq_read ( const struct ipq_handle h,
unsigned char *  buf,
size_t  len,
int  timeout 
)
int ipq_set_mode ( const struct ipq_handle h,
uint8_t  mode,
size_t  range 
)

Variable Documentation

struct ipq_errmap_t ipq_errmap[]
Initial value:
= {
{ IPQ_ERR_NONE, "Unknown error" },
{ IPQ_ERR_IMPL, "Implementation error" },
{ IPQ_ERR_HANDLE, "Unable to create netlink handle" },
{ IPQ_ERR_SOCKET, "Unable to create netlink socket" },
{ IPQ_ERR_BIND, "Unable to bind netlink socket" },
{ IPQ_ERR_BUFFER, "Unable to allocate buffer" },
{ IPQ_ERR_RECV, "Failed to receive netlink message" },
{ IPQ_ERR_NLEOF, "Received EOF on netlink socket" },
{ IPQ_ERR_ADDRLEN, "Invalid peer address length" },
{ IPQ_ERR_STRUNC, "Sent message truncated" },
{ IPQ_ERR_RTRUNC, "Received message truncated" },
{ IPQ_ERR_NLRECV, "Received error from netlink" },
{ IPQ_ERR_SEND, "Failed to send netlink message" },
{ IPQ_ERR_SUPP, "Operation not supported" },
{ IPQ_ERR_RECVBUF, "Receive buffer size invalid" },
{ IPQ_ERR_TIMEOUT, "Timeout"},
{ IPQ_ERR_PROTOCOL, "Invalid protocol specified" }
}
Definition: libipq.c:52
Definition: libipq.c:47
Definition: libipq.c:54
Definition: libipq.c:59
Definition: libipq.c:55
Definition: libipq.c:53
Definition: libipq.c:48
Definition: libipq.c:61
Definition: libipq.c:49
Definition: libipq.c:58
Definition: libipq.c:46
Definition: libipq.c:51
Definition: libipq.c:45
Definition: libipq.c:60
Definition: libipq.c:57
Definition: libipq.c:50
Definition: libipq.c:56