Lines Matching full:socket

27 	struct eswifi_off_socket *socket = context->offload_context;  in eswifi_off_bind()  local
33 err = __eswifi_bind(eswifi, socket, addr, addrlen); in eswifi_off_bind()
41 struct eswifi_off_socket *socket = context->offload_context; in eswifi_off_listen() local
49 __select_socket(eswifi, socket->index); in eswifi_off_listen()
59 socket->is_server = true; in eswifi_off_listen()
68 struct eswifi_off_socket *socket; in eswifi_off_connect_work() local
75 socket = CONTAINER_OF(work, struct eswifi_off_socket, connect_work); in eswifi_off_connect_work()
76 eswifi = eswifi_socket_to_dev(socket); in eswifi_off_connect_work()
80 cb = socket->conn_cb; in eswifi_off_connect_work()
81 context = socket->context; in eswifi_off_connect_work()
82 user_data = socket->conn_data; in eswifi_off_connect_work()
84 err = __eswifi_off_start_client(eswifi, socket); in eswifi_off_connect_work()
86 socket->state = ESWIFI_SOCKET_STATE_CONNECTED; in eswifi_off_connect_work()
87 net_context_set_state(socket->context, NET_CONTEXT_CONNECTED); in eswifi_off_connect_work()
89 socket->state = ESWIFI_SOCKET_STATE_NONE; in eswifi_off_connect_work()
106 struct eswifi_off_socket *socket = context->offload_context; in eswifi_off_connect() local
119 if (socket->state != ESWIFI_SOCKET_STATE_NONE) { in eswifi_off_connect()
124 socket->peer_addr = *addr; in eswifi_off_connect()
125 socket->conn_data = user_data; in eswifi_off_connect()
126 socket->conn_cb = cb; in eswifi_off_connect()
127 socket->state = ESWIFI_SOCKET_STATE_CONNECTING; in eswifi_off_connect()
131 k_work_submit_to_queue(&eswifi->work_q, &socket->connect_work); in eswifi_off_connect()
136 err = __eswifi_off_start_client(eswifi, socket); in eswifi_off_connect()
138 socket->state = ESWIFI_SOCKET_STATE_CONNECTED; in eswifi_off_connect()
140 socket->state = ESWIFI_SOCKET_STATE_NONE; in eswifi_off_connect()
156 struct eswifi_off_socket *socket = context->offload_context; in eswifi_off_accept() local
162 ret = __eswifi_accept(eswifi, socket); in eswifi_off_accept()
168 socket->accept_cb = cb; in eswifi_off_accept()
169 socket->accept_data = user_data; in eswifi_off_accept()
170 k_sem_reset(&socket->accept_sem); in eswifi_off_accept()
178 return k_sem_take(&socket->accept_sem, K_MSEC(timeout)); in eswifi_off_accept()
182 struct eswifi_off_socket *socket) in __eswifi_off_send_pkt() argument
184 struct net_pkt *pkt = socket->tx_pkt; in __eswifi_off_send_pkt()
196 __select_socket(eswifi, socket->index); in __eswifi_off_send_pkt()
223 struct eswifi_off_socket *socket; in eswifi_off_send_work() local
230 socket = CONTAINER_OF(work, struct eswifi_off_socket, send_work); in eswifi_off_send_work()
231 eswifi = eswifi_socket_to_dev(socket); in eswifi_off_send_work()
235 user_data = socket->send_data; in eswifi_off_send_work()
236 cb = socket->send_cb; in eswifi_off_send_work()
237 context = socket->context; in eswifi_off_send_work()
239 err = __eswifi_off_send_pkt(eswifi, socket); in eswifi_off_send_work()
240 socket->tx_pkt = NULL; in eswifi_off_send_work()
254 struct eswifi_off_socket *socket = pkt->context->offload_context; in eswifi_off_send() local
255 struct eswifi_dev *eswifi = eswifi_by_iface_idx(socket->context->iface); in eswifi_off_send()
262 if (socket->state != ESWIFI_SOCKET_STATE_CONNECTED) { in eswifi_off_send()
267 if (socket->tx_pkt) { in eswifi_off_send()
271 socket->tx_pkt = pkt; in eswifi_off_send()
274 socket->send_data = user_data; in eswifi_off_send()
275 socket->send_cb = cb; in eswifi_off_send()
277 k_work_submit_to_queue(&eswifi->work_q, &socket->send_work); in eswifi_off_send()
284 err = __eswifi_off_send_pkt(eswifi, socket); in eswifi_off_send()
285 socket->tx_pkt = NULL; in eswifi_off_send()
290 cb(socket->context, err, user_data); in eswifi_off_send()
303 struct eswifi_off_socket *socket = pkt->context->offload_context; in eswifi_off_sendto() local
304 struct eswifi_dev *eswifi = eswifi_by_iface_idx(socket->context->iface); in eswifi_off_sendto()
311 if (socket->tx_pkt) { in eswifi_off_sendto()
316 socket->tx_pkt = pkt; in eswifi_off_sendto()
318 if (socket->state != ESWIFI_SOCKET_STATE_CONNECTED) { in eswifi_off_sendto()
319 socket->peer_addr = *dst_addr; in eswifi_off_sendto()
320 err = __eswifi_off_start_client(eswifi, socket); in eswifi_off_sendto()
326 socket->state = ESWIFI_SOCKET_STATE_CONNECTED; in eswifi_off_sendto()
330 socket->send_data = user_data; in eswifi_off_sendto()
331 socket->send_cb = cb; in eswifi_off_sendto()
333 k_work_submit_to_queue(&eswifi->work_q, &socket->send_work); in eswifi_off_sendto()
340 err = __eswifi_off_send_pkt(eswifi, socket); in eswifi_off_sendto()
341 socket->tx_pkt = NULL; in eswifi_off_sendto()
346 cb(socket->context, err, user_data); in eswifi_off_sendto()
357 struct eswifi_off_socket *socket = context->offload_context; in eswifi_off_recv() local
365 socket->recv_cb = cb; in eswifi_off_recv()
366 socket->recv_data = user_data; in eswifi_off_recv()
367 k_sem_reset(&socket->read_sem); in eswifi_off_recv()
374 err = k_sem_take(&socket->read_sem, K_MSEC(timeout)); in eswifi_off_recv()
378 socket->recv_cb = NULL; in eswifi_off_recv()
386 struct eswifi_off_socket *socket = context->offload_context; in eswifi_off_put() local
394 ret = __eswifi_socket_free(eswifi, socket); in eswifi_off_put()
399 if (--socket->usage <= 0) { in eswifi_off_put()
400 socket->context = NULL; in eswifi_off_put()
413 struct eswifi_off_socket *socket = NULL; in eswifi_off_get() local
425 socket = &eswifi->socket[idx]; in eswifi_off_get()
426 (*context)->offload_context = socket; in eswifi_off_get()
428 LOG_DBG("Socket index %d", socket->index); in eswifi_off_get()
430 k_work_init(&socket->connect_work, eswifi_off_connect_work); in eswifi_off_get()
431 k_work_init(&socket->send_work, eswifi_off_send_work); in eswifi_off_get()
432 k_sem_init(&socket->read_sem, 1, 1); in eswifi_off_get()
433 k_sem_init(&socket->accept_sem, 1, 1); in eswifi_off_get()
435 k_work_reschedule_for_queue(&eswifi->work_q, &socket->read_work, in eswifi_off_get()
448 struct eswifi_off_socket *socket = NULL; in eswifi_offload_async_msg() local
474 struct eswifi_off_socket *s = &eswifi->socket[i]; in eswifi_offload_async_msg()
477 socket = s; in eswifi_offload_async_msg()
482 if (!socket) { in eswifi_offload_async_msg()
483 LOG_ERR("No listening socket"); in eswifi_offload_async_msg()
487 struct sockaddr_in *peer = net_sin(&socket->peer_addr); in eswifi_offload_async_msg()
493 socket->state = ESWIFI_SOCKET_STATE_CONNECTED; in eswifi_offload_async_msg()
494 socket->usage++; in eswifi_offload_async_msg()
497 socket->context->flags |= NET_CONTEXT_REMOTE_ADDR_SET; in eswifi_offload_async_msg()
498 memcpy(&socket->context->remote, &socket->peer_addr, in eswifi_offload_async_msg()
504 if (socket->accept_cb) { in eswifi_offload_async_msg()
505 socket->accept_cb(socket->context, in eswifi_offload_async_msg()
506 &socket->peer_addr, in eswifi_offload_async_msg()
508 socket->accept_data); in eswifi_offload_async_msg()
511 k_sem_give(&socket->accept_sem); in eswifi_offload_async_msg()