summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 15:34:30 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 15:34:30 +0000
commit1c0b4d3721e40586219fb7676e61e6ba19affdd2 (patch)
treede2388c47a825d111501090727ce9a2c7f9acd5a /src
parent18d19a287315b950a6cef6051f8d4e844e37c6ba (diff)
downloadconntrack-tools-1c0b4d3721e40586219fb7676e61e6ba19affdd2.tar.gz
conntrack-tools-1c0b4d3721e40586219fb7676e61e6ba19affdd2.zip
rename class `buffer' to `queue' which is what it really implements
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/queue.c (renamed from src/buffer.c)52
-rw-r--r--src/read_config_yy.y10
-rw-r--r--src/sync-ftfw.c40
-rw-r--r--src/sync-mode.c1
5 files changed, 52 insertions, 53 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1fac3dc..62a7467 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,7 +10,7 @@ conntrack_SOURCES = conntrack.c
conntrack_LDADD = ../extensions/libct_proto_tcp.la ../extensions/libct_proto_udp.la ../extensions/libct_proto_icmp.la
conntrack_LDFLAGS = $(all_libraries) @LIBNETFILTER_CONNTRACK_LIBS@
-conntrackd_SOURCES = alarm.c main.c run.c hash.c buffer.c \
+conntrackd_SOURCES = alarm.c main.c run.c hash.c queue.c \
local.c log.c mcast.c netlink.c \
ignore_pool.c \
cache.c cache_iterators.c \
diff --git a/src/buffer.c b/src/queue.c
index 23f7797..3413013 100644
--- a/src/buffer.c
+++ b/src/queue.c
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* 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
@@ -16,16 +16,16 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include "buffer.h"
+#include "queue.h"
-struct buffer *buffer_create(size_t max_size)
+struct queue *queue_create(size_t max_size)
{
- struct buffer *b;
+ struct queue *b;
- b = malloc(sizeof(struct buffer));
+ b = malloc(sizeof(struct queue));
if (b == NULL)
return NULL;
- memset(b, 0, sizeof(struct buffer));
+ memset(b, 0, sizeof(struct queue));
b->max_size = max_size;
INIT_LIST_HEAD(&b->head);
@@ -33,25 +33,25 @@ struct buffer *buffer_create(size_t max_size)
return b;
}
-void buffer_destroy(struct buffer *b)
+void queue_destroy(struct queue *b)
{
struct list_head *i, *tmp;
- struct buffer_node *node;
+ struct queue_node *node;
/* XXX: set cur_size and num_elems */
list_for_each_safe(i, tmp, &b->head) {
- node = (struct buffer_node *) i;
+ node = (struct queue_node *) i;
list_del(i);
free(node);
}
free(b);
}
-static struct buffer_node *buffer_node_create(const void *data, size_t size)
+static struct queue_node *queue_node_create(const void *data, size_t size)
{
- struct buffer_node *n;
+ struct queue_node *n;
- n = malloc(sizeof(struct buffer_node) + size);
+ n = malloc(sizeof(struct queue_node) + size);
if (n == NULL)
return NULL;
@@ -62,12 +62,12 @@ static struct buffer_node *buffer_node_create(const void *data, size_t size)
return n;
}
-int buffer_add(struct buffer *b, const void *data, size_t size)
+int queue_add(struct queue *b, const void *data, size_t size)
{
int ret = 0;
- struct buffer_node *n;
+ struct queue_node *n;
- /* does it fit this buffer? */
+ /* does it fit this queue? */
if (size > b->max_size) {
errno = ENOSPC;
ret = -1;
@@ -75,16 +75,16 @@ int buffer_add(struct buffer *b, const void *data, size_t size)
}
retry:
- /* buffer is full: kill the oldest entry */
+ /* queue is full: kill the oldest entry */
if (b->cur_size + size > b->max_size) {
- n = (struct buffer_node *) b->head.prev;
+ n = (struct queue_node *) b->head.prev;
list_del(b->head.prev);
b->cur_size -= n->size;
free(n);
goto retry;
}
- n = buffer_node_create(data, size);
+ n = queue_node_create(data, size);
if (n == NULL) {
ret = -1;
goto err;
@@ -98,9 +98,9 @@ err:
return ret;
}
-void buffer_del(struct buffer *b, void *data)
+void queue_del(struct queue *b, void *data)
{
- struct buffer_node *n = container_of(data, struct buffer_node, data);
+ struct queue_node *n = container_of(data, struct queue_node, data);
list_del(&n->head);
b->cur_size -= n->size;
@@ -108,21 +108,21 @@ void buffer_del(struct buffer *b, void *data)
free(n);
}
-void buffer_iterate(struct buffer *b,
- void *data,
- int (*iterate)(void *data1, void *data2))
+void queue_iterate(struct queue *b,
+ void *data,
+ int (*iterate)(void *data1, void *data2))
{
struct list_head *i, *tmp;
- struct buffer_node *n;
+ struct queue_node *n;
list_for_each_safe(i, tmp, &b->head) {
- n = (struct buffer_node *) i;
+ n = (struct queue_node *) i;
if (iterate(n->data, data))
break;
}
}
-unsigned int buffer_len(struct buffer *b)
+unsigned int queue_len(struct queue *b)
{
return b->num_elems;
}
diff --git a/src/read_config_yy.y b/src/read_config_yy.y
index e2bb4c8..9cb304a 100644
--- a/src/read_config_yy.y
+++ b/src/read_config_yy.y
@@ -406,14 +406,14 @@ sync_mode_alarm_line: refreshtime
sync_mode_ftfw_list:
| sync_mode_ftfw_list sync_mode_ftfw_line;
-sync_mode_ftfw_line: resend_buffer_size
+sync_mode_ftfw_line: resend_queue_size
| timeout
| window_size
;
-resend_buffer_size: T_RESEND_BUFFER_SIZE T_NUMBER
+resend_queue_size: T_RESEND_BUFFER_SIZE T_NUMBER
{
- conf.resend_buffer_size = $2;
+ conf.resend_queue_size = $2;
};
window_size: T_WINDOWSIZE T_NUMBER
@@ -685,8 +685,8 @@ init_config(char *filename)
if (CONFIG(refresh) == 0)
CONFIG(refresh) = 60;
- if (CONFIG(resend_buffer_size) == 0)
- CONFIG(resend_buffer_size) = 262144;
+ if (CONFIG(resend_queue_size) == 0)
+ CONFIG(resend_queue_size) = 262144;
/* create empty pool */
if (!STATE(ignore_pool)) {
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index 2f27fe6..c3b9f61 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -1,5 +1,5 @@
/*
- * (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* 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
@@ -21,7 +21,7 @@
#include "sync.h"
#include "linux_list.h"
#include "us-conntrack.h"
-#include "buffer.h"
+#include "queue.h"
#include "debug.h"
#include "network.h"
#include "alarm.h"
@@ -37,8 +37,8 @@
static LIST_HEAD(rs_list);
static LIST_HEAD(tx_list);
static unsigned int tx_list_len;
-static struct buffer *rs_queue;
-static struct buffer *tx_queue;
+static struct queue *rs_queue;
+static struct queue *tx_queue;
struct cache_ftfw {
struct list_head rs_list;
@@ -72,15 +72,15 @@ static struct cache_extra cache_ftfw_extra = {
static int ftfw_init()
{
- tx_queue = buffer_create(CONFIG(resend_buffer_size));
+ tx_queue = queue_create(CONFIG(resend_queue_size));
if (tx_queue == NULL) {
- dlog(STATE(log), LOG_ERR, "cannot create tx buffer");
+ dlog(STATE(log), LOG_ERR, "cannot create tx queue");
return -1;
}
- rs_queue = buffer_create(CONFIG(resend_buffer_size));
+ rs_queue = queue_create(CONFIG(resend_queue_size));
if (rs_queue == NULL) {
- dlog(STATE(log), LOG_ERR, "cannot create rs buffer");
+ dlog(STATE(log), LOG_ERR, "cannot create rs queue");
return -1;
}
@@ -92,8 +92,8 @@ static int ftfw_init()
static void ftfw_kill()
{
- buffer_destroy(rs_queue);
- buffer_destroy(tx_queue);
+ queue_destroy(rs_queue);
+ queue_destroy(tx_queue);
}
static void tx_queue_add_ctlmsg(u_int32_t flags, u_int32_t from, u_int32_t to)
@@ -104,7 +104,7 @@ static void tx_queue_add_ctlmsg(u_int32_t flags, u_int32_t from, u_int32_t to)
.to = to,
};
- buffer_add(tx_queue, &ack, NETHDR_ACK_SIZ);
+ queue_add(tx_queue, &ack, NETHDR_ACK_SIZ);
}
static int do_cache_to_tx(void *data1, void *data2)
@@ -148,7 +148,7 @@ static int rs_queue_to_tx(void *data1, void *data2)
if (between(net->seq, nack->from, nack->to)) {
dp("rs_queue_to_tx sq: %u fl:%u len:%u\n",
net->seq, net->flags, net->len);
- buffer_add(tx_queue, net, net->len);
+ queue_add(tx_queue, net, net->len);
}
return 0;
}
@@ -159,8 +159,8 @@ static int rs_queue_empty(void *data1, void *data2)
struct nethdr_ack *h = data2;
if (between(net->seq, h->from, h->to)) {
- dp("remove from buffer (seq=%u)\n", net->seq);
- buffer_del(rs_queue, data1);
+ dp("remove from queue (seq=%u)\n", net->seq);
+ queue_del(rs_queue, data1);
}
return 0;
}
@@ -227,7 +227,7 @@ static int ftfw_recv(const struct nethdr *net)
dp("NACK: from seq=%u to seq=%u\n", nack->from, nack->to);
rs_list_to_tx(STATE_SYNC(internal), nack->from, nack->to);
- buffer_iterate(rs_queue, nack, rs_queue_to_tx);
+ queue_iterate(rs_queue, nack, rs_queue_to_tx);
return 1;
} else if (IS_RESYNC(net)) {
dp("RESYNC ALL\n");
@@ -238,7 +238,7 @@ static int ftfw_recv(const struct nethdr *net)
dp("ACK: from seq=%u to seq=%u\n", h->from, h->to);
rs_list_empty(STATE_SYNC(internal), h->from, h->to);
- buffer_iterate(rs_queue, h, rs_queue_empty);
+ queue_iterate(rs_queue, h, rs_queue_empty);
return 1;
} else if (IS_ALIVE(net))
return 1;
@@ -270,7 +270,7 @@ insert:
list_add(&cn->rs_list, &rs_list);
break;
case NFCT_Q_DESTROY:
- buffer_add(rs_queue, net, net->len);
+ queue_add(rs_queue, net, net->len);
break;
}
}
@@ -289,9 +289,9 @@ static int tx_queue_xmit(void *data1, void *data2)
if (IS_DATA(net) || IS_ACK(net) || IS_NACK(net)) {
dp("-> back_to_tx_queue sq: %u fl:%u len:%u\n",
net->seq, net->flags, net->len);
- buffer_add(rs_queue, net, net->len);
+ queue_add(rs_queue, net, net->len);
}
- buffer_del(tx_queue, net);
+ queue_del(tx_queue, net);
return 0;
}
@@ -330,7 +330,7 @@ static void ftfw_run(int step)
struct list_head *i, *tmp;
/* send messages in the tx_queue */
- buffer_iterate(tx_queue, NULL, tx_queue_xmit);
+ queue_iterate(tx_queue, NULL, tx_queue_xmit);
/* send conntracks in the tx_list */
list_for_each_safe(i, tmp, &tx_list) {
diff --git a/src/sync-mode.c b/src/sync-mode.c
index d54e169..a90e529 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -27,7 +27,6 @@
#include <sys/select.h>
#include "sync.h"
#include "network.h"
-#include "buffer.h"
#include "debug.h"
static void do_mcast_handler_step(struct nethdr *net)