summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp-data.h2
-rw-r--r--src/ipcpd/ipcp.c5
-rw-r--r--src/ipcpd/ipcp.h7
-rw-r--r--src/ipcpd/local/main.c32
-rw-r--r--src/ipcpd/normal/cdap_request.c3
-rw-r--r--src/ipcpd/normal/fmgr.c7
-rw-r--r--src/ipcpd/normal/fmgr.h10
-rw-r--r--src/ipcpd/normal/frct.c19
-rw-r--r--src/ipcpd/normal/frct.h7
-rw-r--r--src/ipcpd/normal/main.c2
-rw-r--r--src/ipcpd/normal/ribmgr.c18
-rw-r--r--src/ipcpd/normal/ribmgr.h11
-rw-r--r--src/ipcpd/normal/shm_pci.c16
-rw-r--r--src/ipcpd/shim-eth-llc/main.c50
-rw-r--r--src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto4
-rw-r--r--src/ipcpd/shim-udp/main.c31
-rw-r--r--src/ipcpd/shim-udp/shim_udp_messages.proto4
17 files changed, 146 insertions, 82 deletions
diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h
index 4971dbb5..a9a637f0 100644
--- a/src/ipcpd/ipcp-data.h
+++ b/src/ipcpd/ipcp-data.h
@@ -44,7 +44,7 @@ struct ipcp_data {
pthread_mutex_t lock;
};
-struct ipcp_data * ipcp_data_create();
+struct ipcp_data * ipcp_data_create(void);
struct ipcp_data * ipcp_data_init(struct ipcp_data * dst,
enum ipcp_type ipcp_type);
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index f9246c7a..c2d343f8 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -189,6 +189,8 @@ void * ipcp_main_loop(void * o)
struct timeval ltv = {(SOCKET_TIMEOUT / 1000),
(SOCKET_TIMEOUT % 1000) * 1000};
+ (void) o;
+
sock_path = ipcp_sock_path(getpid());
if (sock_path == NULL)
return (void *) 1;
@@ -255,8 +257,7 @@ void * ipcp_main_loop(void * o)
if (conf_msg->ipcp_type == IPCP_NORMAL) {
conf.addr_size = conf_msg->addr_size;
conf.cep_id_size = conf_msg->cep_id_size;
- conf.pdu_length_size
- = conf_msg->pdu_length_size;
+ conf.pdu_length_size = conf_msg->pdu_length_size;
conf.qos_id_size = conf_msg->qos_id_size;
conf.seqno_size = conf_msg->seqno_size;
conf.has_ttl = conf_msg->has_ttl;
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 87c0c5d1..18a5bdab 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -53,13 +53,14 @@ struct ipcp {
pthread_t mainloop;
} ipcpi;
-int ipcp_init();
+int ipcp_init(enum ipcp_type type,
+ struct ipcp_ops * ops);
-void ipcp_fini();
+void ipcp_fini(void);
void ipcp_set_state(enum ipcp_state state);
-enum ipcp_state ipcp_get_state();
+enum ipcp_state ipcp_get_state(void);
int ipcp_wait_state(enum ipcp_state state,
const struct timespec * timeout);
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 68c9ae8c..c9ad0ae6 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -38,6 +38,7 @@
#include <pthread.h>
#include <sys/wait.h>
#include <fcntl.h>
+#include <assert.h>
#define EVENT_WAIT_TIMEOUT 100 /* us */
#define THIS_TYPE IPCP_LOCAL
@@ -53,7 +54,7 @@ struct {
pthread_t sduloop;
} local_data;
-int local_data_init()
+static int local_data_init(void)
{
int i;
for (i = 0; i < IRMD_MAX_FLOWS; ++i)
@@ -68,7 +69,7 @@ int local_data_init()
return 0;
}
-void local_data_fini()
+static void local_data_fini(void)
{
pthread_rwlock_destroy(&local_data.lock);
}
@@ -80,6 +81,8 @@ static void * ipcp_local_sdu_loop(void * o)
if (fq == NULL)
return (void *) 1;
+ (void) o;
+
while (true) {
int fd;
int ret;
@@ -89,10 +92,7 @@ static void * ipcp_local_sdu_loop(void * o)
if (ret == -ETIMEDOUT)
continue;
- if (ret < 0) {
- LOG_ERR("Event wait returned error code %d.", -ret);
- continue;
- }
+ assert(!ret);
pthread_rwlock_rdlock(&ipcpi.state_lock);
@@ -106,6 +106,8 @@ static void * ipcp_local_sdu_loop(void * o)
while ((fd = fqueue_next(fq)) >= 0) {
idx = local_flow_read(fd);
+ assert((size_t) idx < (SHM_BUFFER_SIZE));
+
fd = local_data.in_out[fd];
if (fd != -1)
@@ -121,6 +123,8 @@ static void * ipcp_local_sdu_loop(void * o)
void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
{
+ (void) c;
+
switch(sig) {
case SIGINT:
case SIGTERM:
@@ -143,10 +147,7 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
static int ipcp_local_bootstrap(struct dif_config * conf)
{
- if (conf->type != THIS_TYPE) {
- LOG_ERR("Config doesn't match IPCP type.");
- return -1;
- }
+ assert (conf->type == THIS_TYPE);
pthread_rwlock_wrlock(&ipcpi.state_lock);
@@ -204,12 +205,12 @@ static int ipcp_local_flow_alloc(int fd,
{
int out_fd = -1;
- LOG_DBG("Allocating flow to %s on fd %d.", dst_name, fd);
+ /* This ipcpd has all QoS */
+ (void) qos;
- if (dst_name == NULL || src_ae_name == NULL)
- return -1;
+ LOG_DBG("Allocating flow to %s on fd %d.", dst_name, fd);
- /* This ipcpd has all QoS */
+ assert(dst_name || src_ae_name);
pthread_rwlock_rdlock(&ipcpi.state_lock);
@@ -271,8 +272,7 @@ static int ipcp_local_flow_dealloc(int fd)
{
struct timespec t = {0, 10000};
- if (fd < 0)
- return -EINVAL;
+ assert(!(fd < 0));
flow_set_del(local_data.flows, fd);
diff --git a/src/ipcpd/normal/cdap_request.c b/src/ipcpd/normal/cdap_request.c
index 5839360b..8409b508 100644
--- a/src/ipcpd/normal/cdap_request.c
+++ b/src/ipcpd/normal/cdap_request.c
@@ -134,8 +134,7 @@ int cdap_request_wait(struct cdap_request * creq)
return ret;
}
-void cdap_request_respond(struct cdap_request * creq,
- int response)
+void cdap_request_respond(struct cdap_request * creq, int response)
{
if (creq == NULL)
return;
diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c
index 3da392c5..46c72691 100644
--- a/src/ipcpd/normal/fmgr.c
+++ b/src/ipcpd/normal/fmgr.c
@@ -126,6 +126,8 @@ static void * fmgr_nm1_acceptor(void * o)
int fd;
char * ae_name;
+ (void) o;
+
while (true) {
ipcp_wait_state(IPCP_ENROLLED, NULL);
@@ -190,6 +192,8 @@ static void * fmgr_np1_sdu_reader(void * o)
if (fq == NULL)
return (void *) 1;
+ (void) o;
+
while (true) {
int ret = flow_event_wait(fmgr.np1_set, fq, &timeout);
if (ret == -ETIMEDOUT)
@@ -240,6 +244,9 @@ void * fmgr_nm1_sdu_reader(void * o)
fqueue_t * fq = fqueue_create();
if (fq == NULL)
return (void *) 1;
+
+ (void) o;
+
while (true) {
int ret = flow_event_wait(fmgr.nm1_set, fq, &timeout);
if (ret == -ETIMEDOUT)
diff --git a/src/ipcpd/normal/fmgr.h b/src/ipcpd/normal/fmgr.h
index f97cf858..faa8a0e4 100644
--- a/src/ipcpd/normal/fmgr.h
+++ b/src/ipcpd/normal/fmgr.h
@@ -34,28 +34,34 @@
#define MGMT_AE "Management"
#define DT_AE "Data transfer"
-int fmgr_init();
-int fmgr_fini();
+int fmgr_init(void);
+
+int fmgr_fini(void);
int fmgr_np1_alloc(int fd,
char * dst_ap_name,
char * src_ae_name,
enum qos_cube qos);
+
int fmgr_np1_alloc_resp(int fd,
int response);
+
int fmgr_np1_dealloc(int fd);
int fmgr_np1_post_buf(cep_id_t id,
buffer_t * buf);
+
int fmgr_np1_post_sdu(cep_id_t id,
struct shm_du_buff * sdb);
int fmgr_nm1_mgmt_flow(char * dst_name);
+
int fmgr_nm1_dt_flow(char * dst_name,
enum qos_cube qos);
int fmgr_nm1_write_sdu(struct pci * pci,
struct shm_du_buff * sdb);
+
int fmgr_nm1_write_buf(struct pci * pci,
buffer_t * buf);
diff --git a/src/ipcpd/normal/frct.c b/src/ipcpd/normal/frct.c
index 9daf8755..3f80f91e 100644
--- a/src/ipcpd/normal/frct.c
+++ b/src/ipcpd/normal/frct.c
@@ -42,7 +42,7 @@ enum conn_state {
struct frct_i {
uint32_t cep_id;
- uint32_t r_address;
+ uint64_t r_address;
uint32_t r_cep_id;
enum qos_cube cube;
uint64_t seqno;
@@ -58,18 +58,20 @@ struct {
pthread_mutex_t cep_ids_lock;
} frct;
-static int next_cep_id()
+static cep_id_t next_cep_id(void)
{
- int ret;
+ cep_id_t ret;
pthread_mutex_lock(&frct.cep_ids_lock);
ret = bmp_allocate(frct.cep_ids);
+ if (!bmp_is_id_valid(frct.cep_ids, ret))
+ ret = INVALID_CEP_ID;
pthread_mutex_unlock(&frct.cep_ids_lock);
return ret;
}
-static int release_cep_id(int id)
+static int release_cep_id(cep_id_t id)
{
int ret;
@@ -117,7 +119,7 @@ int frct_fini()
return 0;
}
-static struct frct_i * create_frct_i(uint32_t address,
+static struct frct_i * create_frct_i(uint64_t address,
cep_id_t r_cep_id)
{
struct frct_i * instance;
@@ -128,6 +130,11 @@ static struct frct_i * create_frct_i(uint32_t address,
return NULL;
id = next_cep_id();
+ if (id == INVALID_CEP_ID) {
+ free(instance);
+ return NULL;
+ }
+
instance->r_address = address;
instance->cep_id = id;
instance->r_cep_id = r_cep_id;
@@ -191,7 +198,7 @@ static void destroy_frct_i(struct frct_i * instance)
free(instance);
}
-cep_id_t frct_i_create(uint32_t address,
+cep_id_t frct_i_create(uint64_t address,
buffer_t * buf,
enum qos_cube cube)
{
diff --git a/src/ipcpd/normal/frct.h b/src/ipcpd/normal/frct.h
index b9e70d0f..572c1f61 100644
--- a/src/ipcpd/normal/frct.h
+++ b/src/ipcpd/normal/frct.h
@@ -30,10 +30,11 @@
struct frct_i;
-int frct_init();
-int frct_fini();
+int frct_init(void);
-cep_id_t frct_i_create(uint32_t address,
+int frct_fini(void);
+
+cep_id_t frct_i_create(uint64_t address,
buffer_t * buf,
enum qos_cube cube);
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 0339eaf4..32aabdf2 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -47,6 +47,8 @@ int irmd_api;
void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
{
+ (void) c;
+
switch(sig) {
case SIGINT:
case SIGTERM:
diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c
index c69a59ce..cd12bcc6 100644
--- a/src/ipcpd/normal/ribmgr.c
+++ b/src/ipcpd/normal/ribmgr.c
@@ -167,6 +167,9 @@ int ribmgr_cdap_reply(struct cdap * instance,
{
struct list_head * pos, * n = NULL;
+ (void) data;
+ (void) len;
+
pthread_mutex_lock(&rib.cdap_reqs_lock);
list_for_each_safe(pos, n, &rib.cdap_reqs) {
@@ -202,6 +205,9 @@ int ribmgr_cdap_read(struct cdap * instance,
char * name)
{
LOG_MISSING;
+ (void) instance;
+ (void) invoke_id;
+ (void) name;
return -1;
}
@@ -216,6 +222,8 @@ int ribmgr_cdap_write(struct cdap * instance,
static_info_msg_t * msg;
int ret = 0;
+ (void) flags;
+
pthread_rwlock_wrlock(&ipcpi.state_lock);
if (ipcp_get_state() == IPCP_PENDING_ENROLL &&
strcmp(name, STATIC_INFO) == 0) {
@@ -272,6 +280,11 @@ int ribmgr_cdap_create(struct cdap * instance,
size_t len)
{
LOG_MISSING;
+ (void) instance;
+ (void) invoke_id;
+ (void) name;
+ (void) data;
+ (void) len;
return -1;
}
@@ -283,6 +296,11 @@ int ribmgr_cdap_delete(struct cdap * instance,
size_t len)
{
LOG_MISSING;
+ (void) instance;
+ (void) invoke_id;
+ (void) name;
+ (void) data;
+ (void) len;
return -1;
}
diff --git a/src/ipcpd/normal/ribmgr.h b/src/ipcpd/normal/ribmgr.h
index ed8bae03..01bfcb40 100644
--- a/src/ipcpd/normal/ribmgr.h
+++ b/src/ipcpd/normal/ribmgr.h
@@ -27,10 +27,12 @@
#include "dt_const.h"
-int ribmgr_init();
-int ribmgr_fini();
+int ribmgr_init(void);
+
+int ribmgr_fini(void);
int ribmgr_add_flow(int fd);
+
int ribmgr_remove_flow(int fd);
int ribmgr_bootstrap(struct dif_config * conf);
@@ -39,7 +41,8 @@ int ribmgr_bootstrap(struct dif_config * conf);
* FIXME: Should we expose the RIB?
* Else we may end up with a lot of getters and setters
*/
-struct dt_const * ribmgr_dt_const();
-uint32_t ribmgr_address();
+struct dt_const * ribmgr_dt_const(void);
+
+uint32_t ribmgr_address(void);
#endif
diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c
index 3a16a2da..aa18fa38 100644
--- a/src/ipcpd/normal/shm_pci.c
+++ b/src/ipcpd/normal/shm_pci.c
@@ -39,13 +39,12 @@
#define TTL_SIZE 1
#define CHK_SIZE 4
-static int shm_pci_head_size(struct dt_const * dtc)
+static size_t shm_pci_head_size(struct dt_const * dtc)
{
- int len = 0;
+ size_t len = 0;
len = dtc->addr_size * 2 + dtc->cep_id_size * 2
- + dtc->pdu_length_size + dtc->seqno_size
- + QOS_ID_SIZE;
+ + dtc->pdu_length_size + dtc->seqno_size + QOS_ID_SIZE;
if (dtc->has_ttl)
len += TTL_SIZE;
@@ -53,7 +52,7 @@ static int shm_pci_head_size(struct dt_const * dtc)
return len;
}
-static int shm_pci_tail_size(struct dt_const * dtc)
+static size_t shm_pci_tail_size(struct dt_const * dtc)
{
return dtc->has_chk ? CHK_SIZE : 0;
}
@@ -162,10 +161,11 @@ struct pci * shm_pci_des(struct shm_du_buff * sdb)
int offset = 0;
struct dt_const * dtc;
- head = shm_du_buff_head(sdb);
- if (head == NULL)
+ if (sdb == NULL)
return NULL;
+ head = shm_du_buff_head(sdb);
+
dtc = ribmgr_dt_const();
if (dtc == NULL)
return NULL;
@@ -221,7 +221,7 @@ int shm_pci_shrink(struct shm_du_buff * sdb)
int shm_pci_dec_ttl(struct shm_du_buff * sdb)
{
struct dt_const * dtc;
- int offset = 0;
+ size_t offset = 0;
uint8_t * head;
uint8_t * tail;
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index db258c8b..7976a2d1 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -123,7 +123,7 @@ struct {
pthread_t sdu_reader;
} eth_llc_data;
-static int eth_llc_data_init()
+static int eth_llc_data_init(void)
{
int i;
@@ -166,7 +166,7 @@ static int eth_llc_data_init()
return 0;
}
-void eth_llc_data_fini()
+void eth_llc_data_fini(void)
{
bmp_destroy(eth_llc_data.saps);
flow_set_destroy(eth_llc_data.np1_flows);
@@ -190,7 +190,7 @@ static int eth_llc_ipcp_send_frame(uint8_t * dst_addr,
uint8_t * payload,
size_t len)
{
- int frame_len = 0;
+ uint32_t frame_len = 0;
uint8_t cf = 0x03;
uint16_t length;
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
@@ -262,7 +262,7 @@ static int eth_llc_ipcp_send_frame(uint8_t * dst_addr,
}
eth_llc_data.tx_offset =
- (eth_llc_data.tx_offset + 1) & (SHM_BUFFER_SIZE - 1);
+ (eth_llc_data.tx_offset + 1) & ((SHM_BUFFER_SIZE) - 1);
#else
if (sendto(eth_llc_data.s_fd,
frame,
@@ -415,7 +415,7 @@ static int eth_llc_ipcp_sap_alloc_reply(uint8_t ssap,
}
-static int eth_llc_ipcp_flow_dealloc_req(uint8_t ssap, uint8_t * r_addr)
+static int eth_llc_ipcp_flow_dealloc_req(uint8_t ssap)
{
int fd = -1;
@@ -462,7 +462,7 @@ static int eth_llc_ipcp_mgmt_frame(uint8_t * buf, size_t len, uint8_t * r_addr)
msg->response);
break;
case SHIM_ETH_LLC_MSG_CODE__FLOW_DEALLOC:
- eth_llc_ipcp_flow_dealloc_req(msg->ssap, r_addr);
+ eth_llc_ipcp_flow_dealloc_req(msg->ssap);
break;
default:
LOG_ERR("Unknown message received %d.", msg->code);
@@ -492,6 +492,8 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
#endif
struct eth_llc_frame * llc_frame;
+ (void) o;
+
memset(br_addr, 0xff, MAC_SIZE * sizeof(uint8_t));
while (true) {
@@ -532,7 +534,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
MAC_SIZE) &&
memcmp(br_addr, llc_frame->dst_hwaddr, MAC_SIZE)) {
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
- offset = (offset + 1) & (SHM_BUFFER_SIZE - 1);
+ offset = (offset + 1) & ((SHM_BUFFER_SIZE) - 1);
header->tp_status = TP_STATUS_KERNEL;
#endif
continue;
@@ -543,7 +545,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
if (length > 0x05FF) { /* DIX */
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
- offset = (offset + 1) & (SHM_BUFFER_SIZE -1);
+ offset = (offset + 1) & ((SHM_BUFFER_SIZE) -1);
header->tp_status = TP_STATUS_KERNEL;
#endif
continue;
@@ -565,7 +567,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
if (fd < 0) {
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
- offset = (offset + 1) & (SHM_BUFFER_SIZE - 1);
+ offset = (offset + 1) & ((SHM_BUFFER_SIZE) - 1);
header->tp_status = TP_STATUS_KERNEL;
#endif
continue;
@@ -576,7 +578,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
llc_frame->src_hwaddr, MAC_SIZE)) {
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
- offset = (offset + 1) & (SHM_BUFFER_SIZE -1);
+ offset = (offset + 1) & ((SHM_BUFFER_SIZE) -1);
header->tp_status = TP_STATUS_KERNEL;
#endif
continue;
@@ -588,7 +590,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
}
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
- offset = (offset + 1) & (SHM_BUFFER_SIZE -1);
+ offset = (offset + 1) & ((SHM_BUFFER_SIZE) - 1);
header->tp_status = TP_STATUS_KERNEL;
#endif
}
@@ -608,6 +610,8 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
if (fq == NULL)
return (void *) 1;
+ (void) o;
+
while (true) {
int ret = flow_event_wait(eth_llc_data.np1_flows, fq, &timeout);
if (ret == -ETIMEDOUT)
@@ -648,6 +652,8 @@ static void * eth_llc_ipcp_sdu_writer(void * o)
void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
{
+ (void) c;
+
switch(sig) {
case SIGINT:
case SIGTERM:
@@ -801,7 +807,7 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
#if defined(PACKET_RX_RING) && defined(PACKET_TX_RING)
eth_llc_data.rx_ring = mmap(NULL, 2 * SHM_RDRB_BLOCK_SIZE
- * SHM_BUFFER_SIZE,
+ * (SHM_BUFFER_SIZE),
PROT_READ | PROT_WRITE, MAP_SHARED,
skfd, 0);
if (eth_llc_data.rx_ring == NULL) {
@@ -811,7 +817,7 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
}
eth_llc_data.tx_ring = eth_llc_data.rx_ring
- + SHM_RDRB_BLOCK_SIZE * SHM_BUFFER_SIZE;
+ + SHM_RDRB_BLOCK_SIZE * (SHM_BUFFER_SIZE);
#endif
pthread_rwlock_wrlock(&ipcpi.state_lock);
@@ -902,8 +908,8 @@ static int eth_llc_ipcp_flow_alloc(int fd,
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
- ssap = bmp_allocate(eth_llc_data.saps);
- if (ssap < 0) {
+ ssap = bmp_allocate(eth_llc_data.saps);
+ if (!bmp_is_id_valid(eth_llc_data.saps, ssap)) {
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
pthread_rwlock_unlock(&ipcpi.state_lock);
return -1;
@@ -917,7 +923,10 @@ static int eth_llc_ipcp_flow_alloc(int fd,
memset(r_addr, 0xff, MAC_SIZE);
- if (eth_llc_ipcp_sap_alloc(r_addr, ssap, dst_name, src_ae_name) < 0) {
+ if (eth_llc_ipcp_sap_alloc(r_addr,
+ ssap,
+ dst_name,
+ src_ae_name) < 0) {
pthread_rwlock_rdlock(&ipcpi.state_lock);
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
bmp_release(eth_llc_data.saps, eth_llc_data.fd_to_ef[fd].sap);
@@ -945,7 +954,7 @@ static int eth_llc_ipcp_flow_alloc_resp(int fd, int response)
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
ssap = bmp_allocate(eth_llc_data.saps);
- if (ssap < 0) {
+ if (!bmp_is_id_valid(eth_llc_data.saps, ssap)) {
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
pthread_rwlock_unlock(&ipcpi.state_lock);
return -1;
@@ -959,7 +968,10 @@ static int eth_llc_ipcp_flow_alloc_resp(int fd, int response)
pthread_rwlock_unlock(&eth_llc_data.flows_lock);
pthread_rwlock_unlock(&ipcpi.state_lock);
- if (eth_llc_ipcp_sap_alloc_resp(r_addr, ssap, r_sap, response) < 0) {
+ if (eth_llc_ipcp_sap_alloc_resp(r_addr,
+ ssap,
+ r_sap,
+ response) < 0) {
pthread_rwlock_rdlock(&ipcpi.state_lock);
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
bmp_release(eth_llc_data.saps, eth_llc_data.fd_to_ef[fd].sap);
@@ -970,7 +982,7 @@ static int eth_llc_ipcp_flow_alloc_resp(int fd, int response)
flow_set_add(eth_llc_data.np1_flows, fd);
- LOG_DBG("Accepted flow, fd %d, SAP %d.", fd, ssap);
+ LOG_DBG("Accepted flow, fd %d, SAP %d.", fd, (uint8_t)ssap);
return 0;
}
diff --git a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto
index dbad4964..0e8a1ce2 100644
--- a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto
+++ b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto
@@ -8,7 +8,7 @@ message shim_eth_llc_msg {
required shim_eth_llc_msg_code code = 1;
optional string dst_name = 2;
optional string src_ae_name = 3;
- required sint32 ssap = 4;
- optional sint32 dsap = 5;
+ required uint32 ssap = 4;
+ optional uint32 dsap = 5;
optional sint32 response = 6;
};
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 050623e4..62e1b2d0 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -94,7 +94,7 @@ struct {
pthread_mutex_t fd_set_lock;
} udp_data;
-static int udp_data_init()
+static int udp_data_init(void)
{
int i;
@@ -119,7 +119,7 @@ static int udp_data_init()
return 0;
}
-static void udp_data_fini()
+static void udp_data_fini(void)
{
flow_set_destroy(udp_data.np1_flows);
@@ -192,7 +192,7 @@ static int send_shim_udp_msg(shim_udp_msg_t * msg, uint32_t dst_ip_addr)
}
static int ipcp_udp_port_alloc(uint32_t dst_ip_addr,
- uint32_t src_udp_port,
+ uint16_t src_udp_port,
char * dst_name,
char * src_ae_name)
{
@@ -314,8 +314,8 @@ static int udp_port_to_fd(int udp_port)
return -1;
}
-static int ipcp_udp_port_alloc_reply(int src_udp_port,
- int dst_udp_port,
+static int ipcp_udp_port_alloc_reply(uint16_t src_udp_port,
+ uint16_t dst_udp_port,
int response)
{
int fd = -1;
@@ -368,7 +368,7 @@ static int ipcp_udp_port_alloc_reply(int src_udp_port,
return ret;
}
-static int ipcp_udp_flow_dealloc_req(int udp_port)
+static int ipcp_udp_flow_dealloc_req(uint16_t udp_port)
{
int skfd = -1;
int fd = -1;
@@ -408,13 +408,15 @@ static int ipcp_udp_flow_dealloc_req(int udp_port)
return 0;
}
-static void * ipcp_udp_listener()
+static void * ipcp_udp_listener(void * o)
{
uint8_t buf[SHIM_UDP_MSG_SIZE];
- int n = 0;
+ ssize_t n = 0;
struct sockaddr_in c_saddr;
int sfd = udp_data.s_fd;
+ (void) o;
+
while (true) {
shim_udp_msg_t * msg = NULL;
@@ -464,9 +466,9 @@ static void * ipcp_udp_listener()
return 0;
}
-static void * ipcp_udp_sdu_reader()
+static void * ipcp_udp_sdu_reader(void * o)
{
- int n;
+ ssize_t n;
int skfd;
int fd;
/* FIXME: avoid this copy */
@@ -476,6 +478,8 @@ static void * ipcp_udp_sdu_reader()
int flags;
struct timeval tv = {0, FD_UPDATE_TIMEOUT};
+ (void) o;
+
while (true) {
pthread_rwlock_rdlock(&ipcpi.state_lock);
pthread_rwlock_rdlock(&udp_data.flows_lock);
@@ -507,7 +511,6 @@ static void * ipcp_udp_sdu_reader()
(unsigned *) &n)) <= 0)
continue;
- /* send the sdu to the correct fd */
flow_write(fd, buf, n);
}
}
@@ -524,6 +527,8 @@ static void * ipcp_udp_sdu_loop(void * o)
if (fq == NULL)
return (void *) 1;
+ (void) o;
+
while (true) {
int ret = flow_event_wait(udp_data.np1_flows, fq, &timeout);
if (ret == -ETIMEDOUT)
@@ -563,6 +568,8 @@ static void * ipcp_udp_sdu_loop(void * o)
void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
{
+ (void) c;
+
switch(sig) {
case SIGINT:
case SIGTERM:
@@ -1105,7 +1112,7 @@ static int ipcp_udp_flow_alloc_resp(int fd, int response)
static int ipcp_udp_flow_dealloc(int fd)
{
int skfd = -1;
- int remote_udp = -1;
+ uint16_t remote_udp;
struct timespec t = {0, 10000};
struct sockaddr_in r_saddr;
socklen_t r_saddr_len = sizeof(r_saddr);
diff --git a/src/ipcpd/shim-udp/shim_udp_messages.proto b/src/ipcpd/shim-udp/shim_udp_messages.proto
index e6bac908..bd9bd3aa 100644
--- a/src/ipcpd/shim-udp/shim_udp_messages.proto
+++ b/src/ipcpd/shim-udp/shim_udp_messages.proto
@@ -8,7 +8,7 @@ message shim_udp_msg {
required shim_udp_msg_code code = 1;
optional string dst_name = 2;
optional string src_ae_name = 4;
- required sint32 src_udp_port = 5;
- optional sint32 dst_udp_port = 6;
+ required uint32 src_udp_port = 5;
+ optional uint32 dst_udp_port = 6;
optional sint32 response = 7;
};