Lines Matching full:socket
12 #include <zephyr/net/socket.h>
34 int socket = zsock_socket(addr->sa_family, SOCK_DGRAM, IPPROTO_UDP); in transport_socket_open() local
41 if (socket < 0) { in transport_socket_open()
45 if (zsock_setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &feature_on, sizeof(feature_on))) { in transport_socket_open()
50 if (zsock_bind(socket, addr, sizeof(*addr))) { in transport_socket_open()
51 LOG_ERR("Failed to bind socket"); in transport_socket_open()
56 if (cnt > 0 && zsock_setsockopt(socket, in transport_socket_open()
61 LOG_ERR("Failed to set socket binding to an interface"); in transport_socket_open()
65 if (zsock_setsockopt(socket, SOL_SOCKET, SO_TIMESTAMPING, &ts_mask, sizeof(ts_mask))) { in transport_socket_open()
70 if (zsock_setsockopt(socket, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority))) { in transport_socket_open()
75 return socket; in transport_socket_open()
77 zsock_close(socket); in transport_socket_open()
89 zsock_setsockopt(port->socket[1], IPPROTO_IP, in transport_join_multicast()
97 zsock_setsockopt(port->socket[0], IPPROTO_IPV6, in transport_join_multicast()
108 int socket, ttl = 1; in transport_udp_ipv4_open() local
115 socket = transport_socket_open(iface, (struct sockaddr *)&addr); in transport_udp_ipv4_open()
116 if (socket < 0) { in transport_udp_ipv4_open()
120 if (zsock_setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl))) { in transport_udp_ipv4_open()
121 LOG_ERR("Failed to set ip multicast ttl socket option"); in transport_udp_ipv4_open()
125 if (zsock_getsockopt(socket, IPPROTO_IP, IP_TOS, &tos, &length)) { in transport_udp_ipv4_open()
133 if (zsock_setsockopt(socket, IPPROTO_IP, IP_TOS, &tos, length)) { in transport_udp_ipv4_open()
137 return socket; in transport_udp_ipv4_open()
139 zsock_close(socket); in transport_udp_ipv4_open()
147 int socket, hops = 1, feature_on = 1; in transport_udp_ipv6_open() local
154 socket = transport_socket_open(iface, (struct sockaddr *)&addr); in transport_udp_ipv6_open()
155 if (socket < 0) { in transport_udp_ipv6_open()
159 if (zsock_setsockopt(socket, in transport_udp_ipv6_open()
168 if (zsock_setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hops, sizeof(hops))) { in transport_udp_ipv6_open()
169 LOG_ERR("Failed to set ip multicast hops socket option"); in transport_udp_ipv6_open()
173 if (zsock_getsockopt(socket, IPPROTO_IPV6, IPV6_TCLASS, &tclass, &length)) { in transport_udp_ipv6_open()
181 if (zsock_setsockopt(socket, IPPROTO_IPV6, IPV6_TCLASS, &tclass, length)) { in transport_udp_ipv6_open()
185 return socket; in transport_udp_ipv6_open()
187 zsock_close(socket); in transport_udp_ipv6_open()
191 static int transport_send(int socket, int port, void *buf, int length, struct sockaddr *addr) in transport_send() argument
215 cnt = zsock_sendto(socket, buf, length, 0, addr, addrlen); in transport_send()
227 int socket; in ptp_transport_open() local
230 socket = IS_ENABLED(CONFIG_PTP_UDP_IPv4_PROTOCOL) ? in ptp_transport_open()
234 if (socket == -1) { in ptp_transport_open()
236 zsock_close(port->socket[PTP_SOCKET_EVENT]); in ptp_transport_open()
237 port->socket[PTP_SOCKET_EVENT] = -1; in ptp_transport_open()
243 port->socket[i] = socket; in ptp_transport_open()
253 if (port->socket[i] >= 0) { in ptp_transport_close()
254 if (zsock_close(port->socket[i])) { in ptp_transport_close()
255 LOG_ERR("Failed to close socket on PTP Port %d", in ptp_transport_close()
261 port->socket[i] = -1; in ptp_transport_close()
269 __ASSERT(PTP_SOCKET_CNT > idx, "Invalid socket index"); in ptp_transport_send()
274 return transport_send(port->socket[idx], socket_port[idx], msg, length, NULL); in ptp_transport_send()
279 __ASSERT(PTP_SOCKET_CNT > idx, "Invalid socket index"); in ptp_transport_sendto()
284 return transport_send(port->socket[idx], socket_port[idx], msg, length, &msg->addr); in ptp_transport_sendto()
289 __ASSERT(PTP_SOCKET_CNT > idx, "Invalid socket index"); in ptp_transport_recv()
305 cnt = zsock_recvmsg(port->socket[idx], &msghdr, ZSOCK_MSG_DONTWAIT); in ptp_transport_recv()