Lines Matching +full:everything +full:- +full:else

2  * Copyright (c) 2002 - 2003
59 #include "pcap-int.h"
133 if (remaining > fuzzSize - fuzzPos) {
134 remaining = fuzzSize - fuzzPos;
148 #else
166 #else
198 * so that lower-rated errors for a given address in a given family
199 * should not overwrite higher-rated errors for another address in that
200 * family, and higher-rated errors should overwrite lower-rated errors.
219 #else
227 * or that it is set up, but it's IPv4-only or IPv6-only
231 * that, even if something else went wrong in another
242 #else
249 * Network errors that could be IPv4-specific, IPv6-
253 * everything else.
260 #else
274 * but overwrite everything else.
280 #else
290 * everything else.
296 * Anything else.
312 * \param errbuf: a pointer to an user-allocated buffer that will contain
317 * The error message cannot be larger than 'errbuflen - 1' because the
320 * \return '0' if everything is fine, '-1' if some errors occurred. The
335 return -1;
342 #else
364 sockcount--;
374 * \return '0' if the address is multicast, '-1' if it is not.
378 if (saddr->sa_family == PF_INET)
381 if (IN_MULTICAST(ntohl(saddr4->sin_addr.s_addr))) return 0;
382 else return -1;
384 else
387 if (IN6_IS_ADDR_MULTICAST(&saddr6->sin6_addr)) return 0;
388 else return -1;
406 return addr_a->info->ai_family - addr_b->info->ai_family;
418 if (addr_a->errtype == addr_b->errtype)
420 if (addr_a->errcode == addr_b->errcode)
422 return addr_a->info->ai_family - addr_b->info->ai_family;
424 return addr_a->errcode - addr_b->errcode;
427 return addr_a->errtype - addr_b->errtype;
438 sock = socket(addrinfo->ai_family, addrinfo->ai_socktype,
439 addrinfo->ai_protocol);
454 sizeof (int)) == -1)
488 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
493 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
496 * if everything is fine, INVALID_SOCKET if some errors occurred. The error message is returned
530 * Force the use of IPv6-only addresses.
535 * https://tools.ietf.org/html/rfc3493#section-3.7
545 * pre-NT 6 Windows stacks don't support it, and the
553 * https://tools.ietf.org/html/rfc3493#section-5.3
561 if (addrinfo->ai_family == PF_INET6)
565 (char *)&on, sizeof (int)) == -1)
576 if (bind(sock, addrinfo->ai_addr, (int) addrinfo->ai_addrlen) != 0)
583 if (addrinfo->ai_socktype == SOCK_STREAM)
584 if (listen(sock, nconn) == -1)
595 else /* we're the client */
613 tempaddrinfo = tempaddrinfo->ai_next)
637 tempaddrinfo = tempaddrinfo->ai_next, i++)
672 current_af != tempaddrinfo->ai_family)
692 if (connect(sock, tempaddrinfo->ai_addr, (int) tempaddrinfo->ai_addrlen) == -1)
698 else
752 } else {
757 } else {
771 bufspaceleft = errbuflen - msglen;
781 sock_getascii_addrport((struct sockaddr_storage *) addrs_to_try[i].info->ai_addr,
786 bufspaceleft = errbuflen - msglen;
804 else
824 bufspaceleft = errbuflen - msglen;
839 bufspaceleft = errbuflen - msglen;
845 else
861 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
866 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
868 * \return '0' if everything is fine, '-1' if some errors occurred. The error message is returned
883 return -1;
893 * 1) on Windows, Microsoft explicitly says it's not thread-safe;
895 * thread-safe, so an implementation might use a static buffer
914 else if (hostname != NULL)
917 else if (portname != NULL)
920 else
946 "%sA non-recoverable error occurred when attempting to resolve %s",
1045 * to control that everything is fine (e.g. a TCP socket cannot have a mcast address, and such).
1052 * \param port: a pointer to a user-allocated buffer containing the network port to use.
1061 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1066 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1069 * if everything is fine, NULL if some errors occurred. The error message
1124 } else {
1135 } else {
1155 * XXX - should we just check that at least *one* address is
1158 * support? :-))
1160 if ((addrinfo->ai_family != PF_INET) &&
1161 (addrinfo->ai_family != PF_INET6))
1172 if ((addrinfo->ai_socktype == SOCK_STREAM) &&
1173 (sock_ismcastaddr(addrinfo->ai_addr) == 0))
1195 * \param buffer: a char pointer to a user-allocated buffer in which data is contained.
1199 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1204 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1206 * \return '0' if everything is fine, '-1' if an error other than
1208 * '-2' if we got one of those errors.
1225 return -1;
1236 #else
1240 * on errors on stream-oriented sockets when the other
1245 #else
1250 if (nsent == -1)
1270 return -2;
1274 #else
1283 return -2;
1288 return -1;
1291 remaining -= nsent;
1323 * \param outbuf: user-allocated buffer (of size 'totsize') into which data
1334 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1339 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1341 * \return '0' if everything is fine, '-1' if some errors occurred. The error message
1358 return -1;
1385 * \param buffer: a char pointer to a user-allocated buffer in which data has to be stored
1404 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1409 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1411 * \return the number of bytes read if everything is fine, '-1' if some errors occurred.
1435 return -1;
1455 * XXX - what about MSG_PEEK?
1458 if (nread == -2) return -1;
1460 else
1462 #else
1466 if (nread == -1)
1470 return -3;
1473 return -1;
1491 return -1;
1493 else
1510 remaining -= nread;
1520 * Returns the size of the datagram on success or -1 on error.
1543 return -1;
1551 return -1;
1579 return -1;
1581 #else /* _WIN32 */
1584 * a socket for a message-oriented protocol will discard
1590 * when receiving a message for a message-oriented
1608 #else
1611 if (nread == -1)
1614 return -3;
1616 return -1;
1620 * XXX - Solaris supports this, but only if you ask for the
1633 return -1;
1654 * this buffer is not large enough, it will cycle in order to read everything as well.
1660 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1665 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1667 * \return '0' if everything is fine, '-1' if some errors occurred.
1687 if (sock_recv(sock, ssl, buffer, TEMP_BUF_SIZE, SOCK_RECEIVEALL_YES, errbuf, errbuflen) == -1)
1688 return -1;
1690 size -= TEMP_BUF_SIZE;
1699 if (sock_recv(sock, ssl, buffer, size, SOCK_RECEIVEALL_YES, errbuf, errbuflen) == -1)
1700 return -1;
1721 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1726 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1729 * - '1' if the host list is empty
1730 * - '0' if the host belongs to the host list (and therefore it is allowed to connect)
1731 * - '-1' in case the host does not belong to the host list (and therefore it is not allowed to connect
1732 * - '-2' in case or error. The error message is returned in the 'errbuf' variable.
1754 return -2;
1795 if (sock_cmpaddr(from, (struct sockaddr_storage *) ai_next->ai_addr) == 0)
1806 ai_next = ai_next->ai_next;
1831 return -2;
1832 } else {
1839 return -1;
1856 * This function will return '0' if the two addresses matches, '-1' if not.
1863 * \return '0' if the addresses are equal, '-1' if they are different.
1867 if (first->ss_family == second->ss_family)
1869 if (first->ss_family == AF_INET)
1871 if (memcmp(&(((struct sockaddr_in *) first)->sin_addr),
1872 &(((struct sockaddr_in *) second)->sin_addr),
1876 else /* address family is AF_INET6 */
1878 if (memcmp(&(((struct sockaddr_in6 *) first)->sin6_addr),
1879 &(((struct sockaddr_in6 *) second)->sin6_addr),
1885 return -1;
1893 * - connected sockets
1894 * - server sockets
1915 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1920 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1922 * \return It returns '-1' if this function succeeds, '0' otherwise.
1938 if (getsockname(sock, (struct sockaddr *) &mysockaddr, &sockaddrlen) == -1)
1966 * zero-ed prior using it, and the address family field must be filled with the proper value.
1984 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
1989 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
1991 * \return It returns '-1' if this function succeeds, '0' otherwise.
2001 retval = -1;
2004 if (sockaddr->ss_family == AF_INET)
2006 else
2008 #else
2014 if ((sockaddr->ss_family == AF_INET6) &&
2015 (memcmp(&((struct sockaddr_in6 *) sockaddr)->sin6_addr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(struct in6_addr)) == 0))
2030 errbuf[errbuflen - 1] = 0;
2036 address[addrlen - 1] = 0;
2042 port[portlen - 1] = 0;
2061 * \param address: a zero-terminated string which contains the name you have to
2064 * \param sockaddr: a user-allocated sockaddr_storage structure which will contains the
2068 * - 'AF_INET' if we want to ping an IPv4 host
2069 * - 'AF_INET6' if we want to ping an IPv6 host
2070 * - 'AF_UNSPEC' if we do not have preferences about the protocol used to ping the host
2072 * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
2077 * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
2079 * \return '-1' if the translation succeeded, '-2' if there was some non critical error, '0'
2101 if (addrinfo->ai_family == PF_INET)
2102 memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in));
2103 else
2104 memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in6));
2106 if (addrinfo->ai_next != NULL)
2112 return -2;
2116 return -1;