Lines Matching defs:sock

154 static int netlink_sock(int *sock, uint32_t *seq_nr, int proto)
156 if (*sock > 0) {
161 *sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, proto);
162 if (*sock <= 0) {
246 static int netlink_check_answer(int sock)
254 if (recv(sock, &answer, sizeof(answer), 0) < 0) {
269 static int veth_add(int sock, uint32_t seq, const char *peera, int ns_a,
312 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) {
316 return netlink_check_answer(sock);
319 static int ip4_addr_set(int sock, uint32_t seq, const char *intf,
354 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) {
358 return netlink_check_answer(sock);
361 static int link_set_up(int sock, uint32_t seq, const char *intf)
380 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) {
384 return netlink_check_answer(sock);
387 static int ip4_route_set(int sock, uint32_t seq, const char *intf,
418 if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) {
423 return netlink_check_answer(sock);
581 unsigned int *server_port, int sock[2])
587 sock[0] = socket(AF_INET, SOCK_DGRAM, 0);
588 if (sock[0] < 0) {
597 if (bind(sock[0], (struct sockaddr *)&server, s_len)) {
602 if (getsockname(sock[0], (struct sockaddr *)&server, &s_len)) {
609 if (setsockopt(sock[0], SOL_SOCKET, SO_RCVTIMEO, (const char *)&t, sizeof t)) {
614 sock[1] = socket(AF_INET, SOCK_DGRAM, 0);
615 if (sock[1] < 0) {
623 close(sock[0]);
627 static int udp_ping_send(int sock[2], in_addr_t dest_ip, unsigned int port,
639 s_bytes = sendto(sock[1], buf, buf_len, 0, dest_addr, sizeof(server));
648 r_bytes = recv(sock[0], sock_buf, buf_len, 0);
664 static int udp_ping_reply(int sock[2], in_addr_t dest_ip, unsigned int port,
676 r_bytes = recv(sock[0], sock_buf, buf_len, 0);
691 s_bytes = sendto(sock[1], buf, buf_len, 0, dest_addr, sizeof(server));
703 typedef int (*ping_f)(int sock[2], in_addr_t dest_ip, unsigned int port,
1337 static int netlink_sock_bind(int *sock, uint32_t *seq, int proto, uint32_t groups)
1346 if (netlink_sock(sock, seq, proto)) {
1351 if (bind(*sock, (struct sockaddr *)&snl, sizeof(snl)) < 0) {
1357 if (getsockname(*sock, (struct sockaddr *)&snl, &addr_len) < 0) {
1372 close(*sock);
1680 /* Check that seq sock is ready, just for sure. */