summaryrefslogtreecommitdiffstats
path: root/include
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 /include
parent1c7352133af433d3d3881bb21e1de0e9e32f5b8c (diff)
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 'include')
-rw-r--r--include/network.h47
1 files changed, 22 insertions, 25 deletions
diff --git a/include/network.h b/include/network.h
index 1195303..11e65c7 100644
--- a/include/network.h
+++ b/include/network.h
@@ -9,25 +9,34 @@
struct nf_conntrack;
struct nethdr {
- uint8_t version;
+ uint8_t version:4,
+ type:4;
uint8_t flags;
uint16_t len;
uint32_t seq;
};
-#define NETHDR_SIZ sizeof(struct nethdr)
+#define NETHDR_SIZ nethdr_align(sizeof(struct nethdr))
+
+int nethdr_align(int len);
+int nethdr_size(int len);
+void nethdr_set(struct nethdr *net, int type);
+void nethdr_set_ack(struct nethdr *net);
#define NETHDR_DATA(x) \
- (struct netpld *)(((char *)x) + sizeof(struct nethdr))
+ (struct netattr *)(((char *)x) + NETHDR_SIZ)
+#define NETHDR_TAIL(x) \
+ (struct netattr *)(((char *)x) + x->len)
struct nethdr_ack {
- uint8_t version;
+ uint8_t version:4,
+ type:4;
uint8_t flags;
uint16_t len;
uint32_t seq;
uint32_t from;
uint32_t to;
};
-#define NETHDR_ACK_SIZ sizeof(struct nethdr_ack)
+#define NETHDR_ACK_SIZ nethdr_align(sizeof(struct nethdr_ack))
enum {
NET_F_UNUSED = (1 << 0),
@@ -49,17 +58,17 @@ enum {
#define BUILD_NETMSG(ct, query) \
({ \
char __net[4096]; \
- memset(__net, 0, NETHDR_SIZ + NETPLD_SIZ); \
- build_netmsg(ct, query, (struct nethdr *) __net); \
- (struct nethdr *) __net; \
+ struct nethdr *__hdr = (struct nethdr *) __net; \
+ memset(__hdr, 0, NETHDR_SIZ); \
+ nethdr_set(__hdr, query); \
+ build_payload(ct, __hdr); \
+ HDR_HOST2NETWORK(__hdr); \
+ __hdr; \
})
struct us_conntrack;
struct mcast_sock;
-void build_netmsg(struct nf_conntrack *ct, int query, struct nethdr *net);
-size_t prepare_send_netmsg(struct mcast_sock *m, void *data);
-
enum {
SEQ_UNKNOWN,
SEQ_UNSET,
@@ -129,12 +138,6 @@ static inline int between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
return seq3 - seq2 >= seq1 - seq2;
}
-struct netpld {
- uint16_t len;
- uint16_t query;
-};
-#define NETPLD_SIZ sizeof(struct netpld)
-
#define PLD_NETWORK2HOST(x) \
({ \
x->len = ntohs(x->len); \
@@ -158,12 +161,6 @@ struct netattr {
x->nta_attr = ntohs(x->nta_attr); \
})
-#define PLD_DATA(x) \
- (struct netattr *)(((char *)x) + sizeof(struct netpld))
-
-#define PLD_TAIL(x) \
- (struct netattr *)(((char *)x) + sizeof(struct netpld) + x->len)
-
#define NTA_DATA(x) \
(void *)(((char *)x) + sizeof(struct netattr))
@@ -207,8 +204,8 @@ struct nta_attr_natseqadj {
uint32_t repl_seq_offset_after;
};
-void build_netpld(struct nf_conntrack *ct, struct netpld *pld, int query);
+void build_payload(const struct nf_conntrack *ct, struct nethdr *n);
-int parse_netpld(struct nf_conntrack *ct, struct nethdr *net, int *query, size_t remain);
+int parse_payload(struct nf_conntrack *ct, struct nethdr *n, size_t remain);
#endif