The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pkts.h File Reference
#include "if.h"
#include "request.h"
#include "llist.c"
Include dependency graph for pkts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _PACKED_
 
struct  PACKET
 
struct  _PACKED_
 
struct  pkt_op_table
 
struct  pkt_queue
 

Macros

#define NETSUKUKU_ID   "ntk"
 
#define MAXMSGSZ   65536
 
#define SKT_TCP   1
 
#define SKT_UDP   2
 
#define SKT_BCAST   3
 
#define PKT_BIND_DEV   1 /* Bind the pkt.sk socket to pkt.dev */
 
#define PKT_RECV_TIMEOUT   (1<<1)
 
#define PKT_SEND_TIMEOUT   (1<<2)
 
#define PKT_SET_LOWDELAY   (1<<3)
 
#define PKT_COMPRESSED
 
#define PKT_KEEPALIVE   (1<<5) /* Let the pkt.sk socket be alive */
 
#define PKT_NONBLOCK   (1<<6) /* Socket must not block */
 
#define SEND_ACK   1
 
#define BCAST_PKT
 
#define HOOK_PKT
 
#define ASYNC_REPLY
 
#define ASYNC_REPLIED   (1<<4)
 
#define LOOPBACK_PKT   (1<<5) /* This is a packet destinated to me */
 
#define RESTRICTED_PKT
 
#define COMPRESSED_PKT   (1<<7) /* The whole packet is Z compressed */
 
#define BCAST_TRACER_PKT
 
#define BCAST_TRACER_BBLOCK
 
#define BCAST_TRACER_STARTERS
 
#define QSPN_BNODE_CLOSED
 
#define QSPN_BNODE_OPENED   (1<<4)
 
#define PKT_MAX_MSG_SZ   1048576 /* bytes */
 
#define PKT_COMPRESS_LEVEL   Z_DEFAULT_COMPRESSION
 
#define PKT_COMPRESS_THRESHOLD
 
#define PACKET_SZ(sz)   (sizeof(pkt_hdr)+(sz))
 
#define BRDCAST_SZ(pkt_sz)   (sizeof(brdcast_hdr)+(pkt_sz))
 
#define BRDCAST_HDR_PTR(msg)   ((brdcast_hdr *)(msg))
 
#define PKT_Q_MTX_LOCKED   1 /* We are waiting the reply */
 
#define PKT_Q_PKT_RECEIVED   (1<<1) /* The reply was received */
 
#define PKT_Q_TIMEOUT   (1<<2) /* None replied ._, */
 
#define PKT_Q_CHECK_FROM
 
#define SEND_RQ_ERR   -1
 
#define SEND_RQ_ERR_RQ   -2
 
#define SEND_RQ_ERR_RE   -3
 
#define SEND_RQ_ERR_PORT   -4
 
#define SEND_RQ_ERR_TO   -5
 
#define SEND_RQ_ERR_CONNECT   -6
 
#define SEND_RQ_ERR_SEND   -7
 
#define SEND_RQ_ERR_RECV   -8
 
#define SEND_RQ_ERR_RECVOP   -9
 
#define SEND_RQ_ERR_RECVID   -10
 
#define SEND_RQ_ERR_REPLY   -11
 

Typedefs

typedef struct pkt_queue pkt_queue
 

Functions

void pkts_init (interface *ifs, int ifs_n, int queue_init)
 
void pkt_addfrom (PACKET *pkt, inet_prefix *from)
 
void pkt_addto (PACKET *pkt, inet_prefix *to)
 
void pkt_add_dev (PACKET *pkt, interface *dev, int bind_the_socket)
 
void pkt_addsk (PACKET *pkt, int family, int sk, int sk_type)
 
void pkt_addport (PACKET *pkt, u_short port)
 
void pkt_addflags (PACKET *pkt, int flags)
 
void pkt_addtimeout (PACKET *pkt, u_int timeout, int recv, int send)
 
void pkt_addcompress (PACKET *pkt)
 
void pkt_addlowdelay (PACKET *pkt)
 
void pkt_addnonblock (PACKET *pkt)
 
void pkt_addhdr (PACKET *pkt, pkt_hdr *hdr)
 
void pkt_addmsg (PACKET *pkt, char *msg)
 
void pkt_copy (PACKET *dst, PACKET *src)
 
void pkt_clear (PACKET *pkt)
 
void pkt_free (PACKET *pkt, int close_socket)
 
