summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-12-08 11:10:47 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2008-12-08 11:10:47 +0100
commita516e5f8e550a6073aae96491372c45ce340da88 (patch)
treee87a074749efdad9365a83678d74f076a6a95171 /src/network.c
parent1c7352133af433d3d3881bb21e1de0e9e32f5b8c (diff)
downloadconntrack-tools-a516e5f8e550a6073aae96491372c45ce340da88.tar.gz
conntrack-tools-a516e5f8e550a6073aae96491372c45ce340da88.zip
network: remove the netpld header from the messages
This patch simplifies the message format of the replication messages. As a result, we save four bytes. The netpld header was introduced in the early protocol design. Today, it does not have any reason to exist. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/src/network.c b/src/network.c
index ca00881..34992ec 100644
--- a/src/network.c
+++ b/src/network.c
@@ -25,48 +25,40 @@
#include <time.h>
#include <string.h>
+#define NETHDR_ALIGNTO 4
+
static unsigned int seq_set, cur_seq;
-static size_t __do_prepare(struct mcast_sock *m, void *data, size_t len)
+int nethdr_align(int value)
{
- struct nethdr *net = data;
+ return (value + NETHDR_ALIGNTO - 1) & ~(NETHDR_ALIGNTO - 1);
+}
+int nethdr_size(int len)
+{
+ return NETHDR_SIZ + len;
+}
+
+static inline void __nethdr_set(struct nethdr *net, int len, int type)
+{
if (!seq_set) {
seq_set = 1;
cur_seq = time(NULL);
}
- net->version = CONNTRACKD_PROTOCOL_VERSION;
- net->len = len;
- net->seq = cur_seq++;
- HDR_HOST2NETWORK(net);
-
- return len;
+ net->version = CONNTRACKD_PROTOCOL_VERSION;
+ net->type = type;
+ net->len = len;
+ net->seq = cur_seq++;
}
-static size_t __prepare_ctl(struct mcast_sock *m, void *data)
+void nethdr_set(struct nethdr *net, int type)
{
- return __do_prepare(m, data, NETHDR_ACK_SIZ);
+ __nethdr_set(net, NETHDR_SIZ, type);
}
-static size_t __prepare_data(struct mcast_sock *m, void *data)
+void nethdr_set_ack(struct nethdr *net)
{
- struct nethdr *net = (struct nethdr *) data;
- struct netpld *pld = NETHDR_DATA(net);
-
- return __do_prepare(m, data, ntohs(pld->len) + NETPLD_SIZ + NETHDR_SIZ);
-}
-
-size_t prepare_send_netmsg(struct mcast_sock *m, void *data)
-{
- int ret = 0;
- struct nethdr *net = (struct nethdr *) data;
-
- if (IS_DATA(net))
- ret = __prepare_data(m, data);
- else if (IS_CTL(net))
- ret = __prepare_ctl(m, data);
-
- return ret;
+ __nethdr_set(net, NETHDR_ACK_SIZ, 0);
}
static size_t tx_buflenmax;
@@ -129,13 +121,6 @@ ssize_t mcast_buffered_pending_netmsg(struct mcast_sock *m)
return ret;
}
-void build_netmsg(struct nf_conntrack *ct, int query, struct nethdr *net)
-{
- struct netpld *pld = NETHDR_DATA(net);
-
- build_netpld(ct, pld, query);
-}
-
static int local_seq_set = 0;
/* this function only tracks, it does not update the last sequence received */