All Files Functions Variables Enumerator Macros Groups Pages
Functions
queue.c File Reference

Queue buffer implementation. More...

#include <linux/netfilter_ipv4.h>
#include <linux/kfifo.h>
#include <net/ip.h>
#include "rom.h"

Go to the source code of this file.

Functions

static LIST_HEAD (q_list)
 defines the queue list as struct list_head
 
static struct q_head * get_queue_for_dst (__be32 dst_addr)
 For a given destination dst_addr get_queue_for_dst will return a pointer to its queue head if it exists, otherwise NULL.
 
static struct q_head * create_queue_for_dst (__be32 dst_addr)
 create_queue_for_dst will create a new queue by allocating memory for both the q_head structure and the q_buf FIFO buffer and adding the created struct q_head to q_list
 
int release_queue_for_dst (struct t_id dest)
 release_queue_for_dst will reinject all queued packets for a specific destination and delete the corresponding queue afterwards, if it is not the external queue
 
static void enqueue_packet (struct sk_buff *skb, int(*okfn)(struct sk_buff *), __be32 dst_addr)
 enqueue_packet checks if a queue already exists for a given destination dst_addr. If not a queue is created. Afterwards the packet is added to the queue by adding both pointers for the packet *skb and the next-processing funcition *okfn to the queue FIFO buffer
 
static void check_and_send_rreq (__be32 dst_addr)
 check_and_send_rreq checks if there are already buffered packets for the same destination. If not it initiates a RREQ to user space
 
void queue_packet_handler (struct sk_buff *skb, int(*okfn)(struct sk_buff *), int ext_dest)
 queue_packet_handler is invoked by the route-o-matic netfilter hook for each packet which needs to be queued. It will send out a RREQ message if necessary and enqueue the packet.
 
void dump_queue_list (void)
 dump_queue_list dumps the whole buffer to kernel log
 
int queue_init (void)
 queue_init will initialize the queue list with one shared queue for packets for all non-private destinations (identified by 0.0.0.0)
 
void destroy_queue (void)
 destroy_queue will free the allocated memory for ALL q_head structures and the queue FIFO buffers including the shared non-private queue. All buffered packets will be discarded without reinjecting. If you want to reinject them before you have to do this manually using a QREL message. Call this function for a clean termination of route-o-matic.
 

Detailed Description

Queue buffer implementation.

Authors
Carsten.Vogel | Mohamad.Sbeiti @paser.info

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For further information see file COPYING in the top level directory

This work is part of the secure wireless mesh networks framework, which is currently under development by CNI

The route-o-matic queue format:

q_list: A double-linked list which manages the different packet queues for every destination. The members of this list are q_head structures.

q_head: There is one q_head for every destination address (non-private addresses share one queue for 0.0.0.0). It contains the address and the actual queue q_buf.

q_buf: This is the FIFO buffer which holds pointers to both the queued packets and their next-processing function (okfn).

Definition in file queue.c.

Function Documentation

static void check_and_send_rreq ( __be32  dst_addr)
static

check_and_send_rreq checks if there are already buffered packets for the same destination. If not it initiates a RREQ to user space

Parameters
dst_addrdestination address
Returns
void

Definition at line 252 of file queue.c.

References DEBUG_ROM, get_queue_for_dst(), and send_rom_rreq().

Referenced by queue_packet_handler().

static struct q_head* create_queue_for_dst ( __be32  dst_addr)
staticread

create_queue_for_dst will create a new queue by allocating memory for both the q_head structure and the q_buf FIFO buffer and adding the created struct q_head to q_list

Parameters
dst_addrdestination address
Returns
struct q_head

Definition at line 92 of file queue.c.

References DEBUG_ROM, and QUEUE_SIZE.

Referenced by enqueue_packet(), and queue_init().

static void enqueue_packet ( struct sk_buff *  skb,
int(*)(struct sk_buff *)  okfn,
__be32  dst_addr 
)
static

enqueue_packet checks if a queue already exists for a given destination dst_addr. If not a queue is created. Afterwards the packet is added to the queue by adding both pointers for the packet *skb and the next-processing funcition *okfn to the queue FIFO buffer

Parameters
skbsocket-buffer
okfnokfn
dst_addrdestination address
Returns
...

Definition at line 173 of file queue.c.

References create_queue_for_dst(), and get_queue_for_dst().

Referenced by queue_packet_handler().

static struct q_head* get_queue_for_dst ( __be32  dst_addr)
staticread

For a given destination dst_addr get_queue_for_dst will return a pointer to its queue head if it exists, otherwise NULL.

Parameters
dst_addrdestination address
Returns
pointer to queue or 0

Definition at line 67 of file queue.c.

Referenced by check_and_send_rreq(), and enqueue_packet().

void queue_packet_handler ( struct sk_buff *  skb,
int(*)(struct sk_buff *)  okfn,
int  ext_dest 
)

queue_packet_handler is invoked by the route-o-matic netfilter hook for each packet which needs to be queued. It will send out a RREQ message if necessary and enqueue the packet.

Parameters
*skbsocket buffer
okfnokfn
ext_destext_dest
Returns
void

Definition at line 299 of file queue.c.

References check_and_send_rreq(), and enqueue_packet().

Referenced by hook_func().

int release_queue_for_dst ( struct t_id  dest)

release_queue_for_dst will reinject all queued packets for a specific destination and delete the corresponding queue afterwards, if it is not the external queue

Parameters
destdestination address
Returns
0 or -EINVAL

Definition at line 126 of file queue.c.

Referenced by rom_qrel(), and rom_rtadd().