aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gg_sniff/gg_sniff.h2
-rw-r--r--gg_sniff/pcap.c30
-rw-r--r--libglouglou/examples/dnsreverse.c4
-rw-r--r--libglouglou/libggnet.c22
-rw-r--r--libglouglou/libggnet.h102
-rw-r--r--libglouglou/libggnet_dns.c2
-rw-r--r--libglouglou/libggnet_dns.h12
-rw-r--r--libglouglou/libglouglou.c34
-rw-r--r--libglouglou/libglouglou.h49
-rw-r--r--libglouglou/sendbuf.c2
-rw-r--r--libglouglou/sendbuf.h12
-rw-r--r--libglouglou/tests/sendrecv.c2
12 files changed, 140 insertions, 133 deletions
diff --git a/gg_sniff/gg_sniff.h b/gg_sniff/gg_sniff.h
index 0b8d85c..01fa468 100644
--- a/gg_sniff/gg_sniff.h
+++ b/gg_sniff/gg_sniff.h
@@ -1,5 +1,5 @@
/* pcap.c */
int ggsniff_pcap_init(struct event_base *, struct gg_client *,
- struct ggnet *, char *, int, char *);
+ struct ggnet *, char *, int, char *);
void ggsniff_pcap_shutdown(void);
diff --git a/gg_sniff/pcap.c b/gg_sniff/pcap.c
index 2e31769..91e76c9 100644
--- a/gg_sniff/pcap.c
+++ b/gg_sniff/pcap.c
@@ -62,25 +62,25 @@ struct _cap_t {
int ptruncated;
};
-static pcap_t *my_pcap_open_live(const char *, int, int, int,
- char *, u_int, u_int);
-static void ip_handle(struct ip *, const u_char *, u_int);
-static void conn_del(struct ggnet_conn *);
-static void ether_handle(struct ether_header *, const u_char *, u_int);
-static pcap_handler lookup_phandler(int);
-static void phandler_ether(u_char *,
- const struct pcap_pkthdr *, const u_char *);
+static pcap_t *my_pcap_open_live(const char *, int, int, int,
+ char *, u_int, u_int);
+static void ip_handle(struct ip *, const u_char *, u_int);
+static void conn_del(struct ggnet_conn *);
+static void ether_handle(struct ether_header *, const u_char *, u_int);
+static pcap_handler lookup_phandler(int);
+static void phandler_ether(u_char *,
+ const struct pcap_pkthdr *, const u_char *);
#if defined(__OpenBSD__)
-static void phandler_loop(u_char *,
- const struct pcap_pkthdr *, const u_char *);
+static void phandler_loop(u_char *,
+ const struct pcap_pkthdr *, const u_char *);
#endif
#if defined(__linux__)
-static void phandler_sll(u_char *,
- const struct pcap_pkthdr *, const u_char *);
+static void phandler_sll(u_char *,
+ const struct pcap_pkthdr *, const u_char *);
#endif
-static void cb_pcap(int, short, void *);
-static void cb_conntimer(int, short, void *);
-static void cb_nodename(struct ggnet *, struct ggnet_node *);
+static void cb_pcap(int, short, void *);
+static void cb_conntimer(int, short, void *);
+static void cb_nodename(struct ggnet *, struct ggnet_node *);
static struct phandler phandlers[] = {
{ phandler_ether, DLT_EN10MB },
diff --git a/libglouglou/examples/dnsreverse.c b/libglouglou/examples/dnsreverse.c
index 99656ca..7a68d64 100644
--- a/libglouglou/examples/dnsreverse.c
+++ b/libglouglou/examples/dnsreverse.c
@@ -9,8 +9,8 @@
static void _cb_dns(struct in_addr *, char *, void *);
struct event_base *_ev_base;
-char *_name = NULL;
-int _answer = 0;
+char *_name = NULL;
+int _answer = 0;
int
main(int argc, char *argv[])
diff --git a/libglouglou/libggnet.c b/libglouglou/libggnet.c
index ab44d9f..832de54 100644
--- a/libglouglou/libggnet.c
+++ b/libglouglou/libggnet.c
@@ -5,16 +5,18 @@
#include "libggnet.h"
#include "libggnet_dns.h"
-static struct ggnet_nodegroup *nodegroup_add(struct ggnet *,
- enum ggnet_grouptype, void *,
- struct ggnet_nodegroup *);
-static void nodegroup_del(struct ggnet *, struct ggnet_nodegroup *);
-static struct ggnet_nodegroup *nodegroup_find(struct ggnet *,
- enum ggnet_grouptype type,
- void *param);
-static void nodegroup_set(struct ggnet *, struct ggnet_node *);
-static void nodegroup_unset(struct ggnet *, struct ggnet_node *);
-static void _cb_dns_reverse(struct in_addr *, char *, void *);
+static struct ggnet_nodegroup *
+ nodegroup_add(struct ggnet *,
+ enum ggnet_grouptype, void *,
+ struct ggnet_nodegroup *);
+static void nodegroup_del(struct ggnet *, struct ggnet_nodegroup *);
+static struct ggnet_nodegroup *
+ nodegroup_find(struct ggnet *,
+ enum ggnet_grouptype type,
+ void *param);
+static void nodegroup_set(struct ggnet *, struct ggnet_node *);
+static void nodegroup_unset(struct ggnet *, struct ggnet_node *);
+static void _cb_dns_reverse(struct in_addr *, char *, void *);
struct ggnet *
ggnet_new(int manage_connid)
diff --git a/libglouglou/libggnet.h b/libglouglou/libggnet.h
index 3caea7c..794639b 100644
--- a/libglouglou/libggnet.h
+++ b/libglouglou/libggnet.h
@@ -32,25 +32,25 @@ enum ggnet_grouptype {
struct ggnet_nodegroup {
LIST_ENTRY(ggnet_nodegroup) entry;
struct ggnet_nodegroup *parent;
- enum ggnet_grouptype type;
+ enum ggnet_grouptype type;
struct in_addr addr;
- char name[GGNET_DNSNAME_MAX];
- int node_count;
- int conn_count;
- int child_groups_count;
- void *usrdata;
+ char name[GGNET_DNSNAME_MAX];
+ int node_count;
+ int conn_count;
+ int child_groups_count;
+ void *usrdata;
};
struct ggnet_node {
LIST_ENTRY(ggnet_node) entry;
struct ggnet *net;
- struct in_addr addr;
- time_t lastseen;
- int used;
- char fqdn[GGNET_DNSNAME_MAX];
- struct ggnet_nodegroup *group; /* XXX for now we support only one group */
- struct ggnet_dns_req *dns_req;
- void *usrdata;
+ struct in_addr addr;
+ time_t lastseen;
+ int used;
+ char fqdn[GGNET_DNSNAME_MAX];
+ struct ggnet_nodegroup *group; /* XXX for now we support only one group */
+ struct ggnet_dns_req *dns_req;
+ void *usrdata;
};
enum ggnet_connstate {
@@ -78,59 +78,59 @@ struct ggnet {
LIST_HEAD(, ggnet_conn) conn_list;
LIST_HEAD(, ggnet_node) node_list;
LIST_HEAD(, ggnet_nodegroup) group_list;
- int conn_count;
- int node_count;
+ int conn_count;
+ int node_count;
u_int16_t conn_freeids[GGNET_CONN_FREEIDS_COUNT];
- int conn_freeids_ptr;
- int manage_connid;
+ int conn_freeids_ptr;
+ int manage_connid;
time_t time;
- int debug;
+ int debug;
/* grouping */
- int use_grouping;
+ int use_grouping;
void (*cb_addgroup)(struct ggnet *, struct ggnet_nodegroup *, struct ggnet_nodegroup *);
void (*cb_delgroup)(struct ggnet *, struct ggnet_nodegroup *);
/* dns */
- int use_dns;
- struct ggnet_dns *ggdns;
+ int use_dns;
+ struct ggnet_dns *ggdns;
void (*cb_nodename)(struct ggnet *, struct ggnet_node *);
};
struct ggnet *ggnet_new(int);
-void ggnet_set_grouping(struct ggnet *, int,
- void (*cb_addgroup)(struct ggnet *,
- struct ggnet_nodegroup *,
- struct ggnet_nodegroup *),
- void (*cb_delgroup)(struct ggnet *,
- struct ggnet_nodegroup *));
-void ggnet_set_dns(struct ggnet *net, int set,
- struct event_base *ev_base,
- void (*cb_nodename)(struct ggnet *,
- struct ggnet_node *));
-void ggnet_debug_set(struct ggnet *, int);
-void ggnet_free(struct ggnet *);
+void ggnet_set_grouping(struct ggnet *, int,
+ void (*cb_addgroup)(struct ggnet *,
+ struct ggnet_nodegroup *,
+ struct ggnet_nodegroup *),
+ void (*cb_delgroup)(struct ggnet *,
+ struct ggnet_nodegroup *));
+void ggnet_set_dns(struct ggnet *net, int set,
+ struct event_base *ev_base,
+ void (*cb_nodename)(struct ggnet *,
+ struct ggnet_node *));
+void ggnet_debug_set(struct ggnet *, int);
+void ggnet_free(struct ggnet *);
struct ggnet_node *ggnet_node_add(struct ggnet *, struct in_addr *);
-void ggnet_node_del(struct ggnet *, struct ggnet_node *);
+void ggnet_node_del(struct ggnet *, struct ggnet_node *);
struct ggnet_node *ggnet_node_find(struct ggnet *, struct in_addr *);
-void *ggnet_node_usrdata_get(struct ggnet_node *);
-void ggnet_node_usrdata_set(struct ggnet_node *, void *);
-struct ggnet_nodegroup *ggnet_node_group_get(struct ggnet_node *);
+void *ggnet_node_usrdata_get(struct ggnet_node *);
+void ggnet_node_usrdata_set(struct ggnet_node *, void *);
+struct ggnet_nodegroup *ggnet_node_group_get(struct ggnet_node *);
struct ggnet_conn *ggnet_conn_add(struct ggnet *, struct in_addr *, int,
- struct in_addr *, int, int, int, int);
-void ggnet_conn_data(struct ggnet *, struct ggnet_conn *,
- int, int);
-void ggnet_conn_del(struct ggnet *, struct ggnet_conn *);
+ struct in_addr *, int, int, int, int);
+void ggnet_conn_data(struct ggnet *, struct ggnet_conn *,
+ int, int);
+void ggnet_conn_del(struct ggnet *, struct ggnet_conn *);
struct ggnet_conn *ggnet_conn_find(struct ggnet *, struct in_addr *, int,
- struct in_addr *, int, int, int *);
+ struct in_addr *, int, int, int *);
struct ggnet_conn *ggnet_conn_find_by_id(struct ggnet *, int);
struct ggnet_conn *ggnet_conn_find_by_node(struct ggnet *,
- struct ggnet_node *, struct ggnet_node *);
-void *ggnet_conn_usrdata_get(struct ggnet_conn *);
-void ggnet_conn_usrdata_set(struct ggnet_conn *, void *);
-void *ggnet_conn_src_get(struct ggnet_conn *);
-void *ggnet_conn_dst_get(struct ggnet_conn *);
-void *ggnet_nodegroup_usrdata_get(struct ggnet_nodegroup *);
-void ggnet_nodegroup_usrdata_set(struct ggnet_nodegroup *,
- void *);
-void ggnet_time_update(struct ggnet *, time_t);
+ struct ggnet_node *, struct ggnet_node *);
+void *ggnet_conn_usrdata_get(struct ggnet_conn *);
+void ggnet_conn_usrdata_set(struct ggnet_conn *, void *);
+void *ggnet_conn_src_get(struct ggnet_conn *);
+void *ggnet_conn_dst_get(struct ggnet_conn *);
+void *ggnet_nodegroup_usrdata_get(struct ggnet_nodegroup *);
+void ggnet_nodegroup_usrdata_set(struct ggnet_nodegroup *,
+ void *);
+void ggnet_time_update(struct ggnet *, time_t);
#endif /* _LIBGGNET_H_ */
diff --git a/libglouglou/libggnet_dns.c b/libglouglou/libggnet_dns.c
index c59c8a7..c6f8cce 100644
--- a/libglouglou/libggnet_dns.c
+++ b/libglouglou/libggnet_dns.c
@@ -95,7 +95,7 @@ ggnet_dns_cancel(struct ggnet_dns *ggdns, struct ggnet_dns_req *req)
static void
_cb_evdns_reverse(int result, char type, int count,
- int ttl, void *addresses, void *arg)
+ int ttl, void *addresses, void *arg)
{
struct ggnet_dns_req *req;
char **name;
diff --git a/libglouglou/libggnet_dns.h b/libglouglou/libggnet_dns.h
index 9fc716d..e254840 100644
--- a/libglouglou/libggnet_dns.h
+++ b/libglouglou/libggnet_dns.h
@@ -25,10 +25,10 @@ struct ggnet_dns {
LIST_HEAD(, ggnet_dns_req) req_list; /* XXX for now unused. remove ? */
};
-struct ggnet_dns *ggnet_dns_new(struct event_base *);
-void ggnet_dns_free(struct ggnet_dns *);
+struct ggnet_dns *ggnet_dns_new(struct event_base *);
+void ggnet_dns_free(struct ggnet_dns *);
struct ggnet_dns_req *ggnet_dns_reverse(struct ggnet_dns *, struct in_addr *,
- void (*cb_usr)(struct in_addr *, char *, void *),
- void *);
-void ggnet_dns_cancel(struct ggnet_dns *,
- struct ggnet_dns_req *);
+ void (*cb_usr)(struct in_addr *, char *, void *),
+ void *);
+void ggnet_dns_cancel(struct ggnet_dns *,
+ struct ggnet_dns_req *);
diff --git a/libglouglou/libglouglou.c b/libglouglou/libglouglou.c
index 972bb07..f702d2a 100644
--- a/libglouglou/libglouglou.c
+++ b/libglouglou/libglouglou.c
@@ -25,19 +25,19 @@ printf("libgg: %s: " fmt "\n", __func__, ##__VA_ARGS__)
if (_verbosity >= 2) \
printf("libgg: %s: XXX: " fmt "\n", __func__, ##__VA_ARGS__)
-void cb_srv_receive(evutil_socket_t, short, void *);
+void cb_srv_receive(evutil_socket_t, short, void *);
struct gg_user *user_add(struct gg_server *, struct sockaddr_in *);
-void user_del(struct gg_server *, struct gg_user *);
+void user_del(struct gg_server *, struct gg_user *);
struct gg_user *user_find(struct gg_server *, struct sockaddr_in *);
-int user_send(struct gg_user *, void *, int);
-int cb_usr_send(void *, int, void *);
-int client_send(struct gg_client *, void *, int);
-void cb_cli_receive(evutil_socket_t, short, void *);
-void cb_cli_timer(evutil_socket_t, short, void *);
-int cb_cli_send(void *, int, void *);
+int user_send(struct gg_user *, void *, int);
+int cb_usr_send(void *, int, void *);
+int client_send(struct gg_client *, void *, int);
+void cb_cli_receive(evutil_socket_t, short, void *);
+void cb_cli_timer(evutil_socket_t, short, void *);
+int cb_cli_send(void *, int, void *);
struct gg_packet *pkt_decode(char **, int *);
-int pkt_getsize(struct gg_packet *);
-int pkt_encode(struct gg_packet *, struct gg_packet *);
+int pkt_getsize(struct gg_packet *);
+int pkt_encode(struct gg_packet *, struct gg_packet *);
int _verbosity = 0;
@@ -424,14 +424,14 @@ client_send(struct gg_client *cli, void *data, int size)
void
cb_cli_receive(evutil_socket_t fd, short what, void *arg)
{
- struct gg_client *cli;
- struct gg_packet *pkt;
- struct sockaddr_in remote;
+ struct gg_client *cli;
+ struct gg_packet *pkt;
+ struct sockaddr_in remote;
socklen_t remote_len;
- char buf[PACKET_BUFFER_SIZE];
- char *buf_p;
- int buf_len;
- int len;
+ char buf[PACKET_BUFFER_SIZE];
+ char *buf_p;
+ int buf_len;
+ int len;
cli = arg;
remote_len = sizeof(struct sockaddr_in);
diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h
index cdb29e7..5c727b4 100644
--- a/libglouglou/libglouglou.h
+++ b/libglouglou/libglouglou.h
@@ -111,7 +111,7 @@ typedef struct gg_packet_props_t {
extern gg_packet_props_t gg_packet_props[];
struct gg_user {
- LIST_ENTRY(gg_user) entry;
+ LIST_ENTRY(gg_user) entry;
int id;
int sock;
struct sockaddr_in addr;
@@ -121,17 +121,17 @@ struct gg_user {
struct gg_server {
struct event_base *ev_base;
const char *ip;
- int port;
+ int port;
struct sockaddr_in addr;
struct event *ev;
- int sock;
+ 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;
+ void *usrdata;
LIST_HEAD(, gg_user) user_list;
- int user_count;
- int user_id_count;
+ int user_count;
+ int user_id_count;
};
enum client_status {
@@ -155,23 +155,28 @@ struct gg_client {
};
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 *);
+ 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 (*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);
+int gg_verbosity_get(void);
+void gg_verbosity_set(int);
/* utils.c */
@@ -181,7 +186,7 @@ void gg_verbosity_set(int);
#define GGLOG_INFO 1
#define GGLOG_DEBUG 2
-int gg_log_init(char *, int);
+int gg_log_init(char *, int);
void gg_log_shutdown(void);
void gg_log_tmp(const char *, ...);
void gg_log_debug(const char *, ...);
@@ -197,7 +202,7 @@ 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 *);
+int addrcmp(struct sockaddr_in *, struct sockaddr_in *);
void droppriv(char *, int, char *);
#endif /* _LIBGLOUGLOU_H_ */
diff --git a/libglouglou/sendbuf.c b/libglouglou/sendbuf.c
index 47c4fd1..1b8c7a2 100644
--- a/libglouglou/sendbuf.c
+++ b/libglouglou/sendbuf.c
@@ -14,7 +14,7 @@ static void cb_timer(evutil_socket_t, short, void *);
*/
struct sendbuf *
sendbuf_new(struct event_base *ev_base, int buffer_size, int msec_max,
- int (*send_func)(void *, int, void *), void *usrdata)
+ int (*send_func)(void *, int, void *), void *usrdata)
{
struct sendbuf *sbuf = NULL;
struct event *ev_timer;
diff --git a/libglouglou/sendbuf.h b/libglouglou/sendbuf.h
index 7a7bd05..f0a7689 100644
--- a/libglouglou/sendbuf.h
+++ b/libglouglou/sendbuf.h
@@ -16,9 +16,9 @@ struct sendbuf {
};
struct sendbuf *sendbuf_new(struct event_base *, int, int,
- int (*send_func)(void *, int, void *),
- void *);
-void sendbuf_free(struct sendbuf *);
-int sendbuf_append(struct sendbuf *, void *, int);
-void *sendbuf_gettoken(struct sendbuf *, int);
-int sendbuf_flush(struct sendbuf *);
+ int (*send_func)(void *, int, void *),
+ void *);
+void sendbuf_free(struct sendbuf *);
+int sendbuf_append(struct sendbuf *, void *, int);
+void *sendbuf_gettoken(struct sendbuf *, int);
+int sendbuf_flush(struct sendbuf *);
diff --git a/libglouglou/tests/sendrecv.c b/libglouglou/tests/sendrecv.c
index 2df9e01..63ba6e3 100644
--- a/libglouglou/tests/sendrecv.c
+++ b/libglouglou/tests/sendrecv.c
@@ -7,7 +7,7 @@ int cli_recv_ok = 0;
int
srv_handle_packet(struct gg_server *srv,
- struct gg_user *usr, struct gg_packet *pkt)
+ struct gg_user *usr, struct gg_packet *pkt)
{
if (pkt->type == PACKET_NEWCONN)
srv_recv_ok = 1;