Skip to content

Commit

Permalink
Merge pull request #625 from cinerea0/master
Browse files Browse the repository at this point in the history
Allow building on systems using musl
  • Loading branch information
gustavo-iniguez-goya authored Feb 19, 2022
2 parents 377b4c8 + a550252 commit f575ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions daemon/netfilter/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (q *Queue) create(queueID uint16) (err error) {
return fmt.Errorf("Error binding to AF_INET protocol family: %v", err)
} else if ret, err := C.nfq_bind_pf(q.h, AF_INET6); err != nil || ret < 0 {
return fmt.Errorf("Error binding to AF_INET6 protocol family: %v", err)
} else if q.qh, err = C.CreateQueue(q.h, C.u_int16_t(queueID), C.u_int32_t(q.idx)); err != nil || q.qh == nil {
} else if q.qh, err = C.CreateQueue(q.h, C.uint16_t(queueID), C.uint32_t(q.idx)); err != nil || q.qh == nil {
q.destroy()
return fmt.Errorf("Error binding to queue: %v", err)
}
Expand All @@ -107,14 +107,14 @@ func (q *Queue) create(queueID uint16) (err error) {
func (q *Queue) setup() (err error) {
var ret C.int

queueSize := C.u_int32_t(NF_DEFAULT_QUEUE_SIZE)
queueSize := C.uint32_t(NF_DEFAULT_QUEUE_SIZE)
bufferSize := C.uint(NF_DEFAULT_PACKET_SIZE)
totSize := C.uint(NF_DEFAULT_QUEUE_SIZE * NF_DEFAULT_PACKET_SIZE)

if ret, err = C.nfq_set_queue_maxlen(q.qh, queueSize); err != nil || ret < 0 {
q.destroy()
return fmt.Errorf("Unable to set max packets in queue: %v", err)
} else if C.nfq_set_mode(q.qh, C.u_int8_t(2), bufferSize) < 0 {
} else if C.nfq_set_mode(q.qh, C.uint8_t(2), bufferSize) < 0 {
q.destroy()
return fmt.Errorf("Unable to set packets copy mode: %v", err)
} else if q.fd, err = C.nfq_fd(q.h); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions daemon/netfilter/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
#include <libnetfilter_queue/libnetfilter_queue.h>

typedef struct {
uint verdict;
uint mark;
uint mark_set;
uint length;
unsigned int verdict;
unsigned int mark;
unsigned int mark_set;
unsigned int length;
unsigned char *data;
} verdictContainer;

static void *get_uid = NULL;

extern void go_callback(int id, unsigned char* data, int len, uint mark, u_int32_t idx, verdictContainer *vc, uint32_t uid);
extern void go_callback(int id, unsigned char* data, int len, unsigned int mark, uint32_t idx, verdictContainer *vc, uint32_t uid);

static uint8_t stop = 0;

Expand Down Expand Up @@ -80,7 +80,7 @@ static int nf_callback(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, struct n
return nfq_set_verdict2(qh, id, vc.verdict, vc.mark, vc.length, vc.data);
}

static inline struct nfq_q_handle* CreateQueue(struct nfq_handle *h, u_int16_t queue, u_int32_t idx) {
static inline struct nfq_q_handle* CreateQueue(struct nfq_handle *h, uint16_t queue, uint32_t idx) {
struct nfq_q_handle* qh = nfq_create_queue(h, queue, &nf_callback, (void*)((uintptr_t)idx));
if (qh == NULL){
printf("ERROR: nfq_create_queue() queue not created\n");
Expand Down

0 comments on commit f575ba0

Please sign in to comment.