Lines Matching full:contexts

81 static struct net_context contexts[NET_MAX_CONTEXT];  variable
83 /* We need to lock the contexts array as these APIs are typically called
187 if (!net_context_is_used(&contexts[i])) { in check_used_port()
191 if (context != NULL && context == &contexts[i]) { in check_used_port()
195 if (!(net_context_get_proto(&contexts[i]) == proto && in check_used_port()
197 contexts[i].local)->sin_port == local_port)) { in check_used_port()
201 if (net_context_is_bound_to_iface(&contexts[i])) { in check_used_port()
202 if (iface != NULL && iface != net_context_get_iface(&contexts[i])) { in check_used_port()
209 if (net_sin6_ptr(&contexts[i].local)->sin6_addr == NULL || in check_used_port()
210 net_sin6_ptr(&contexts[i].local)->sin6_family != AF_INET6) { in check_used_port()
215 net_sin6_ptr(&contexts[i].local)->sin6_addr) || in check_used_port()
219 net_context_is_reuseport_set(&contexts[i])) { in check_used_port()
225 !is_in_tcp_listen_state(&contexts[i]) && in check_used_port()
227 net_sin6_ptr(&contexts[i].local)->sin6_addr) && in check_used_port()
243 net_sin6_ptr(&contexts[i].local)-> in check_used_port()
248 net_context_is_reuseport_set(&contexts[i])) { in check_used_port()
254 is_in_tcp_time_wait_state(&contexts[i])) { in check_used_port()
269 if (net_sin_ptr(&contexts[i].local)->sin_addr == NULL || in check_used_port()
271 net_context_is_v6only_set(&contexts[i]) : true) && in check_used_port()
272 net_sin_ptr(&contexts[i].local)->sin_family != AF_INET)) { in check_used_port()
277 net_sin_ptr(&contexts[i].local)->sin_addr) || in check_used_port()
281 net_context_is_reuseport_set(&contexts[i])) { in check_used_port()
287 !is_in_tcp_listen_state(&contexts[i]) && in check_used_port()
289 net_sin_ptr(&contexts[i].local)->sin_addr) && in check_used_port()
305 net_sin_ptr(&contexts[i].local)-> in check_used_port()
310 net_context_is_reuseport_set(&contexts[i])) { in check_used_port()
316 is_in_tcp_time_wait_state(&contexts[i])) { in check_used_port()
532 if (net_context_is_used(&contexts[i])) { in net_context_get()
536 memset(&contexts[i], 0, sizeof(contexts[i])); in net_context_get()
542 if (net_tcp_get(&contexts[i]) < 0) { in net_context_get()
547 contexts[i].iface = -1; in net_context_get()
548 contexts[i].flags = 0U; in net_context_get()
549 atomic_set(&contexts[i].refcount, 1); in net_context_get()
551 net_context_set_family(&contexts[i], family); in net_context_get()
552 net_context_set_type(&contexts[i], type); in net_context_get()
553 net_context_set_proto(&contexts[i], proto); in net_context_get()
556 contexts[i].options.addr_preferences = IPV6_PREFER_SRC_PUBTMP_DEFAULT; in net_context_get()
560 contexts[i].options.rcvtimeo = K_FOREVER; in net_context_get()
563 contexts[i].options.sndtimeo = K_FOREVER; in net_context_get()
567 contexts[i].options.ipv6_v6only = true; in net_context_get()
570 (void)memset(&contexts[i].remote, 0, sizeof(struct sockaddr)); in net_context_get()
571 (void)memset(&contexts[i].local, 0, sizeof(struct sockaddr_ptr)); in net_context_get()
575 (struct sockaddr_in6 *)&contexts[i].local; in net_context_get()
577 find_available_port(&contexts[i], (struct sockaddr *)addr6); in net_context_get()
584 contexts[i].ipv6_hop_limit = INITIAL_HOP_LIMIT; in net_context_get()
585 contexts[i].ipv6_mcast_hop_limit = INITIAL_MCAST_HOP_LIMIT; in net_context_get()
588 struct sockaddr_in *addr = (struct sockaddr_in *)&contexts[i].local; in net_context_get()
591 find_available_port(&contexts[i], (struct sockaddr *)addr); in net_context_get()
598 contexts[i].ipv4_ttl = INITIAL_TTL; in net_context_get()
599 contexts[i].ipv4_mcast_ttl = INITIAL_MCAST_TTL; in net_context_get()
604 k_sem_init(&contexts[i].recv_data_wait, 1, K_SEM_MAX_LIMIT); in net_context_get()
607 k_mutex_init(&contexts[i].lock); in net_context_get()
609 contexts[i].flags |= NET_CONTEXT_IN_USE; in net_context_get()
610 *context = &contexts[i]; in net_context_get()
683 if (!PART_OF_ARRAY(contexts, context)) { in net_context_put()
847 NET_ASSERT(PART_OF_ARRAY(contexts, context)); in net_context_bind()
1188 if (!net_context_is_used(&contexts[i])) { in find_context()
1192 if (contexts[i].conn_handler == conn_handler) { in find_context()
1193 return &contexts[i]; in find_context()
1204 NET_ASSERT(PART_OF_ARRAY(contexts, context)); in net_context_listen()
1328 NET_ASSERT(PART_OF_ARRAY(contexts, context)); in net_context_connect()
1510 NET_ASSERT(PART_OF_ARRAY(contexts, context)); in net_context_accept()
2219 NET_ASSERT(PART_OF_ARRAY(contexts, context)); in context_sendto()
3551 if (!PART_OF_ARRAY(contexts, context)) { in net_context_set_option()
3644 if (!PART_OF_ARRAY(contexts, context)) { in net_context_get_option()
3773 if (!net_context_is_used(&contexts[i])) { in net_context_foreach()
3777 k_mutex_lock(&contexts[i].lock, K_FOREVER); in net_context_foreach()
3779 cb(&contexts[i], user_data); in net_context_foreach()
3781 k_mutex_unlock(&contexts[i].lock); in net_context_foreach()