summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-eth-llc/main.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2016-06-14 18:01:09 +0200
committerdimitri staessens <[email protected]>2016-06-14 18:01:09 +0200
commit18318ecbd33544438f7ec870437ff93f6d286c07 (patch)
treeb6cdd28d260cf8f838c3299455ab1070a6e4c25c /src/ipcpd/shim-eth-llc/main.c
parentaf2ab9b56fb4b541abd067c9a6e2b3f62a4c4aab (diff)
parent6cc20e6d98aec8d1da0740a2a890e984e634445a (diff)
downloadouroboros-18318ecbd33544438f7ec870437ff93f6d286c07.tar.gz
ouroboros-18318ecbd33544438f7ec870437ff93f6d286c07.zip
Merged in sandervrijders/ouroboros/be (pull request #125)
ipcpd: Fix wrong length in shim-eth-llc
Diffstat (limited to 'src/ipcpd/shim-eth-llc/main.c')
-rw-r--r--src/ipcpd/shim-eth-llc/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index fe7b5dcb..1ff3496b 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -65,6 +65,7 @@ typedef ShimEthLlcMsg shim_eth_llc_msg_t;
#define MGMT_SAP 0x01
#define SHIM_ETH_LLC_MAX_SDU_SIZE 1500
#define MAC_SIZE 6
+#define LLC_HEADER_SIZE 3
#define MAX_SAPS 64
/* global for trapping signal */
@@ -278,7 +279,7 @@ static int eth_llc_ipcp_send_frame(uint8_t dst_addr[MAC_SIZE],
return -1;
}
- length = htons(len);
+ length = htons(len + LLC_HEADER_SIZE);
memcpy(frame, dst_addr, MAC_SIZE * sizeof(uint8_t));
frame_len += MAC_SIZE;
@@ -580,8 +581,9 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
rw_lock_unlock(&_ipcp->state_lock);
- if (recv(shim_data(_ipcp)->s_fd, buf,
- SHIM_ETH_LLC_MAX_SDU_SIZE, 0) < 0) {
+ frame_len = recv(shim_data(_ipcp)->s_fd, buf,
+ SHIM_ETH_LLC_MAX_SDU_SIZE, 0);
+ if (frame_len < 0) {
LOG_ERR("Failed to recv frame.");
continue;
}
@@ -600,13 +602,14 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
for (; i < 2 * MAC_SIZE; i++)
src_mac[i - MAC_SIZE] = buf[i];
- frame_len = ((buf[i]) << 8) + buf[i + 1];
i += 2;
dsap = reverse_bits(buf[i++]);
ssap = reverse_bits(buf[i++]);
i++;
+ frame_len -= i;
+
if (ssap == MGMT_SAP &&
dsap == MGMT_SAP) {
eth_llc_ipcp_mgmt_frame((uint8_t *) (buf + i),