char * pkt_pack (PACKET *pkt)
 
int pkt_verify_hdr (PACKET pkt)
 
ssize_t pkt_send (PACKET *pkt)
 
ssize_t pkt_recv (PACKET *pkt)
 
int pkt_tcp_connect (inet_prefix *host, short port, interface *dev)
 
void pkt_fill_hdr (pkt_hdr *hdr, u_char flags, int id, u_char op, size_t sz)
 
int send_rq (PACKET *pkt, int pkt_flags, u_char rq, int rq_id, u_char re, int check_ack, PACKET *rpkt)
 
int forward_pkt (PACKET rpkt, inet_prefix to)
 
int pkt_err (PACKET pkt, u_char err, int free_pkt)
 
void add_pkt_op (u_char op, char sk_type, u_short port, int(*exec_f)(PACKET pkt))
 
int pkt_exec (PACKET pkt, int acpt_idx)
 
void pkt_queue_init (void)
 
void pkt_queue_close (void)
 
int pkt_q_wait_recv (int id, inet_prefix *from, PACKET *rpkt, pkt_queue **ret_pq)
 
int pkt_q_add_pkt (PACKET pkt)
 
void pkt_q_del (pkt_queue *pq, int close_socket)
 

Variables

static const int_info pkt_hdr_iinfo
 
static const int_info brdcast_hdr_iinfo = { 1, { 1 }, { sizeof(char)*4 }, { 1 } }
 
struct pkt_op_table pkt_op_tbl [(ACK_NEGATIVE+1)]
 
pkt_queuepkt_q
 
int pkt_q_counter
 

Macro Definition Documentation

#define ASYNC_REPLIED   (1<<4)
#define ASYNC_REPLY
Value:
(1<<3) /* Tells the receiver to reply with a new
connection. The reply pkt will be
handled by the pkt_queue. */
#define BCAST_PKT
Value:
(1<<1) /* In this pkt there is encapsulated a
* broadcast/flood pkt. Woa */
#define BCAST_TRACER_BBLOCK
Value:
(1<<1) /*When set, the tracer pkt carries also
bnodes blocks.*/
#define BCAST_TRACER_PKT
Value:
1 /*When a bcast is marked with this, it
acts as a tracer_pkt ;)*/
#define BCAST_TRACER_STARTERS
Value:
(1<<2) /*Tracer pkt bound to the qspn starter
continual group*/
#define BRDCAST_HDR_PTR (   msg)    ((brdcast_hdr *)(msg))
#define BRDCAST_SZ (   pkt_sz)    (sizeof(brdcast_hdr)+(pkt_sz))
#define COMPRESSED_PKT   (1<<7) /* The whole packet is Z compressed */
#define HOOK_PKT
Value:
(1<<2) /* All the pkts sent while hooking have
* this flag set */
#define LOOPBACK_PKT   (1<<5) /* This is a packet destinated to me */
#define MAXMSGSZ   65536
#define NETSUKUKU_ID   "ntk"
#define PACKET_SZ (   sz)    (sizeof(pkt_hdr)+(sz))
#define PKT_BIND_DEV   1 /* Bind the pkt.sk socket to pkt.dev */
#define PKT_COMPRESS_LEVEL   Z_DEFAULT_COMPRESSION
#define PKT_COMPRESS_THRESHOLD
Value:
1024 /* If the flag PKT_COMPRESSED is set
and hdr.sz > PKT_COMPRESS_THRESHOLD,
then compress the packet */
#define PKT_COMPRESSED
Value:
(1<<4) /* If set the packet will be Z
compressed before being sent */
#define PKT_KEEPALIVE   (1<<5) /* Let the pkt.sk socket be alive */
#define PKT_MAX_MSG_SZ   1048576 /* bytes */
#define PKT_NONBLOCK   (1<<6) /* Socket must not block */
#define PKT_Q_CHECK_FROM
Value:
(1<<3) /* Check the from ip while
receiving the async pkt */
#define PKT_Q_MTX_LOCKED   1 /* We are waiting the reply */
#define PKT_Q_PKT_RECEIVED   (1<<1) /* The reply was received */
#define PKT_Q_TIMEOUT   (1<<2) /* None replied ._, */
#define PKT_RECV_TIMEOUT   (1<<1)
#define PKT_SEND_TIMEOUT   (1<<2)
#define PKT_SET_LOWDELAY   (1<<3)
#define QSPN_BNODE_CLOSED
Value:
(1<<3) /*The last bnode, who forwarded this
qspn pkt has all its links closed.*/
#define QSPN_BNODE_OPENED   (1<<4)
#define RESTRICTED_PKT
Value:
(1<<6) /* Packet sent from a node in restricted
mode */
#define SEND_ACK   1
#define SEND_RQ_ERR   -1
#define SEND_RQ_ERR_CONNECT   -6
#define SEND_RQ_ERR_PORT   -4
#define SEND_RQ_ERR_RE   -3
#define SEND_RQ_ERR_RECV   -8
#define SEND_RQ_ERR_RECVID   -10
#define SEND_RQ_ERR_RECVOP   -9
#define SEND_RQ_ERR_REPLY   -11
#define SEND_RQ_ERR_RQ   -2
#define SEND_RQ_ERR_SEND   -7
#define SEND_RQ_ERR_TO   -5
#define SKT_BCAST   3
#define SKT_TCP   1
#define SKT_UDP   2

