summaryrefslogtreecommitdiff
path: root/src/network.c
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>2007-06-13 19:46:11 +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>2007-06-13 19:46:11 +0000
commite6f0851b184123ebf04df45e2f29a59f0cb827eb (patch)
tree173f08d0a5e3c059bec480ba3a4fe9880e7267e1 /src/network.c
parent7e28837a6073600129d2fc06c23c40726ef5976a (diff)
downloadconntrack-tools-e6f0851b184123ebf04df45e2f29a59f0cb827eb.tar.gz
conntrack-tools-e6f0851b184123ebf04df45e2f29a59f0cb827eb.zip
- local requests return EXIT_FAILURE if it can't connect to the daemon
- several cleanups
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/src/network.c b/src/network.c
index a7ce740..37f437e 100644
--- a/src/network.c
+++ b/src/network.c
@@ -19,20 +19,25 @@
#include "conntrackd.h"
#include "network.h"
-#if 0
-#define _TEST_DROP
-#else
-#undef _TEST_DROP
-#endif
-
-static int drop = 0; /* debugging purposes */
static unsigned int seq_set, cur_seq;
static int send_netmsg(struct mcast_sock *m, void *data, unsigned int len)
{
struct nlnetwork *net = data;
+ if (!seq_set) {
+ seq_set = 1;
+ cur_seq = time(NULL);
+ net->flags |= NET_HELLO;
+ }
+
+ net->flags = htons(net->flags);
+ net->seq = htonl(cur_seq++);
+
+#undef _TEST_DROP
#ifdef _TEST_DROP
+ static int drop = 0;
+
if (++drop > 10) {
drop = 0;
printf("dropping resend (seq=%u)\n", ntohl(net->seq));
@@ -48,15 +53,6 @@ int mcast_send_netmsg(struct mcast_sock *m, void *data)
unsigned int len = nlh->nlmsg_len + sizeof(struct nlnetwork);
struct nlnetwork *net = data;
- if (!seq_set) {
- seq_set = 1;
- cur_seq = time(NULL);
- net->flags |= NET_HELLO;
- }
-
- net->flags = htons(net->flags);
- net->seq = htonl(cur_seq++);
-
if (nlh_host2network(nlh) == -1)
return -1;
@@ -71,20 +67,11 @@ int mcast_resend_netmsg(struct mcast_sock *m, void *data)
net->flags = ntohs(net->flags);
- if (!seq_set) {
- seq_set = 1;
- cur_seq = time(NULL);
- net->flags |= NET_HELLO;
- }
-
if (net->flags & NET_NACK || net->flags & NET_ACK)
len = sizeof(struct nlnetwork_ack);
else
len = sizeof(struct nlnetwork) + ntohl(nlh->nlmsg_len);
- net->flags = htons(net->flags);
- net->seq = htonl(cur_seq++);
-
return send_netmsg(m, data, len);
}
@@ -93,12 +80,6 @@ int mcast_send_error(struct mcast_sock *m, void *data)
struct nlnetwork *net = data;
unsigned int len = sizeof(struct nlnetwork);
- if (!seq_set) {
- seq_set = 1;
- cur_seq = time(NULL);
- net->flags |= NET_HELLO;
- }
-
if (net->flags & NET_NACK || net->flags & NET_ACK) {
struct nlnetwork_ack *nack = (struct nlnetwork_ack *) net;
nack->from = htonl(nack->from);
@@ -106,9 +87,6 @@ int mcast_send_error(struct mcast_sock *m, void *data)
len = sizeof(struct nlnetwork_ack);
}
- net->flags = htons(net->flags);
- net->seq = htonl(cur_seq++);
-
return send_netmsg(m, data, len);
}