summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--include/buffer.h31
-rw-r--r--include/conntrackd.h2
-rw-r--r--include/queue.h31
-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
9 files changed, 85 insertions, 85 deletions
diff --git a/ChangeLog b/ChangeLog
index 34ad928..82072f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@ o minor irrelevant fixes for uncommon error paths and fix several typos
o detach daemon from its terminal (Ben Lenitz <BLentz@channing-bete.com>)
o obsolete `-S' option: Use information provided by the config file
o daemonize conntrackd after initialization
+o rename class `buffer' to `queue' which is what it really implements
version 0.9.5 (2007/07/29)
------------------------------
diff --git a/include/buffer.h b/include/buffer.h
deleted file mode 100644
index cb42f51..0000000
--- a/include/buffer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _BUFFER_H_
-#define _BUFFER_H_
-
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include "linux_list.h"
-
-struct buffer {
- size_t max_size;
- size_t cur_size;
- unsigned int num_elems;
- struct list_head head;
-};
-
-struct buffer_node {
- struct list_head head;
- size_t size;
- char data[0];
-};
-
-struct buffer *buffer_create(size_t max_size);
-void buffer_destroy(struct buffer *b);
-unsigned int buffer_len(struct buffer *b);
-int buffer_add(struct buffer *b, const void *data, size_t size);
-void buffer_del(struct buffer *b, void *data);
-void buffer_iterate(struct buffer *b,
- void *data,
- int (*iterate)(void *data1, void *data2));
-
-#endif
diff --git a/include/conntrackd.h b/include/conntrackd.h
index 116ab9d..a4a91ea 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -87,7 +87,7 @@ struct ct_conf {
unsigned int listen_to_len;
unsigned int flags;
int family; /* protocol family */
- unsigned int resend_buffer_size;/* FTFW protocol */
+ unsigned int resend_queue_size; /* FTFW protocol */
unsigned int window_size;
int cache_write_through;
struct {
diff --git a/include/queue.h b/include/queue.h
new file mode 100644
index 0000000..691138f
--- /dev/null
+++ b/include/queue.h
@@ -0,0 +1,31 @@
+#ifndef _QUEUE_H_
+#define _QUEUE_H_
+
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include "linux_list.h"
+
+struct queue {
+ size_t max_size;
+ size_t cur_size;
+ unsigned int num_elems;
+ struct list_head head;
+};
+
+struct queue_node {
+ struct list_head head;
+ size_t size;
+ char data[0];
+};
+
+struct queue *queue_create(size_t max_size);
+void queue_destroy(struct queue *b);
+unsigned int queue_len(struct queue *b);
+int queue_add(struct queue *b, const void *data, size_t size);
+void queue_del(struct queue *b, void *data);
+void queue_iterate(struct queue *b,
+ void *data,
+ int (*iterate)(void *data1, void *data2));
+
+#endif
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)