cpu/examples/sys/drivers: reduce scope of variables

dev/timer
Hinnerk van Bruinehsen 9 years ago
parent d1406e1ea7
commit 57b998e4a1

@ -86,6 +86,7 @@ void abtorigin(const char *vector, u_long *lnk_ptr1)
/*-----------------------------------------------------------------------------------*/
void UNDEF_Routine(void)
{
/* cppcheck-suppress variableScope */
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction
@ -99,6 +100,7 @@ void UNDEF_Routine(void)
/*-----------------------------------------------------------------------------------*/
void PABT_Routine(void)
{
/* cppcheck-suppress variableScope */
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction
@ -112,6 +114,7 @@ void PABT_Routine(void)
/*-----------------------------------------------------------------------------------*/
void DABT_Routine(void)
{
/* cppcheck-suppress variableScope */
register u_long *lnk_ptr;
__asm__ __volatile__("sub %0, lr, #8" : "=r"(lnk_ptr)); // get aborting instruction

@ -391,11 +391,10 @@ bool i2c_write(uint8_t i2c_interface, uint8_t slave_addr, uint8_t reg_addr,
i2c_write_length = tx_buff_length + 1;
i2c_master_buffer[0] = (slave_addr << 1) & WRITE_ENABLE_BIT_MASK;
i2c_master_buffer[1] = reg_addr;
int32_t i;
int32_t j = 0;
if ((tx_buff != NULL) && tx_buff_length < (I2C_BUFSIZE - 2)) {
for (i = 2; i < tx_buff_length + 2; i++) {
int32_t j = 0;
for (int32_t i = 2; i < tx_buff_length + 2; i++) {
i2c_master_buffer[i] = tx_buff[j];
j++;
//printf("I2CMasterBuffer[%d] = %d\n", i, I2CMasterBuffer[i]);
@ -419,14 +418,12 @@ bool i2c_trans_receive(uint8_t i2c_interface, uint8_t slave_addr,
I2C_BUFSIZE * sizeof(uint8_t));
i2c_write_length = tx_buff_length;
i2c_read_length = rx_buff_length;
bool successful = false;
int32_t read_index = 0;
int32_t i = 0;
if (tx_buff != NULL && (tx_buff_length > 0)) {
int32_t read_index = 0;
i2c_master_buffer[0] = (slave_addr << 1) & WRITE_ENABLE_BIT_MASK;
for (i = 1; i < tx_buff_length + 1; i++) {
for (int32_t i = 1; i < tx_buff_length + 1; i++) {
if (i < I2C_BUFSIZE) {
i2c_master_buffer[i] = tx_buff[i - 1];
}
@ -439,7 +436,7 @@ bool i2c_trans_receive(uint8_t i2c_interface, uint8_t slave_addr,
read_index = i + 1;
}
successful = i2c_transaction(i2c_interface);
bool successful = i2c_transaction(i2c_interface);
if (successful && (rx_buff != NULL) && (rx_buff_length > 0)) {
memcpy(rx_buff, (const uint8_t *)(i2c_master_buffer + read_index),

@ -996,7 +996,6 @@ uint32_t _maca_init_from_flash ( uint32_t addr ) {
nvm_err_t err;
volatile uint32_t buffer[8];
volatile uint32_t length;
volatile uint32_t i = 0;
volatile uint32_t j = 0;
@ -1013,6 +1012,7 @@ uint32_t _maca_init_from_flash ( uint32_t addr ) {
}
if ( buffer[0] == MACA_FLASH_INIT_MAGIC ) {
volatile uint32_t length;
length = buffer[1] & 0x0000ffff;
while ( i < ( length-4 ) ) {

@ -38,6 +38,7 @@ void random_init(void)
int random_read(char *buf, unsigned int num)
{
/* cppcheck-suppress variableScope */
uint32_t tmp;
int count = 0;

@ -32,6 +32,7 @@ void random_init(void)
int random_read(char *buf, unsigned int num)
{
/* cppcheck-suppress variableScope */
uint32_t tmp;
int count = 0;

@ -98,10 +98,9 @@ uint32_t srf02_get_distance(uint8_t ranging_mode)
void srf02_start_ranging(uint16_t ranging_mode)
{
uint32_t distance = 0;
while (1) {
distance = srf02_get_distance(ranging_mode);
uint32_t distance = srf02_get_distance(ranging_mode);
if (distance != UINT32_MAX) {
switch (ranging_mode) {

@ -85,7 +85,6 @@ void *threadA_func(void *)
{
int day = 13, month = 6, year = 2014;
int ret_day;
char day_of_week_table[][32] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
printf("\n******** Hello, now you're in %s ********\n", thread_getname(thread_getpid()));
printf("We'll test some C functions here!\n");
@ -99,6 +98,7 @@ void *threadA_func(void *)
ret_day = day_of_week(day, month, year);
if (ret_day >= 0){
char day_of_week_table[][32] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
printf("%s\n", day_of_week_table[ret_day]);
}

@ -61,7 +61,6 @@ static void *init_udp_server(void *arg)
sockaddr6_t sa;
char buffer_main[UDP_BUFFER_SIZE];
int32_t recsize;
uint32_t fromlen;
int sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
@ -79,7 +78,7 @@ static void *init_udp_server(void *arg)
}
while (1) {
recsize = socket_base_recvfrom(sock, (void *)buffer_main, UDP_BUFFER_SIZE, 0, &sa, &fromlen);
int32_t recsize = socket_base_recvfrom(sock, (void *)buffer_main, UDP_BUFFER_SIZE, 0, &sa, &fromlen);
if (recsize < 0) {
printf("ERROR: recsize < 0!\n");

@ -359,14 +359,13 @@ uint8_t tripledes_get_preferred_block_size(void)
static void cookey(const uint32_t *raw1, uint32_t *keyout)
{
uint32_t *cook;
const uint32_t *raw0;
uint32_t dough[32];
int i;
cook = dough;
for (i = 0; i < 16; i++, raw1++) {
raw0 = raw1++;
const uint32_t *raw0 = raw1++;
*cook = (*raw0 & 0x00fc0000L) << 6;
*cook |= (*raw0 & 0x00000fc0L) << 10;
*cook |= (*raw1 & 0x00fc0000L) >> 10;
@ -383,7 +382,7 @@ static void cookey(const uint32_t *raw1, uint32_t *keyout)
static void deskey(const uint8_t *key, int decrypt, uint32_t *keyout)
{
uint32_t i, j, l, m, n, kn[32];
uint32_t i, j, l, m, kn[32];
uint8_t pc1m[56], pcr[56];
for (j = 0; j < 56; j++) {
@ -401,7 +400,7 @@ static void deskey(const uint8_t *key, int decrypt, uint32_t *keyout)
m = i << 1;
}
n = m + 1;
uint32_t n = m + 1;
kn[m] = kn[n] = 0L;
for (j = 0; j < 28; j++) {

@ -65,7 +65,7 @@ int rc5_encrypt(cipher_context_t *context, uint8_t *block,
register uint32_t r;
rc5_context_t *rc5_context = (rc5_context_t *) context->context;
register uint32_t *s = rc5_context->skey;
uint8_t i, tmp;
uint8_t i;
c2l(block, l);
block += 4;
c2l(block, r);
@ -74,7 +74,7 @@ int rc5_encrypt(cipher_context_t *context, uint8_t *block,
for (i = RC5_ROUNDS; i > 0; i--) {
l ^= r;
tmp = r;
uint8_t tmp = r;
tmp &= 0x1f;
rotl32(l, tmp);
l += *s++;
@ -98,7 +98,7 @@ int rc5_decrypt(cipher_context_t *context, uint8_t *cipherBlock,
register uint32_t r;
rc5_context_t *rc5_context = (rc5_context_t *) context->context;
register uint32_t *s = rc5_context->skey + (2 * RC5_ROUNDS) + 1;
uint8_t i, tmp;
uint8_t i;
c2l(cipherBlock, l);
cipherBlock += 4;
@ -106,7 +106,7 @@ int rc5_decrypt(cipher_context_t *context, uint8_t *cipherBlock,
for (i = RC5_ROUNDS; i > 0; i--) {
r -= *s--;
tmp = l;
uint8_t tmp = l;
tmp &= 0x1f;
rotr32(r, tmp);
r ^= l;
@ -128,8 +128,8 @@ int rc5_decrypt(cipher_context_t *context, uint8_t *cipherBlock,
int rc5_setup_key(cipher_context_t *context, uint8_t *key, uint8_t keysize)
{
(void)keysize;
uint32_t *L, l, A, B, *S, k;
uint8_t ii, jj, m;
uint32_t *L, l, A, B, *S;
uint8_t ii, jj;
int8_t i;
uint8_t tmp[8];
rc5_context_t *rc5_context = (rc5_context_t *) context->context;
@ -159,11 +159,11 @@ int rc5_setup_key(cipher_context_t *context, uint8_t *key, uint8_t keysize)
S = rc5_context->skey;
for (i = 3 * (2 * RC5_ROUNDS + 2) - 1; i >= 0; i--) {
k = (*S + A + B)&RC5_32_MASK;
uint32_t k = (*S + A + B)&RC5_32_MASK;
rotl32((k), (3));
A = *S = k;
S++;
m = ((char)(A + B)) & 0x1f;
uint8_t m = ((char)(A + B)) & 0x1f;
k = (*L + A + B)&RC5_32_MASK;
rotl32((k), (m));
B = *L = k;

@ -528,6 +528,7 @@ static int twofish_set_key(twofish_context_t *ctx, uint8_t *key, uint8_t keylen)
/* The S vector used to key the S-boxes, split up into individual bytes.
* 128-bit keys use only sa through sh; 256-bit use all of them. */
uint8_t sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0, sh = 0;
/* cppcheck-suppress variableScope */
uint8_t si = 0, sj = 0, sk = 0, sl = 0, sm = 0, sn = 0, so = 0, sp = 0;
/* Temporary for CALC_S. */

@ -320,7 +320,6 @@ void icmpv6_send_echo_reply(ipv6_addr_t *destaddr, uint16_t id, uint16_t seq, ui
void icmpv6_send_router_sol(uint8_t sllao)
{
uint16_t packet_length;
int if_id = 0; // TODO get this somehow
ipv6_buf = ipv6_get_buf();
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
@ -343,6 +342,7 @@ void icmpv6_send_router_sol(uint8_t sllao)
if (sllao == OPT_SLLAO) {
opt_stllao_buf = get_opt_stllao_buf(ipv6_ext_hdr_len, icmpv6_opt_hdr_len);
int if_id = 0; // TODO get this somehow
if (net_if_get_src_address_mode(if_id) == NET_IF_TRANS_ADDR_M_LONG) {
icmpv6_ndp_set_sllao(opt_stllao_buf, if_id, NDP_OPT_SLLAO_TYPE, 2);
@ -430,7 +430,6 @@ void recv_echo_repl(void)
void recv_rtr_sol(void)
{
int if_id = 0; // TODO, get this somehow
icmpv6_opt_hdr_len = RTR_SOL_LEN;
ipv6_buf = ipv6_get_buf();
@ -456,6 +455,7 @@ void recv_rtr_sol(void)
return;
}
int if_id = 0; // TODO, get this somehow
if (nbr_entry != NULL) {
/* found neighbor in cache, update values and check addr */
if (memcmp(&llao[2], &nbr_entry->lladdr, lladdr_len) == 0) {
@ -1269,13 +1269,11 @@ void icmpv6_send_neighbor_adv(ipv6_addr_t *src, ipv6_addr_t *dst, ipv6_addr_t *t
void recv_nbr_adv(void)
{
int if_id = 0; // TODO, get this somehow
ipv6_buf = ipv6_get_buf();
uint16_t packet_length = IPV6_HDR_LEN + NTOHS(ipv6_buf->length);
icmpv6_opt_hdr_len = NBR_ADV_LEN;
llao = NULL;
nbr_entry = NULL;
int8_t new_ll = -1;
nbr_adv_buf = get_nbr_adv_buf(ipv6_ext_hdr_len);
/* check if options are present */
@ -1303,12 +1301,14 @@ void recv_nbr_adv(void)
nbr_entry = ndp_neighbor_cache_search(&nbr_adv_buf->target_addr);
if (nbr_entry != NULL) {
int8_t new_ll = -1;
if (llao != 0) {
new_ll = memcmp(&llao[2], &(nbr_entry->lladdr),
nbr_entry->lladdr_len);
((icmpv6_ndp_opt_stllao_t *)llao)->length = nbr_entry->lladdr_len / 8 + 1;
}
int if_id = 0; // TODO, get this somehow
if (nbr_entry->state == NDP_NCE_STATUS_INCOMPLETE) {
if (llao == NULL) {
return;
@ -1518,7 +1518,6 @@ ndp_neighbor_cache_t *ndp_get_ll_address(ipv6_addr_t *ipaddr)
int ndp_addr_is_on_link(ipv6_addr_t *dest_addr)
{
ndp_prefix_info_t *pi;
ndp_neighbor_cache_t *nce;
int if_id = -1;
@ -1531,6 +1530,7 @@ int ndp_addr_is_on_link(ipv6_addr_t *dest_addr)
}
while ((if_id = net_if_iter_interfaces(if_id)) >= 0) {
ndp_prefix_info_t *pi;
if ((pi = ndp_prefix_info_search(if_id, dest_addr, 128))) {
return (pi->flags & ICMPV6_NDP_OPT_PI_FLAG_ON_LINK) != 0;
}

@ -667,8 +667,6 @@ void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)
{
/* try to find best match if dest is not mcast or link local */
int if_id = 0; // TODO: get this somehow
uint8_t tmp = 0;
uint8_t bmatch = 0;
ipv6_net_if_addr_t *addr = NULL;
ipv6_net_if_addr_t *tmp_addr = NULL;
@ -679,8 +677,9 @@ void ipv6_net_if_get_best_src_addr(ipv6_addr_t *src, const ipv6_addr_t *dest)
if (!ipv6_addr_is_link_local(addr->addr_data) &&
!ipv6_addr_is_multicast(addr->addr_data) &&
!ipv6_addr_is_unique_local_unicast(addr->addr_data)) {
tmp = ipv6_get_addr_match(dest, addr->addr_data);
uint8_t bmatch = 0;
uint8_t tmp = ipv6_get_addr_match(dest, addr->addr_data);
if (tmp >= bmatch) {
bmatch = tmp;
tmp_addr = addr;

@ -364,10 +364,9 @@ static void *lowpan_transfer(void *arg)
msg_t m_recv, m_send;
ipv6_hdr_t *ipv6_buf;
lowpan_reas_buf_t *current_buf;
uint8_t gotosleep;
while (1) {
gotosleep = 1;
uint8_t gotosleep = 1;
mutex_lock(&fifo_mutex);
current_buf = packet_fifo;
@ -785,10 +784,6 @@ void lowpan_read(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
net_if_eui64_t *d_addr)
{
/* check if packet is fragmented */
uint8_t hdr_length = 0;
uint8_t datagram_offset = 0;
uint16_t datagram_size = 0;
uint16_t datagram_tag = 0;
short i;
check_timeout();
@ -807,6 +802,10 @@ void lowpan_read(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
/* Fragmented Packet */
if (((data[0] & SIXLOWPAN_FRAG_HDR_MASK) == SIXLOWPAN_FRAG1_DISPATCH) ||
((data[0] & SIXLOWPAN_FRAG_HDR_MASK) == SIXLOWPAN_FRAGN_DISPATCH)) {
uint8_t hdr_length = 0;
uint8_t datagram_offset = 0;
uint16_t datagram_size = 0;
uint16_t datagram_tag = 0;
uint16_t byte_offset;
DEBUG("INFO: fragmentation dispatch 0x%02x received\n",
data[0] & SIXLOWPAN_FRAG_HDR_MASK);
@ -1171,11 +1170,9 @@ void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
uint8_t *ipv6_hdr_fields = data;
uint8_t lowpan_iphc[2];
uint8_t cid = 0;
uint8_t sci = 0;
uint8_t dci = 0;
uint8_t ll_prefix[2] = {0xfe, 0x80};
uint8_t m_prefix[2] = {0xff, 0x02};
lowpan_context_t *con = NULL;
ipv6_buf = ipv6_get_buf();
@ -1275,6 +1272,7 @@ void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
if (lowpan_iphc[1] & SIXLOWPAN_IPHC2_SAC) {
/* 1: Source address compression uses stateful, context-based
* compression.*/
uint8_t sci = 0;
if (cid) {
sci = ipv6_hdr_fields[3] >> 4;
}
@ -1395,6 +1393,7 @@ void lowpan_iphc_decoding(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
mutex_unlock(&lowpan_context_mutex);
}
else {
uint8_t m_prefix[2] = {0xff, 0x02};
/* If M=1 and DAC=0: */
switch (lowpan_iphc[1] & 0x03) {
case (0x01): {
@ -1642,11 +1641,10 @@ static void *lowpan_context_auto_remove(void *arg)
timex_t minute = timex_set(60, 0);
int i;
int8_t to_remove[NDP_6LOWPAN_CONTEXT_MAX];
int8_t to_remove_size;
while (1) {
vtimer_sleep(minute);
to_remove_size = 0;
int8_t to_remove_size = 0;
mutex_lock(&lowpan_context_mutex);
for (i = 0; i < lowpan_context_len(); i++) {

@ -173,13 +173,12 @@ static void *etx_beacon(void *arg)
* and modifies the time to wait accordingly.
*/
etx_probe_t *packet = etx_get_send_buf();
uint8_t p_length = 0;
while (true) {
thread_sleep();
mutex_lock(&etx_mutex);
//Build etx packet
p_length = 0;
uint8_t p_length = 0;
for (uint8_t i = 0; i < ETX_BEST_CANDIDATES; i++) {
if (candidates[i].used != 0) {

@ -322,10 +322,10 @@ socket_internal_t *get_waiting_connection_socket(int socket,
tcp_hdr_t *tcp_header)
{
int i;
socket_internal_t *current_socket, *listening_socket = socket_base_get_socket(socket);
socket_internal_t *listening_socket = socket_base_get_socket(socket);
for (i = 1; i < MAX_SOCKETS + 1; i++) {
current_socket = socket_base_get_socket(i);
socket_internal_t *current_socket = socket_base_get_socket(i);
if (!current_socket) {
continue;
@ -473,10 +473,9 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
socket_internal_t *tcp_socket)
{
msg_t m_recv_tcp, m_send_tcp;
uint8_t target_pid;
if (tcp_socket->socket_values.tcp_control.state == TCP_LAST_ACK) {
target_pid = tcp_socket->recv_pid;
uint8_t target_pid = tcp_socket->recv_pid;
memset(tcp_socket, 0, sizeof(socket_internal_t));
msg_send(&m_send_tcp, target_pid, 0);
return;
@ -621,14 +620,13 @@ void handle_tcp_fin_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
void handle_tcp_no_flags_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
socket_internal_t *tcp_socket, uint8_t *payload, uint8_t tcp_payload_len)
{
uint8_t read_bytes = 0;
socket_t *current_tcp_socket = &tcp_socket->socket_values;
uint8_t send_buffer[BUFFER_SIZE];
ipv6_hdr_t *temp_ipv6_header = ((ipv6_hdr_t *)(&send_buffer));
tcp_hdr_t *current_tcp_packet = ((tcp_hdr_t *)(&send_buffer[IPV6_HDR_LEN]));
if (check_tcp_consistency(current_tcp_socket, tcp_header, tcp_payload_len) == PACKET_OK) {
read_bytes = handle_payload(ipv6_header, tcp_header, tcp_socket, payload);
uint8_t read_bytes = handle_payload(ipv6_header, tcp_header, tcp_socket, payload);
/* Refresh TCP status values */
current_tcp_socket->tcp_control.state = TCP_ESTABLISHED;
@ -662,16 +660,13 @@ void *tcp_packet_handler(void *arg)
(void) arg;
msg_t m_recv_ip, m_send_ip;
ipv6_hdr_t *ipv6_header;
tcp_hdr_t *tcp_header;
uint8_t *payload;
socket_internal_t *tcp_socket = NULL;
uint16_t chksum;
while (1) {
msg_receive(&m_recv_ip);
ipv6_header = ((ipv6_hdr_t *)m_recv_ip.content.ptr);
ipv6_hdr_t *ipv6_header = ((ipv6_hdr_t *)m_recv_ip.content.ptr);
tcp_header = ((tcp_hdr_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN));
#ifdef TCP_HC
tcp_socket = decompress_tcp_packet(ipv6_header);
@ -679,9 +674,9 @@ void *tcp_packet_handler(void *arg)
switch_tcp_packet_byte_order(tcp_header);
tcp_socket = get_tcp_socket(ipv6_header, tcp_header);
#endif
chksum = tcp_csum(ipv6_header, tcp_header);
uint16_t chksum = tcp_csum(ipv6_header, tcp_header);
payload = (uint8_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN + tcp_header->data_offset * 4);
uint8_t *payload = (uint8_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN + tcp_header->data_offset * 4);
if ((chksum == 0xffff) && (tcp_socket != NULL)) {
#ifdef TCP_HC
@ -1333,7 +1328,6 @@ int32_t tcp_recv(int s, void *buf, uint32_t len, int flags)
(void) flags;
/* Variables */
uint8_t read_bytes;
msg_t m_recv, m_send;
socket_internal_t *current_int_tcp_socket;
@ -1355,7 +1349,7 @@ int32_t tcp_recv(int s, void *buf, uint32_t len, int flags)
msg_receive(&m_recv);
if ((socket_base_exists_socket(s)) && (current_int_tcp_socket->tcp_input_buffer_end > 0)) {
read_bytes = read_from_socket(current_int_tcp_socket, buf, len);
uint8_t read_bytes = read_from_socket(current_int_tcp_socket, buf, len);
socket_base_net_msg_reply(&m_recv, &m_send, UNDEFINED);
return read_bytes;
}

@ -410,7 +410,6 @@ socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header)
uint8_t *packet_buffer = ((uint8_t *)temp_ipv6_header) + IPV6_HDR_LEN;
uint16_t tcp_hc_header;
socket_internal_t *current_socket = NULL;
uint16_t packet_size = 0;
/* Full header TCP segment */
if (*(((uint8_t *)temp_ipv6_header) + IPV6_HDR_LEN) == 0x01) {
@ -442,6 +441,8 @@ socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header)
}
/* Compressed header TCP segment */
else {
uint16_t packet_size = 0;
/* Temporary TCP Header */
tcp_hdr_t full_tcp_header;
memset(&full_tcp_header, 0, sizeof(tcp_hdr_t));

@ -68,12 +68,11 @@ void handle_established(socket_internal_t *current_socket)
current_timeout = SECOND;
}
uint8_t i;
if ((current_socket->socket_values.tcp_control.send_nxt >
current_socket->socket_values.tcp_control.send_una) &&
(thread_getstatus(current_socket->send_pid) == STATUS_RECEIVE_BLOCKED)) {
for (i = 0; i < current_socket->socket_values.tcp_control.no_of_retries;
for (uint8_t i = 0; i < current_socket->socket_values.tcp_control.no_of_retries;
i++) {
current_timeout *= 2;
}
@ -94,11 +93,10 @@ void handle_established(socket_internal_t *current_socket)
void check_sockets(void)
{
socket_internal_t *current_socket;
uint8_t i = 1;
while (i < MAX_SOCKETS + 1) {
current_socket = socket_base_get_socket(i);
socket_internal_t *current_socket = socket_base_get_socket(i);
if (tcp_socket_compliancy(i)) {
switch (current_socket->socket_values.tcp_control.state) {

@ -70,19 +70,16 @@ void *udp_packet_handler(void *arg)
(void) arg;
msg_t m_recv_ip, m_send_ip, m_recv_udp, m_send_udp;
ipv6_hdr_t *ipv6_header;
udp_hdr_t *udp_header;
socket_internal_t *udp_socket = NULL;
uint16_t chksum;
msg_init_queue(udp_msg_queue, UDP_PKT_RECV_BUF_SIZE);
while (1) {
msg_receive(&m_recv_ip);
ipv6_header = ((ipv6_hdr_t *)m_recv_ip.content.ptr);
udp_header = ((udp_hdr_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN));
ipv6_hdr_t *ipv6_header = ((ipv6_hdr_t *)m_recv_ip.content.ptr);
udp_hdr_t *udp_header = ((udp_hdr_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN));
chksum = ipv6_csum(ipv6_header, (uint8_t*) udp_header, NTOHS(udp_header->length), IPPROTO_UDP);
uint16_t chksum = ipv6_csum(ipv6_header, (uint8_t*) udp_header, NTOHS(udp_header->length), IPPROTO_UDP);
if (chksum == 0xffff) {
udp_socket = get_udp_socket(udp_header);

Loading…
Cancel
Save