aboutsummaryrefslogtreecommitdiffstats
path: root/libglouglou/libglouglou.h
diff options
context:
space:
mode:
Diffstat (limited to 'libglouglou/libglouglou.h')
-rw-r--r--libglouglou/libglouglou.h91
1 files changed, 52 insertions, 39 deletions
diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h
index fc07477..4cac24d 100644
--- a/libglouglou/libglouglou.h
+++ b/libglouglou/libglouglou.h
@@ -14,60 +14,53 @@
#define PACKET_BUFFER_SIZE 16384
#define GG_PKTARG_MAX 30
-struct gg_packet {
#define PACKET_HEADER_SIZE 2
- u_int8_t ver;
- u_int8_t type;
-/* XXX nicer way for _SIZE ... ? */
#define PACKET_TYPE_MIN 0x00
#define PACKET_TYPE_MAX 0x11
-#define PACKET_NEWCONN 0x00
-#define PACKET_NEWCONN_SIZE (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.newconn)
-#define PACKET_DELCONN 0x01
-#define PACKET_DELCONN_SIZE (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.delconn)
-#define PACKET_DATA 0x02
-#define PACKET_DATA_SIZE (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.data)
-#define PACKET_NAME 0x03
-#define PACKET_NAME_SIZE ((PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.name) - GG_PKTARG_MAX)
-#define PACKET_PROC_FORK 0x10
-#define PACKET_PROC_FORK_SIZE (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.proc.ev.fork)
-#define PACKET_PROC_EXEC 0x11
-#define PACKET_PROC_EXEC_SIZE ((PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.proc.ev.exec) - GG_PKTARG_MAX)
+enum gg_packet_type { /* u_int8_t */
+ PACKET_NEWCONN = 0x00,
+ PACKET_DELCONN = 0x01,
+ PACKET_DATA = 0x02,
+ PACKET_NAME = 0x03,
+ PACKET_FORK = 0x10,
+ PACKET_EXEC = 0x11,
+};
+/* XXX is packed needed everywhere ? */
+struct __attribute__((packed)) gg_packet {
+ u_int8_t ver;
+ u_int8_t type;
union {
- struct newconn {
+ struct __attribute__((packed)) newconn {
u_int16_t id;
u_int32_t src;
u_int32_t dst;
u_int8_t proto;
u_int8_t size;
} newconn;
- struct delconn {
+ struct __attribute__((packed)) delconn {
u_int16_t id;
} delconn;
- struct data {
+ struct __attribute__((packed)) data {
u_int16_t connid;
u_int8_t size;
} data;
- struct name {
+ struct __attribute__((packed)) name {
u_int32_t addr;
u_int8_t len;
u_char fqdn[GG_PKTARG_MAX];
} name;
- struct proc {
+ struct __attribute__((packed)) fork {
u_int32_t pid;
- union {
- struct fork {
- u_int32_t ppid;
- u_int32_t cpid;
- u_int32_t tgid;
- } fork;
- struct exec {
- u_int8_t cmdlen;
- u_char cmd[GG_PKTARG_MAX];
- } exec;
- } ev;
- } proc;
+ u_int32_t ppid;
+ u_int32_t cpid;
+ u_int32_t tgid;
+ } fork;
+ struct __attribute__((packed)) exec {
+ u_int32_t pid;
+ u_int8_t cmdlen;
+ u_char cmd[GG_PKTARG_MAX];
+ } exec;
} pdat;
#define newconn_id pdat.newconn.id
#define newconn_src pdat.newconn.src
@@ -80,12 +73,32 @@ struct gg_packet {
#define name_addr pdat.name.addr
#define name_len pdat.name.len
#define name_fqdn pdat.name.fqdn
-#define proc_pid pdat.proc.pid
-#define proc_fork_ppid pdat.proc.ev.fork.ppid
-#define proc_fork_cpid pdat.proc.ev.fork.cpid
-#define proc_fork_tgid pdat.proc.ev.fork.tgid
-#define proc_exec_cmdlen pdat.proc.ev.exec.cmdlen
-#define proc_exec_cmd pdat.proc.ev.exec.cmd
+#define fork_pid pdat.fork.pid
+#define fork_ppid pdat.fork.ppid
+#define fork_cpid pdat.fork.cpid
+#define fork_tgid pdat.fork.tgid
+#define exec_pid pdat.exec.pid
+#define exec_cmdlen pdat.exec.cmdlen
+#define exec_cmd pdat.exec.cmd
+};
+
+typedef struct gg_packet_props_t {
+ int size;
+} gg_packet_props_t;
+
+gg_packet_props_t gg_packet_props[] = {
+ [PACKET_NEWCONN] = \
+ { (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.newconn) },
+ [PACKET_DELCONN] = \
+ { (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.delconn) },
+ [PACKET_DATA] = \
+ { (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.data) },
+ [PACKET_NAME] = \
+ { ((PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.name) - GG_PKTARG_MAX) },
+ [PACKET_FORK] = \
+ { (PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.fork) },
+ [PACKET_EXEC] = \
+ { ((PACKET_HEADER_SIZE + sizeof((struct gg_packet *)0)->pdat.exec) - GG_PKTARG_MAX) },
};
struct gg_user {