static gboolean afsocket_sd_setup_socket(AFSocketSourceDriver *self, gint fd) { return afsocket_setup_socket(fd, self->sock_options_ptr, AFSOCKET_DIR_RECV); }
static gboolean afinet_setup_socket(gint fd, GSockAddr *addr, InetSocketOptions *sock_options, AFSocketDirection dir) { gint off = 0; if (!afsocket_setup_socket(fd, &sock_options->super, dir)) return FALSE; switch (addr->sa.sa_family) { case AF_INET: { struct ip_mreq mreq; if (IN_MULTICAST(ntohl(g_sockaddr_inet_get_address(addr).s_addr))) { if (dir & AFSOCKET_DIR_RECV) { memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr = g_sockaddr_inet_get_address(addr); mreq.imr_interface.s_addr = INADDR_ANY; /*CID 10352 (#1 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) return FALSE; /*CID 10352 (#2 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &off, sizeof(off))) return FALSE; } if (dir & AFSOCKET_DIR_SEND) { if (sock_options->ttl) /*CID 10352 (#3 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &sock_options->ttl, sizeof(sock_options->ttl))) return FALSE; } } else { if (sock_options->ttl && (dir & AFSOCKET_DIR_SEND)) /*CID 10352 (#4 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IP, IP_TTL, &sock_options->ttl, sizeof(sock_options->ttl))) return FALSE; } if (sock_options->tos && (dir & AFSOCKET_DIR_SEND)) /*CID 10352 (#5 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IP, IP_TOS, &sock_options->tos, sizeof(sock_options->tos))) return FALSE; break; } #if ENABLE_IPV6 case AF_INET6: { struct ipv6_mreq mreq6; if (IN6_IS_ADDR_MULTICAST(&g_sockaddr_inet6_get_sa(addr)->sin6_addr)) { if (dir & AFSOCKET_DIR_RECV) { memset(&mreq6, 0, sizeof(mreq6)); mreq6.ipv6mr_multiaddr = *g_sockaddr_inet6_get_address(addr); mreq6.ipv6mr_interface = 0; /*CID 10352 (#6 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof(mreq6))) return FALSE; /*CID 10352 (#7 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &off, sizeof(off))) return FALSE; } if (dir & AFSOCKET_DIR_SEND) { if (sock_options->ttl) /*CID 10352 (#8 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_HOPS, &sock_options->ttl, sizeof(sock_options->ttl))) return FALSE; } } else { if (sock_options->ttl && (dir & AFSOCKET_DIR_SEND)) /*CID 10352 (#9 of 9): Unchecked return value from library*/ if(setsockopt(fd, SOL_IPV6, IPV6_UNICAST_HOPS, &sock_options->ttl, sizeof(sock_options->ttl))) return FALSE; } break; } #endif } return TRUE; }
static gboolean afsocket_dd_setup_socket(AFSocketDestDriver *self, gint fd) { return afsocket_setup_socket(fd, self->sock_options_ptr, AFSOCKET_DIR_SEND); }