summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-21 20:13:41 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-22 13:27:02 +0200
commit3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2 (patch)
tree881da180b8d801c38ba0fbad2fc9f387a70ec016 /src/ipcpd/shim-eth-llc
parentd5a52f3951fff7ee272bd0d4cd95cd122d07fa64 (diff)
downloadouroboros-3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2.tar.gz
ouroboros-3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2.zip
build: Compile with strict conversion
This has the code checked with -Wcast-qual and -Wconversion flags. These flags were removed because SWIG generated code fails.
Diffstat (limited to 'src/ipcpd/shim-eth-llc')
-rw-r--r--src/ipcpd/shim-eth-llc/main.c36
-rw-r--r--src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto4
2 files changed, 23 insertions, 17 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index dfb6e21c..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,
@@ -534,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;
@@ -545,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;
@@ -567,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;
@@ -578,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;
@@ -590,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
}
@@ -807,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) {
@@ -817,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);
@@ -908,7 +908,7 @@ static int eth_llc_ipcp_flow_alloc(int fd,
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
- ssap = bmp_allocate(eth_llc_data.saps);
+ 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);
@@ -923,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);
@@ -965,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);
@@ -976,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;
};