aboutsummaryrefslogtreecommitdiffstats
path: root/libglouglou/libglouglou.h
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-06-05 18:14:30 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-06-05 18:14:30 +0200
commit29193b6c4c13d885681c42a87632cf65fbf5b70d (patch)
tree82ec9be903a239eda1f73a1d5b6fef31b6702c07 /libglouglou/libglouglou.h
parentgg_map: fix dependencies description (diff)
downloadglouglou-29193b6c4c13d885681c42a87632cf65fbf5b70d.tar.xz
glouglou-29193b6c4c13d885681c42a87632cf65fbf5b70d.zip
convert to tabs, and fix some indent manualy
no functionnal change
Diffstat (limited to 'libglouglou/libglouglou.h')
-rw-r--r--libglouglou/libglouglou.h175
1 files changed, 88 insertions, 87 deletions
diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h
index b081685..cdb29e7 100644
--- a/libglouglou/libglouglou.h
+++ b/libglouglou/libglouglou.h
@@ -22,22 +22,22 @@
#define GG_PKTDATA_SIZE_FACTOR 20
#define GG_PKTDATA_SIZE_ENCODE(pktsize, size, response) \
- (pktsize = ((size / GG_PKTDATA_SIZE_FACTOR) & 0x7f) | (response << 7))
+ (pktsize = ((size / GG_PKTDATA_SIZE_FACTOR) & 0x7f) | (response << 7))
#define GG_PKTDATA_SIZE_DECODE(pktsize, size, response) { \
- response = pktsize >> 7; size = (pktsize & 0x7f) * GG_PKTDATA_SIZE_FACTOR; \
+ response = pktsize >> 7; size = (pktsize & 0x7f) * GG_PKTDATA_SIZE_FACTOR; \
}
#define PACKET_HEADER_SIZE 2
#define PACKET_TYPE_MIN 0x00
#define PACKET_TYPE_MAX 0x12
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,
- PACKET_EXIT = 0x12,
+ PACKET_NEWCONN = 0x00,
+ PACKET_DELCONN = 0x01,
+ PACKET_DATA = 0x02,
+ PACKET_NAME = 0x03,
+ PACKET_FORK = 0x10,
+ PACKET_EXEC = 0x11,
+ PACKET_EXIT = 0x12,
};
/* XXX is packed needed everywhere ? */
@@ -64,22 +64,22 @@ struct __attribute__((packed)) gg_packet {
u_int8_t len;
u_char fqdn[GG_PKTARG_MAX];
} name;
- struct __attribute__((packed)) fork {
- u_int32_t pid;
- 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;
- struct __attribute__((packed)) exit {
- u_int32_t pid;
- u_int32_t tgid;
- u_int8_t ecode;
- } exit;
+ struct __attribute__((packed)) fork {
+ u_int32_t pid;
+ 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;
+ struct __attribute__((packed)) exit {
+ u_int32_t pid;
+ u_int32_t tgid;
+ u_int8_t ecode;
+ } exit;
} pdat;
#define newconn_id pdat.newconn.id
#define newconn_src pdat.newconn.src
@@ -105,72 +105,73 @@ struct __attribute__((packed)) gg_packet {
};
typedef struct gg_packet_props_t {
- int size;
+ int size;
} gg_packet_props_t;
extern gg_packet_props_t gg_packet_props[];
struct gg_user {
LIST_ENTRY(gg_user) entry;
- int id;
- int sock;
- struct sockaddr_in addr;
- struct sendbuf *sbuf;
+ int id;
+ int sock;
+ struct sockaddr_in addr;
+ struct sendbuf *sbuf;
};
struct gg_server {
- struct event_base *ev_base;
- const char *ip;
- int port;
- struct sockaddr_in addr;
- struct event *ev;
- int sock;
- int (*handle_conn)(struct gg_server *, struct gg_user *);
- int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *);
- void *usrdata;
- LIST_HEAD(, gg_user) user_list;
- int user_count;
- int user_id_count;
+ struct event_base *ev_base;
+ const char *ip;
+ int port;
+ struct sockaddr_in addr;
+ struct event *ev;
+ int sock;
+ int (*handle_conn)(struct gg_server *, struct gg_user *);
+ int (*handle_packet)(struct gg_server *,
+ struct gg_user *, struct gg_packet *);
+ void *usrdata;
+ LIST_HEAD(, gg_user) user_list;
+ int user_count;
+ int user_id_count;
};
enum client_status {
- GG_CLIENT_STATUS_CONNECTING = 0,
- GG_CLIENT_STATUS_CONNECTED = 1
+ GG_CLIENT_STATUS_CONNECTING = 0,
+ GG_CLIENT_STATUS_CONNECTED = 1
};
struct gg_client {
- struct event_base *ev_base;
- const char *ip;
- int port;
- struct sockaddr_in addr;
- struct event *ev;
- struct event *ev_timer;
- int sock;
- enum client_status status;
- int (*handle_conn)(struct gg_client *);
- int (*handle_packet)(struct gg_client *, struct gg_packet *);
- void *usrdata;
- struct sendbuf *sbuf;
+ struct event_base *ev_base;
+ const char *ip;
+ int port;
+ struct sockaddr_in addr;
+ struct event *ev;
+ struct event *ev_timer;
+ int sock;
+ enum client_status status;
+ int (*handle_conn)(struct gg_client *);
+ int (*handle_packet)(struct gg_client *, struct gg_packet *);
+ void *usrdata;
+ struct sendbuf *sbuf;
};
-struct gg_server *gg_server_start(struct event_base *, char *, int,
- int (*handle_conn)(struct gg_server *, struct gg_user *),
- int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *),
- void *);
-void gg_server_stop(struct gg_server *);
-int gg_server_send(struct gg_server *, struct gg_packet *, struct gg_user *);
-void gg_server_send_flush(struct gg_server *, struct gg_user *);
-
-struct gg_client *gg_client_connect(struct event_base *, char *, int,
- int (*handle_conn)(struct gg_client *),
- int (*handle_packet)(struct gg_client *, struct gg_packet *),
- void *);
-void gg_client_disconnect(struct gg_client *);
-int gg_client_send(struct gg_client *, struct gg_packet *);
-void gg_client_send_flush(struct gg_client *);
-
-int gg_verbosity_get(void);
-void gg_verbosity_set(int);
+struct gg_server *gg_server_start(struct event_base *, char *, int,
+ int (*handle_conn)(struct gg_server *, struct gg_user *),
+ int (*handle_packet)(struct gg_server *, struct gg_user *, struct gg_packet *),
+ void *);
+void gg_server_stop(struct gg_server *);
+int gg_server_send(struct gg_server *, struct gg_packet *, struct gg_user *);
+void gg_server_send_flush(struct gg_server *, struct gg_user *);
+
+struct gg_client *gg_client_connect(struct event_base *, char *, int,
+ int (*handle_conn)(struct gg_client *),
+ int (*handle_packet)(struct gg_client *, struct gg_packet *),
+ void *);
+void gg_client_disconnect(struct gg_client *);
+int gg_client_send(struct gg_client *, struct gg_packet *);
+void gg_client_send_flush(struct gg_client *);
+
+int gg_verbosity_get(void);
+void gg_verbosity_set(int);
/* utils.c */
@@ -180,23 +181,23 @@ void gg_verbosity_set(int);
#define GGLOG_INFO 1
#define GGLOG_DEBUG 2
-int gg_log_init(char *, int);
-void gg_log_shutdown(void);
-void gg_log_tmp(const char *, ...);
-void gg_log_debug(const char *, ...);
-void gg_log_info(const char *, ...);
-void gg_log_warn(const char *, ...);
+int gg_log_init(char *, int);
+void gg_log_shutdown(void);
+void gg_log_tmp(const char *, ...);
+void gg_log_debug(const char *, ...);
+void gg_log_info(const char *, ...);
+void gg_log_warn(const char *, ...);
#if defined(__OpenBSD__)
void __dead gg_log_fatal(const char *, ...);
#else
-void gg_log_fatal(const char *, ...);
+void gg_log_fatal(const char *, ...);
#endif
-void *xmalloc(size_t);
-void *xcalloc(size_t, size_t);
-void fd_nonblock(int);
-void addrcpy(struct sockaddr_in *, struct sockaddr_in *);
-int addrcmp(struct sockaddr_in *, struct sockaddr_in *);
-void droppriv(char *, int, char *);
+void *xmalloc(size_t);
+void *xcalloc(size_t, size_t);
+void fd_nonblock(int);
+void addrcpy(struct sockaddr_in *, struct sockaddr_in *);
+int addrcmp(struct sockaddr_in *, struct sockaddr_in *);
+void droppriv(char *, int, char *);
#endif /* _LIBGLOUGLOU_H_ */