summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-08 16:54:12 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-08 16:54:12 +0200
commit4e13c71204e9667cfc4b7da6491972f854d9402d (patch)
tree924156d142bce5521757e9349fa0b3fd2ff1b0cc /src
parent021af9e01ce6c6376534b33ef1a06ea4189028d4 (diff)
downloadouroboros-4e13c71204e9667cfc4b7da6491972f854d9402d.tar.gz
ouroboros-4e13c71204e9667cfc4b7da6491972f854d9402d.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/flow.c2
-rw-r--r--src/ipcpd/flow.h4
-rw-r--r--src/ipcpd/ipcp-ops.h22
-rw-r--r--src/ipcpd/shim-udp/main.c24
-rw-r--r--src/irmd/main.c28
-rw-r--r--src/lib/dev.c4
-rw-r--r--src/lib/ipcp.c20
-rw-r--r--src/lib/ipcpd_messages.proto10
-rw-r--r--src/lib/irmd_messages.proto7
9 files changed, 59 insertions, 62 deletions
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 <ouroboros/logs.h>
-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;
}
diff --git a/src/irmd/main.c b/src/irmd/main.c
index a6403612..946ed13d 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -56,8 +56,6 @@
#define IRMD_THREADPOOL_SIZE 3
#endif
-
-
enum flow_state {
FLOW_NULL = 0,
FLOW_PENDING,
@@ -94,10 +92,10 @@ struct reg_name_entry {
struct port_map_entry {
struct list_head next;
- uint32_t port_id;
+ int port_id;
- pid_t n_pid;
- pid_t n_1_pid;
+ pid_t n_pid;
+ pid_t n_1_pid;
enum flow_state state;
};
@@ -122,7 +120,7 @@ struct irm {
pthread_mutex_t lock;
} * instance = NULL;
-static struct port_map_entry * get_port_map_entry(uint32_t port_id)
+static struct port_map_entry * get_port_map_entry(int port_id)
{
struct list_head * pos = NULL;
@@ -732,9 +730,9 @@ static struct port_map_entry * flow_accept(pid_t pid,
return pme;
}
-static int flow_alloc_resp(pid_t n_pid,
- uint32_t port_id,
- int response)
+static int flow_alloc_resp(pid_t n_pid,
+ int port_id,
+ int response)
{
struct reg_name_entry * rne = get_reg_name_entry_by_id(n_pid);
struct port_map_entry * pme = get_port_map_entry(port_id);
@@ -800,7 +798,7 @@ static struct port_map_entry * flow_alloc(pid_t pid,
return e;
}
-static int flow_alloc_res(uint32_t port_id)
+static int flow_alloc_res(int port_id)
{
bool allocated = false;
struct port_map_entry * e;
@@ -810,7 +808,7 @@ static int flow_alloc_res(uint32_t port_id)
/* FIXME: this needs locking */
e = get_port_map_entry(port_id);
if (e == NULL) {
- LOG_DBGF("Could not locate port_id %u", port_id);
+ LOG_DBGF("Could not locate port_id %d", port_id);
return -1;
}
if (e->state == FLOW_ALLOCATED)
@@ -821,7 +819,7 @@ static int flow_alloc_res(uint32_t port_id)
return 0;
}
-static int flow_dealloc(uint32_t port_id)
+static int flow_dealloc(int port_id)
{
pid_t n_1_pid;
@@ -876,8 +874,8 @@ static struct port_map_entry * flow_req_arr(pid_t pid,
return pme;
}
-static int flow_alloc_reply(uint32_t port_id,
- int response)
+static int flow_alloc_reply(int port_id,
+ int response)
{
struct port_map_entry * e;
@@ -894,7 +892,7 @@ static int flow_alloc_reply(uint32_t port_id,
return 0;
}
-static int flow_dealloc_ipcp(uint32_t port_id)
+static int flow_dealloc_ipcp(int port_id)
{
struct port_map_entry * e = get_port_map_entry(port_id);
if (e == NULL)
diff --git a/src/lib/dev.c b/src/lib/dev.c
index c99e8cdb..d574363b 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -46,7 +46,7 @@
struct flow {
struct shm_ap_rbuff * rb;
- uint32_t port_id;
+ int port_id;
uint32_t oflags;
/* don't think this needs locking */
@@ -131,7 +131,7 @@ void ap_fini()
}
#if 0
-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)
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 75676915..843582b9 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -364,7 +364,7 @@ int ipcp_name_unreg(pid_t pid,
}
int ipcp_flow_alloc(pid_t pid,
- uint32_t port_id,
+ int port_id,
pid_t n_pid,
char * dst_name,
char * src_ap_name,
@@ -402,10 +402,10 @@ int ipcp_flow_alloc(pid_t pid,
return ret;
}
-int ipcp_flow_alloc_resp(pid_t pid,
- uint32_t port_id,
- pid_t n_pid,
- int response)
+int ipcp_flow_alloc_resp(pid_t pid,
+ int port_id,
+ pid_t n_pid,
+ int response)
{
ipcp_msg_t msg = IPCP_MSG__INIT;
ipcp_msg_t * recv_msg = NULL;
@@ -468,9 +468,9 @@ int ipcp_flow_req_arr(pid_t pid,
return port_id;
}
-int ipcp_flow_alloc_reply(pid_t pid,
- uint32_t port_id,
- int response)
+int ipcp_flow_alloc_reply(pid_t pid,
+ int port_id,
+ int response)
{
irm_msg_t msg = IRM_MSG__INIT;
irm_msg_t * recv_msg = NULL;
@@ -498,8 +498,8 @@ int ipcp_flow_alloc_reply(pid_t pid,
}
-int ipcp_flow_dealloc(pid_t pid,
- uint32_t port_id)
+int ipcp_flow_dealloc(pid_t pid,
+ int port_id)
{
if (pid != 0) {
ipcp_msg_t msg = IPCP_MSG__INIT;
diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto
index daca011d..901adaa0 100644
--- a/src/lib/ipcpd_messages.proto
+++ b/src/lib/ipcpd_messages.proto
@@ -20,13 +20,13 @@ message ipcp_msg {
repeated string dif_names = 4;
optional int32 len = 5;
optional string name = 6;
- optional int32 port_id = 7;
+ optional sint32 port_id = 7;
optional string dst_name = 8;
optional string src_ap_name = 9;
optional string src_ae_name = 10;
optional dif_config_msg conf = 11;
- optional int32 fd = 12;
- optional int32 pid = 13;
- optional int32 response = 14;
- optional int32 result = 15;
+ optional sint32 fd = 12;
+ optional sint32 pid = 13;
+ optional sint32 response = 14;
+ optional sint32 result = 15;
};
diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto
index c336614e..27194ccb 100644
--- a/src/lib/irmd_messages.proto
+++ b/src/lib/irmd_messages.proto
@@ -49,11 +49,10 @@ message irm_msg {
optional uint32 api_id = 3;
optional uint32 ipcp_type = 5;
repeated string dif_name = 6;
- optional int32 response = 7;
+ optional sint32 response = 7;
optional string dst_name = 8;
- optional uint32 port_id = 9;
+ optional sint32 port_id = 9;
optional int32 pid = 10;
optional dif_config_msg conf = 11;
- optional int32 cfd = 12;
- optional int32 result = 13;
+ optional sint32 result = 12;
};