Typedef Documentation

typedef struct pkt_queue pkt_queue

Function Documentation

void add_pkt_op ( u_char  op,
char  sk_type,
u_short  port,
int(*)(PACKET pkt)  exec_f 
)

Here is the caller graph for this function:

int forward_pkt ( PACKET  rpkt,
inet_prefix  to 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_add_dev ( PACKET pkt,
interface dev,
int  bind_the_socket 
)

Here is the caller graph for this function:

void pkt_addcompress ( PACKET pkt)

Here is the caller graph for this function:

void pkt_addflags ( PACKET pkt,
int  flags 
)
void pkt_addfrom ( PACKET pkt,
inet_prefix from 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_addhdr ( PACKET pkt,
pkt_hdr *  hdr 
)
void pkt_addlowdelay ( PACKET pkt)

Here is the caller graph for this function:

void pkt_addmsg ( PACKET pkt,
char *  msg 
)
void pkt_addnonblock ( PACKET pkt)

Here is the caller graph for this function:

void pkt_addport ( PACKET pkt,
u_short  port 
)

Here is the caller graph for this function:

void pkt_addsk ( PACKET pkt,
int  family,
int  sk,
int  sk_type 
)

Here is the caller graph for this function:

void pkt_addtimeout ( PACKET pkt,
u_int  timeout,
int  recv,
int  send 
)

Here is the caller graph for this function:

void pkt_addto ( PACKET pkt,
inet_prefix to 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_clear ( PACKET pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_copy ( PACKET dst,
PACKET src 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_err ( PACKET  pkt,
u_char  err,
int  free_pkt 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_exec ( PACKET  pkt,
int  acpt_idx 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_fill_hdr ( pkt_hdr *  hdr,
u_char  flags,
int  id,
u_char  op,
size_t  sz 
)

Here is the caller graph for this function:

void pkt_free ( PACKET pkt,
int  close_socket 
)

Here is the call graph for this function:

Here is the caller graph for this function:

char* pkt_pack ( PACKET pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_q_add_pkt ( PACKET  pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_q_del ( pkt_queue pq,
int  close_socket 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_q_wait_recv ( int  id,
inet_prefix from,
PACKET rpkt,
pkt_queue **  ret_pq 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_queue_close ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void pkt_queue_init ( void  )

Here is the caller graph for this function:

ssize_t pkt_recv ( PACKET pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t pkt_send ( PACKET pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_tcp_connect ( inet_prefix host,
short  port,
interface dev 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int pkt_verify_hdr ( PACKET  pkt)

Here is the caller graph for this function:

void pkts_init ( interface ifs,
int  ifs_n,
int  queue_init 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int send_rq ( PACKET pkt,
int  pkt_flags,
u_char  rq,
int  rq_id,
u_char  re,
int  check_ack,
PACKET rpkt 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const int_info brdcast_hdr_iinfo = { 1, { 1 }, { sizeof(char)*4 }, { 1 } }
static
const int_info pkt_hdr_iinfo
static
Initial value:
= { 3,
{ 1 , 1 , 1 },
{ sizeof(char)*3, sizeof(char)*5+sizeof(int),
sizeof(char)*5+sizeof(int)+sizeof(size_t) },
{ 1, 1, 1 }
}
struct pkt_op_table pkt_op_tbl[ (ACK_NEGATIVE+1) ]
pkt_queue* pkt_q
int pkt_q_counter