From 4e13c71204e9667cfc4b7da6491972f854d9402d Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 8 May 2016 16:54:12 +0200 Subject: lib: changed port_id to int returning -1 as uint32_t leads to bugs. also changed types in GPB to sint to use zigzag encoding. --- src/ipcpd/flow.c | 2 +- src/ipcpd/flow.h | 4 ++-- src/ipcpd/ipcp-ops.h | 22 +++++++++++----------- src/ipcpd/shim-udp/main.c | 24 ++++++++++++------------ 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/flow.c b/src/ipcpd/flow.c index ae8f848c..10280f3d 100644 --- a/src/ipcpd/flow.c +++ b/src/ipcpd/flow.c @@ -27,7 +27,7 @@ #include -flow_t * flow_create(uint32_t port_id) +flow_t * flow_create(int port_id) { flow_t * flow = malloc(sizeof *flow); if (flow == NULL) { diff --git a/src/ipcpd/flow.h b/src/ipcpd/flow.h index 0a3e90d1..43de5f94 100644 --- a/src/ipcpd/flow.h +++ b/src/ipcpd/flow.h @@ -48,14 +48,14 @@ enum flow_state { typedef struct flow { struct list_head list; - uint32_t port_id; + int port_id; struct shm_ap_rbuff * rb; enum flow_state state; pthread_mutex_t lock; } flow_t; -flow_t * flow_create(uint32_t port_id); +flow_t * flow_create(int port_id); void flow_destroy(flow_t * flow); #endif /* OUROBOROS_FLOW_H */ diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h index 91b6cac9..5e90939d 100644 --- a/src/ipcpd/ipcp-ops.h +++ b/src/ipcpd/ipcp-ops.h @@ -33,21 +33,21 @@ struct ipcp_ops { int (* ipcp_enroll)(char * member_name, char * n_1_dif); int (* ipcp_reg)(char ** dif_names, - size_t len); + size_t len); int (* ipcp_unreg)(char ** dif_names, - size_t len); + size_t len); int (* ipcp_name_reg)(char * name); int (* ipcp_name_unreg)(char * name); - int (* ipcp_flow_alloc)(uint32_t port_id, - pid_t n_pid, - char * dst_ap_name, - char * src_ap_name, - char * src_ae_name, + int (* ipcp_flow_alloc)(int port_id, + pid_t n_pid, + char * dst_ap_name, + char * src_ap_name, + char * src_ae_name, struct qos_spec * qos); - int (* ipcp_flow_alloc_resp)(uint32_t port_id, - pid_t n_pid, - int response); - int (* ipcp_flow_dealloc)(uint32_t port_id); + int (* ipcp_flow_alloc_resp)(int port_id, + pid_t n_pid, + int response); + int (* ipcp_flow_dealloc)(int port_id); }; #endif /* IPCPD_IPCP_OPS_H */ diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 1f7bb12f..bb20b722 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -171,7 +171,7 @@ void shim_ap_fini() free(_ap_instance); } -static int port_id_to_fd(uint32_t port_id) +static int port_id_to_fd(int port_id) { int i; for (i = 0; i < AP_MAX_FLOWS; ++i) @@ -601,7 +601,7 @@ int ipcp_udp_name_unreg(char * name) return 0; } -int ipcp_udp_flow_alloc(uint32_t port_id, +int ipcp_udp_flow_alloc(int port_id, pid_t n_pid, char * dst_name, char * src_ap_name, @@ -712,18 +712,18 @@ int ipcp_udp_flow_alloc(uint32_t port_id, NULL); _ap_instance->ping_pong = !_ap_instance->ping_pong; - LOG_DBG("Allocated flow with port_id %u on UDP fd %d.", port_id, fd); + LOG_DBG("Allocated flow with port_id %d on UDP fd %d.", port_id, fd); return fd; } -int ipcp_udp_flow_alloc_resp(uint32_t port_id, - pid_t n_pid, - int response) +int ipcp_udp_flow_alloc_resp(int port_id, + pid_t n_pid, + int response) { int fd = port_id_to_fd(port_id); if (fd < 0) { - LOG_DBGF("Could not find flow with port_id %u.", port_id); + LOG_DBGF("Could not find flow with port_id %d.", port_id); return 0; } @@ -755,16 +755,16 @@ int ipcp_udp_flow_alloc_resp(uint32_t port_id, NULL); _ap_instance->ping_pong = !_ap_instance->ping_pong; - LOG_DBG("Accepted flow, port_id %u on UDP fd %d.", port_id, fd); + LOG_DBG("Accepted flow, port_id %d on UDP fd %d.", port_id, fd); return 0; } -int ipcp_udp_flow_dealloc(uint32_t port_id) +int ipcp_udp_flow_dealloc(int port_id) { int fd = port_id_to_fd(port_id); if (fd < 0) { - LOG_DBGF("Could not find flow with port_id %u.", port_id); + LOG_DBGF("Could not find flow with port_id %d.", port_id); return 0; } @@ -778,11 +778,11 @@ int ipcp_udp_flow_dealloc(uint32_t port_id) } /* FIXME: may be crap, didn't think this one through */ -int ipcp_udp_flow_dealloc_arr(uint32_t port_id) +int ipcp_udp_flow_dealloc_arr(int port_id) { int fd = port_id_to_fd(port_id); if (fd < 0) { - LOG_DBGF("Could not find flow with port_id %u.", port_id); + LOG_DBGF("Could not find flow with port_id %d.", port_id); return 0; } -- cgit v1.2.3