bool is_four_touple(socket_internal_t *current_socket, ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header) { return (ipv6_addr_is_equal(¤t_socket->socket_values.local_address.sin6_addr, &ipv6_header->destaddr) && (current_socket->socket_values.local_address.sin6_port == tcp_header->dst_port) && ipv6_addr_is_equal(¤t_socket->socket_values.foreign_address.sin6_addr, &ipv6_header->srcaddr) && (current_socket->socket_values.foreign_address.sin6_port == tcp_header->src_port)); }
socket_internal_t *get_tcp_socket_by_context(ipv6_hdr_t *current_ipv6_header, uint16_t current_context) { socket_internal_t *temp_socket; for (int i = 1; i < MAX_SOCKETS + 1; i++) { temp_socket = socket_base_get_socket(i); if ((temp_socket != NULL) && ipv6_addr_is_equal(&temp_socket->socket_values.foreign_address.sin6_addr, ¤t_ipv6_header->srcaddr) && ipv6_addr_is_equal(&temp_socket->socket_values.local_address.sin6_addr, ¤t_ipv6_header->destaddr) && (temp_socket->socket_values.tcp_control.tcp_context.context_id == current_context)) { return temp_socket; } } return NULL; }
void rpl_add_srh_entry(ipv6_addr_t *child, ipv6_addr_t *parent, uint16_t lifetime) { rpl_routing_entry_t *entry = rpl_find_routing_entry(child); /* If we already have this entry and the parent from parent/child is the same as already * registered, we only update the lifetime. If only the parent of the child changes, we * delete the previous entry and add it below. */ if (entry != NULL) { if (ipv6_addr_is_equal(parent, &entry->next_hop)) { entry->lifetime = lifetime; return; } else { rpl_del_routing_entry(child); } } /* This maybe a bit confusing since the root also using the standard routing table, * but in this case the code stays cleaner - especially for rt_over_timer from trickle.c. * Just keep in mind that address is now child (unique, iteration variable) and parent is * now next_hop. The whole routing table transforms to a list of children and their parents, * so that route aggregation can be done properly. */ DEBUGF("Adding source-routing entry child: %s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, child)); DEBUGF("Adding source-routing entry parent: %s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, parent)); for (uint8_t i = 0; i < rpl_max_routing_entries; i++) { if (!rpl_routing_table[i].used) { memcpy(&rpl_routing_table[i].address, child, sizeof(ipv6_addr_t)); memcpy(&rpl_routing_table[i].next_hop, parent, sizeof(ipv6_addr_t)); rpl_routing_table[i].lifetime = lifetime; rpl_routing_table[i].used = 1; break; } } }