void runFailure3() { struct in_addr addr; uint32_t mode; struct sockaddr_storage store; struct sockaddr_storage buf[] = { store, store, store }; struct sockaddr memb; struct sockaddr groups[] = { memb, memb }; uint32_t len = 30; setsourcefilter(anyint(), anyint(), groups, 2, mode, len, buf); }
void testValues() { f = 2; struct in_addr addr; uint32_t mode; struct sockaddr_storage store; struct sockaddr_storage buf[] = { store, store, store }; struct sockaddr memb; struct sockaddr groups[] = { memb, memb }; uint32_t len = 3; setsourcefilter(anyint(), anyint(), groups, 2, mode, len, buf); //@ assert f == 2; //@ assert vacuous: \false; }
/* * Set IPv4 source filter list in use on socket. * * Stubbed to setsourcefilter(). Performs conversion of structures which * may be inefficient; applications are encouraged to use the * protocol-independent API. */ int setipv4sourcefilter(int s, struct in_addr interface, struct in_addr group, uint32_t fmode, uint32_t numsrc, struct in_addr *slist) { #ifdef INET sockunion_t tmpgroup; struct in_addr *pina; sockunion_t *psu, *tmpslist; int err; size_t i; uint32_t ifindex; assert(s != -1); tmpslist = NULL; if (!IN_MULTICAST(ntohl(group.s_addr)) || (fmode != MCAST_INCLUDE && fmode != MCAST_EXCLUDE)) { errno = EINVAL; return (-1); } ifindex = __inaddr_to_index(interface.s_addr); if (ifindex == 0) { errno = EADDRNOTAVAIL; return (-1); } memset(&tmpgroup, 0, sizeof(sockunion_t)); tmpgroup.sin.sin_family = AF_INET; tmpgroup.sin.sin_len = sizeof(struct sockaddr_in); tmpgroup.sin.sin_addr = group; if (numsrc != 0 || slist != NULL) { tmpslist = calloc(numsrc, sizeof(sockunion_t)); if (tmpslist == NULL) { errno = ENOMEM; return (-1); } pina = slist; psu = tmpslist; for (i = 0; i < numsrc; i++, pina++, psu++) { psu->sin.sin_family = AF_INET; psu->sin.sin_len = sizeof(struct sockaddr_in); psu->sin.sin_addr = *pina; } } err = setsourcefilter(s, ifindex, (struct sockaddr *)&tmpgroup, sizeof(struct sockaddr_in), fmode, numsrc, (struct sockaddr_storage *)tmpslist); if (tmpslist != NULL) { free(tmpslist); } return (err); #else /* !INET */ return (EAFNOSUPPORT); #endif /* INET */ }