Lines Matching +full:everything +full:- +full:else
2 * Copyright (c) 2002 - 2003
59 #include "pcap-int.h"
133 if (remaining > fuzzSize - fuzzPos) { in fuzz_recv()
134 remaining = fuzzSize - fuzzPos; in fuzz_recv()
148 #else in sock_geterrcode()
166 #else in sock_vfmterrmsg()
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 in sock_geterrtype()
227 * or that it is set up, but it's IPv4-only or IPv6-only in sock_geterrtype()
231 * that, even if something else went wrong in another in sock_geterrtype()
242 #else in sock_geterrtype()
249 * Network errors that could be IPv4-specific, IPv6- in sock_geterrtype()
253 * everything else. in sock_geterrtype()
260 #else in sock_geterrtype()
274 * but overwrite everything else. in sock_geterrtype()
280 #else in sock_geterrtype()
290 * everything else. in sock_geterrtype()
296 * Anything else. in sock_geterrtype()
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; in sock_init()
342 #else
364 sockcount--; in sock_cleanup()
374 * \return '0' if the address is multicast, '-1' if it is not.
378 if (saddr->sa_family == PF_INET) in sock_ismcastaddr()
381 if (IN_MULTICAST(ntohl(saddr4->sin_addr.s_addr))) return 0; in sock_ismcastaddr()
382 else return -1; in sock_ismcastaddr()
384 else in sock_ismcastaddr()
387 if (IN6_IS_ADDR_MULTICAST(&saddr6->sin6_addr)) return 0; in sock_ismcastaddr()
388 else return -1; in sock_ismcastaddr()
406 return addr_a->info->ai_family - addr_b->info->ai_family; in compare_addrs_to_try_by_address_family()
418 if (addr_a->errtype == addr_b->errtype) in compare_addrs_to_try_by_status()
420 if (addr_a->errcode == addr_b->errcode) in compare_addrs_to_try_by_status()
422 return addr_a->info->ai_family - addr_b->info->ai_family; in compare_addrs_to_try_by_status()
424 return addr_a->errcode - addr_b->errcode; in compare_addrs_to_try_by_status()
427 return addr_a->errtype - addr_b->errtype; in compare_addrs_to_try_by_status()
438 sock = socket(addrinfo->ai_family, addrinfo->ai_socktype, in sock_create_socket()
439 addrinfo->ai_protocol); in sock_create_socket()
454 sizeof (int)) == -1) in sock_create_socket()
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. in sock_open()
535 * https://tools.ietf.org/html/rfc3493#section-3.7 in sock_open()
545 * pre-NT 6 Windows stacks don't support it, and the in sock_open()
553 * https://tools.ietf.org/html/rfc3493#section-5.3 in sock_open()
561 if (addrinfo->ai_family == PF_INET6) in sock_open()
565 (char *)&on, sizeof (int)) == -1) in sock_open()
576 if (bind(sock, addrinfo->ai_addr, (int) addrinfo->ai_addrlen) != 0) in sock_open()
583 if (addrinfo->ai_socktype == SOCK_STREAM) in sock_open()
584 if (listen(sock, nconn) == -1) in sock_open()
595 else /* we're the client */ in sock_open()
613 tempaddrinfo = tempaddrinfo->ai_next) in sock_open()
637 tempaddrinfo = tempaddrinfo->ai_next, i++) in sock_open()
672 current_af != tempaddrinfo->ai_family) in sock_open()
692 if (connect(sock, tempaddrinfo->ai_addr, (int) tempaddrinfo->ai_addrlen) == -1) in sock_open()
698 else in sock_open()
752 } else { in sock_open()
757 } else { in sock_open()
771 bufspaceleft = errbuflen - msglen; in sock_open()
781 sock_getascii_addrport((struct sockaddr_storage *) addrs_to_try[i].info->ai_addr, in sock_open()
786 bufspaceleft = errbuflen - msglen; in sock_open()
804 else in sock_open()
824 bufspaceleft = errbuflen - msglen; in sock_open()
839 bufspaceleft = errbuflen - msglen; in sock_open()
845 else in sock_open()
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; in sock_close()
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) in get_gai_errstring()
917 else if (portname != NULL) in get_gai_errstring()
920 else in get_gai_errstring()
946 "%sA non-recoverable error occurred when attempting to resolve %s", in get_gai_errstring()
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 { in sock_initaddress()
1135 } else { in sock_initaddress()
1155 * XXX - should we just check that at least *one* address is in sock_initaddress()
1158 * support? :-)) in sock_initaddress()
1160 if ((addrinfo->ai_family != PF_INET) && in sock_initaddress()
1161 (addrinfo->ai_family != PF_INET6)) in sock_initaddress()
1172 if ((addrinfo->ai_socktype == SOCK_STREAM) && in sock_initaddress()
1173 (sock_ismcastaddr(addrinfo->ai_addr) == 0)) in sock_initaddress()
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; in sock_send()
1236 #else in sock_send()
1240 * on errors on stream-oriented sockets when the other in sock_send()
1245 #else in sock_send()
1250 if (nsent == -1) in sock_send()
1270 return -2; in sock_send()
1274 #else in sock_send()
1283 return -2; in sock_send()
1288 return -1; in sock_send()
1291 remaining -= nsent; in sock_send()
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; in sock_bufferize()
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; in sock_recv()
1455 * XXX - what about MSG_PEEK? in sock_recv()
1458 if (nread == -2) return -1; in sock_recv()
1460 else in sock_recv()
1462 #else in sock_recv()
1466 if (nread == -1) in sock_recv()
1470 return -3; in sock_recv()
1473 return -1; in sock_recv()
1491 return -1; in sock_recv()
1493 else in sock_recv()
1510 remaining -= nread; in sock_recv()
1520 * Returns the size of the datagram on success or -1 on error.
1543 return -1; in sock_recv_dgram()
1551 return -1; in sock_recv_dgram()
1579 return -1; in sock_recv_dgram()
1581 #else /* _WIN32 */ in sock_recv_dgram()
1584 * a socket for a message-oriented protocol will discard in sock_recv_dgram()
1590 * when receiving a message for a message-oriented in sock_recv_dgram()
1608 #else in sock_recv_dgram()
1611 if (nread == -1) in sock_recv_dgram()
1614 return -3; in sock_recv_dgram()
1616 return -1; in sock_recv_dgram()
1620 * XXX - Solaris supports this, but only if you ask for the in sock_recv_dgram()
1633 return -1; in sock_recv_dgram()
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) in sock_discard()
1688 return -1; in sock_discard()
1690 size -= TEMP_BUF_SIZE; in sock_discard()
1699 if (sock_recv(sock, ssl, buffer, size, SOCK_RECEIVEALL_YES, errbuf, errbuflen) == -1) in sock_discard()
1700 return -1; in sock_discard()
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 con…
1732 * - '-2' in case or error. The error message is returned in the 'errbuf' variable.
1754 return -2; in sock_check_hostlist()
1795 if (sock_cmpaddr(from, (struct sockaddr_storage *) ai_next->ai_addr) == 0) in sock_check_hostlist()
1806 ai_next = ai_next->ai_next; in sock_check_hostlist()
1831 return -2; in sock_check_hostlist()
1832 } else { in sock_check_hostlist()
1839 return -1; in sock_check_hostlist()
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) in sock_cmpaddr()
1869 if (first->ss_family == AF_INET) in sock_cmpaddr()
1871 if (memcmp(&(((struct sockaddr_in *) first)->sin_addr), in sock_cmpaddr()
1872 &(((struct sockaddr_in *) second)->sin_addr), in sock_cmpaddr()
1876 else /* address family is AF_INET6 */ in sock_cmpaddr()
1878 if (memcmp(&(((struct sockaddr_in6 *) first)->sin6_addr), in sock_cmpaddr()
1879 &(((struct sockaddr_in6 *) second)->sin6_addr), in sock_cmpaddr()
1885 return -1; in sock_cmpaddr()
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) in sock_getmyinfo()
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; in sock_getascii_addrport()
2004 if (sockaddr->ss_family == AF_INET) in sock_getascii_addrport()
2006 else in sock_getascii_addrport()
2008 #else in sock_getascii_addrport()
2014 if ((sockaddr->ss_family == AF_INET6) && in sock_getascii_addrport()
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… in sock_getascii_addrport()
2030 errbuf[errbuflen - 1] = 0; in sock_getascii_addrport()
2036 address[addrlen - 1] = 0; in sock_getascii_addrport()
2042 port[portlen - 1] = 0; in sock_getascii_addrport()
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) in sock_present2network()
2102 memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in)); in sock_present2network()
2103 else in sock_present2network()
2104 memcpy(sockaddr, addrinfo->ai_addr, sizeof(struct sockaddr_in6)); in sock_present2network()
2106 if (addrinfo->ai_next != NULL) in sock_present2network()
2112 return -2; in sock_present2network()
2116 return -1; in sock_present2network()