Lines Matching +full:buffered +full:- +full:negative
2 * Copyright (c) 2002 - 2003
62 #include "rpcap-protocol.h"
105 // and a platform-dependent (UN*X vs. Windows) identifier for the
170 uint8 type; // ContentType - will be 22, for Handshake
173 // This is *not* aligned on a 2-byte boundary; we just
201 * Maximum sizes for fixed-bit-width values.
251 // a TLS handshake message or a non-TLS rpcapd message.
263 if (nrecv == -1)
289 // isn't one, assume it's a non-TLS rpcapd message.
297 // We assume this is a non-TLS rpcapd message.
302 if (nrecv == -1)
307 if (nrecv == -2)
315 if (rpcapd_discard(sockctrl, NULL, plen) == -1)
327 "TLS is required by this server", errbuf) == -1)
349 // We're expecting a non-TLS rpcapd message. If this
365 if (nrecv == -1)
379 if (rpcapd_discard(sockctrl, NULL, plen) == -1)
394 TLS_RECORD_HEADER_LEN, errbuf, PCAP_ERRBUF_SIZE) == -1)
404 TLS_ALERT_LEN, errbuf, PCAP_ERRBUF_SIZE) == -1)
448 &fromlen) == -1)
452 if (rpcap_senderror(pars.sockctrl, pars.ssl, 0, PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
465 if (host_port_check_status == -2) {
475 if (rpcap_senderror(pars.sockctrl, pars.ssl, 0, PCAP_ERR_HOSTNOAUTH, errmsgbuf, errbuf) == -1)
523 if (retval == -1)
527 if (rpcap_senderror(pars.sockctrl, pars.ssl, 0, PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
536 if (rpcap_senderror(pars.sockctrl, pars.ssl, 0, PCAP_ERR_INITTIMEOUT, "The RPCAP initial timeout has expired", errbuf) == -1)
546 if (nrecv == -1)
551 if (nrecv == -2)
571 errbuf) == -1)
588 if (retval == -1)
594 if (retval == -2)
596 // Non-fatal error; we sent back
619 // XXX - is this what happens in active
650 errmsgbuf, errbuf) == -1)
656 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
673 // These are server-to-client messages.
678 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message %s received from client", msg_type_string);
682 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message of type %u received from client", header.type);
686 errmsgbuf, errbuf) == -1)
692 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
706 errmsgbuf, errbuf) == -1)
712 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
744 // - I have to be in normal mode (no active mode)
745 // - if the device is open, I don't have to be in the middle of a capture (session->sockdata)
746 // - if the device is closed, I have always to check if a new command arrives
750 if ((!pars.isactive) && (session == NULL || session->sockdata == 0))
764 if (retval == -1)
770 errmsgbuf, errbuf) == -1)
782 errbuf) == -1)
792 if (nrecv == -1)
797 if (nrecv == -2)
820 errbuf) == -1)
839 // XXX - actually exit....
845 if (daemon_msg_findallif_req(header.ver, &pars, plen) == -1)
861 // XXX - we don't care if the client sends
867 if (retval == -1)
887 errbuf) == -1)
894 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
903 uses_ssl) == -1)
917 &pars, session, plen) == -1)
930 errbuf) == -1)
955 session, plen, &stats, svrcapt) == -1)
969 if (pcap_stats(session->fp, &stats))
971 svrcapt = session->TotCapt;
982 &pars, session) == -1)
1007 &pars, plen, &samp_param) == -1)
1027 errbuf) == -1)
1033 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
1050 // These are server-to-client messages.
1055 rpcapd_log(LOGPRIO_INFO, "The client sent a %s server-to-client message", msg_type_string);
1056 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message %s received from client", msg_type_string);
1060 rpcapd_log(LOGPRIO_INFO, "The client sent a server-to-client message of type %u", header.type);
1061 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message of type %u received from client", header.type);
1065 errmsgbuf, errbuf) == -1)
1071 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
1086 errbuf, errmsgbuf) == -1)
1092 if (rpcapd_discard(pars.sockctrl, pars.ssl, plen) == -1)
1150 if (sock_recv(sockctrl, ssl, remote_errbuf, PCAP_ERRBUF_SIZE - 1,
1152 PCAP_ERRBUF_SIZE) == -1)
1156 return -1;
1158 if (rpcapd_discard(sockctrl, ssl, plen - (PCAP_ERRBUF_SIZE - 1)) == -1)
1161 return -1;
1165 * Null-terminate it.
1167 remote_errbuf[PCAP_ERRBUF_SIZE - 1] = '\0';
1178 PCAP_ERRBUF_SIZE) == -1)
1182 return -1;
1186 * Null-terminate it.
1208 * \param errbuf: a user-allocated buffer in which the error message
1212 * \return '0' if everything is fine, '-1' if an unrecoverable error occurred,
1213 * or '-2' if the authentication failed. For errors, an error message is
1224 char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered
1225 int sendbufidx = 0; // index which keeps the number of bytes currently buffered
1228 status = rpcapd_recv(pars->sockctrl, pars->ssl, (char *) &auth, sizeof(struct rpcap_auth), &plen, errmsgbuf);
1229 if (status == -1)
1231 return -1;
1233 if (status == -2)
1242 if (!pars->nullAuthAllowed)
1247 if (rpcap_senderror(pars->sockctrl, pars->ssl,
1248 0, PCAP_ERR_AUTH_FAILED, errmsgbuf, errbuf) == -1)
1252 return -1;
1272 status = rpcapd_recv(pars->sockctrl, pars->ssl, username, usernamelen, &plen, errmsgbuf);
1273 if (status == -1)
1276 return -1;
1278 if (status == -2)
1294 status = rpcapd_recv(pars->sockctrl, pars->ssl, passwd, passwdlen, &plen, errmsgbuf);
1295 if (status == -1)
1299 return -1;
1301 if (status == -2)
1317 if (rpcap_senderror(pars->sockctrl, pars->ssl,
1318 0, PCAP_ERR_AUTH_FAILED, errmsgbuf, errbuf) == -1)
1322 return -1;
1347 if (rpcap_senderror(pars->sockctrl, pars->ssl,
1348 0, PCAP_ERR_AUTH_TYPE_NOTSUP, errmsgbuf, errbuf) == -1)
1352 return -1;
1359 RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1368 RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1373 // version of the byte-order magic is (which will tell the
1375 // case they will need to byte-swap some fields in some
1376 // link-layer types' headers).
1379 authreply->minvers = RPCAP_MIN_VERSION;
1380 authreply->maxvers = RPCAP_MAX_VERSION;
1381 authreply->byte_order_magic = RPCAP_BYTE_ORDER_MAGIC;
1384 if (sock_send(pars->sockctrl, pars->ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
1388 return -1;
1392 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
1394 return -1;
1400 if (rpcap_senderror(pars->sockctrl, pars->ssl, 0, PCAP_ERR_AUTH,
1401 errmsgbuf, errbuf) == -1)
1405 return -1;
1410 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
1412 return -1;
1415 return -2;
1431 * XXX - hopefully, this returns errors such as ERROR_LOGON_FAILURE,
1434 * that's incorrect, so a client that's trying to brute-force
1456 return -1;
1468 return -1;
1488 * XXX - perhaps what we *should* be using is PAM, if we have
1490 * authentication, whether it's done with a visible-to-root-
1506 return -1;
1514 return -1;
1516 user_password = usersp->sp_pwdp;
1519 * XXX - what about other platforms?
1521 * running as root - it's from 2000, so it doesn't indicate whether
1524 * HP-UX does something else.
1528 user_password = user->pw_passwd;
1552 return -1;
1557 return -1;
1560 if (setuid(user->pw_uid))
1567 return -1;
1570 /* if (setgid(user->pw_gid))
1577 return -1;
1594 if (replylen > UINT32_MAX - (itemlen)) { \
1606 char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered
1607 int sendbufidx = 0; // index which keeps the number of bytes currently buffered
1615 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
1618 return -1;
1622 if (pcap_findalldevs(&alldevs, errmsgbuf) == -1)
1627 if (rpcap_senderror(pars->sockctrl, pars->ssl, ver,
1631 errbuf) == -1)
1634 return -1;
1642 for (d = alldevs; d != NULL; d = d->next)
1646 if (d->description) {
1647 size_t stringlen = strlen(d->description);
1656 if (d->name) {
1657 size_t stringlen = strlen(d->name);
1670 for (address = d->addresses; address != NULL; address = address->next)
1675 switch (address->addr->sa_family)
1700 PCAP_ERRBUF_SIZE) == -1)
1707 for (d = alldevs; d != NULL; d = d->next)
1712 // aligned on 4-byte boundaries, because they're
1713 // preceded by strings that aren't padded to 4-byte
1716 // and store into them - we must fill in a structure and
1720 // the lower-order bits).
1727 if (d->description)
1728 ldescr = (uint16) strlen(d->description);
1731 if (d->name)
1732 lname = (uint16) strlen(d->name);
1738 findalldevs_if.flags = htonl(d->flags);
1741 for (address = d->addresses; address != NULL; address = address->next)
1746 switch (address->addr->sa_family)
1764 PCAP_ERRBUF_SIZE) == -1)
1767 if (sock_bufferize(d->name, lname, sendbuf, &sendbufidx,
1769 PCAP_ERRBUF_SIZE) == -1)
1772 if (sock_bufferize(d->description, ldescr, sendbuf, &sendbufidx,
1774 PCAP_ERRBUF_SIZE) == -1)
1778 for (address = d->addresses; address != NULL; address = address->next)
1785 switch (address->addr->sa_family)
1793 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1795 daemon_seraddr((struct sockaddr_storage *) address->addr, sockaddr);
1799 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1801 daemon_seraddr((struct sockaddr_storage *) address->netmask, sockaddr);
1805 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1807 daemon_seraddr((struct sockaddr_storage *) address->broadaddr, sockaddr);
1811 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1813 daemon_seraddr((struct sockaddr_storage *) address->dstaddr, sockaddr);
1826 if (sock_send(pars->sockctrl, pars->ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
1829 return -1;
1838 if (rpcap_senderror(pars->sockctrl, pars->ssl, ver,
1839 PCAP_ERR_FINDALLIF, errmsgbuf, errbuf) == -1)
1842 return -1;
1859 char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered
1860 int sendbufidx = 0; // index which keeps the number of bytes currently buffered
1863 if (plen > sourcelen - 1)
1869 nread = sock_recv(pars->sockctrl, pars->ssl, source, plen,
1871 if (nread == -1)
1874 return -1;
1877 plen -= nread;
1898 RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1907 RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
1911 openreply->linktype = htonl(pcap_datalink(fp));
1919 openreply->tzoff = 0;
1925 if (sock_send(pars->sockctrl, pars->ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
1928 return -1;
1933 if (rpcap_senderror(pars->sockctrl, pars->ssl, ver, PCAP_ERR_OPEN,
1934 errmsgbuf, errbuf) == -1)
1938 return -1;
1942 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
1944 return -1;
1964 char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered
1965 int sendbufidx = 0; // index which keeps the number of bytes currently buffered
1967 // socket-related variables
1974 // RPCAP-related variables
1981 status = rpcapd_recv(pars->sockctrl, pars->ssl, (char *) &startcapreq,
1983 if (status == -1)
1987 if (status == -2)
2011 session->sockdata = INVALID_SOCKET;
2012 session->ctrl_ssl = session->data_ssl = NULL;
2014 session->have_thread = 0;
2025 session->thread = INVALID_HANDLE_VALUE;
2027 memset(&session->thread, 0, sizeof(session->thread));
2031 if ((session->fp = pcap_open_live(source,
2040 fp->rmt_samp.method = samp_param->method;
2041 fp->rmt_samp.value = samp_param->value;
2046 - we're using TCP, and the user wants us to be in active mode
2047 - we're using UDP
2049 serveropen_dp = (startcapreq.flags & RPCAP_STARTCAPREQ_FLAG_SERVEROPEN) || (startcapreq.flags & RPCAP_STARTCAPREQ_FLAG_DGRAM) || pars->isactive;
2055 - if we're in passive mode, we need to know the address family we want to use
2057 - if we're in active mode, we need to know the network address of the other host
2061 if (getpeername(pars->sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1)
2091 if ((session->sockdata = sock_open(peerhost, addrinfo, SOCKOPEN_CLIENT, 0, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
2104 if ((session->sockdata = sock_open(NULL, addrinfo, SOCKOPEN_SERVER, 1 /* max 1 connection in queue */, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
2109 if (getsockname(session->sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1)
2131 session->sockctrl = pars->sockctrl;
2132 session->ctrl_ssl = pars->ssl;
2133 session->protocol_version = ver;
2136 ret = daemon_unpackapplyfilter(pars->sockctrl, pars->ssl, session, &plen, errmsgbuf);
2137 if (ret == -1)
2142 if (ret == -2)
2144 // Non-fatal error. Send an error message to the client.
2150 RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
2159 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
2163 startcapreply->bufsize = htonl(pcap_bufsize(session->fp));
2168 startcapreply->portdata = htons(port);
2171 if (sock_send(pars->sockctrl, pars->ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
2185 socktemp = accept(session->sockdata, (struct sockaddr *) &saddr, &saddrlen);
2197 sock_close(session->sockdata, NULL, 0);
2198 session->sockdata = socktemp;
2208 ssl = ssl_promotion(1, session->sockdata, errbuf, PCAP_ERRBUF_SIZE);
2216 session->data_ssl = ssl;
2220 session->thread = (HANDLE)_beginthreadex(NULL, 0, daemon_thrdatamain,
2222 if (session->thread == 0)
2228 ret = pthread_create(&session->thread, NULL, daemon_thrdatamain,
2237 session->have_thread = 1;
2240 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2262 if (rpcap_senderror(pars->sockctrl, pars->ssl, ver,
2263 PCAP_ERR_STARTCAPTURE, errmsgbuf, errbuf) == -1)
2267 return -1;
2271 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2274 return -1;
2292 return -1;
2306 if (sock_send(pars->sockctrl, pars->ssl, (char *) &header, sizeof(struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
2310 return -1;
2324 // the in-kernel limit for Linux and 16 times the in-kernel limit for
2327 // It also prevents an overflow on 32-bit platforms when calculating
2328 // the total size of the filter program. (It's not an issue on 64-bit
2329 // platforms with a 64-bit size_t, as the filter size is 32 bits.)
2345 if (status == -1)
2347 return -1;
2349 if (status == -2)
2351 return -2;
2359 return -2;
2367 return -2;
2374 return -2;
2383 if (status == -1)
2385 return -1;
2387 if (status == -2)
2389 return -2;
2392 bf_insn->code = ntohs(insn.code);
2393 bf_insn->jf = insn.jf;
2394 bf_insn->jt = insn.jt;
2395 bf_insn->k = ntohl(insn.k);
2401 // XXX - pcap_setfilter() should do the validation for us.
2406 return -2;
2409 if (pcap_setfilter(session->fp, &bf_prog))
2411 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "RPCAP error: %s", pcap_geterr(session->fp));
2412 return -2;
2427 ret = daemon_unpackapplyfilter(pars->sockctrl, pars->ssl, session, &plen, errmsgbuf);
2428 if (ret == -1)
2431 return -1;
2433 if (ret == -2)
2435 // Non-fatal error. Send an error reply to the client.
2440 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2443 return -1;
2449 if (sock_send(pars->sockctrl, pars->ssl, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE))
2453 return -1;
2459 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2461 return -1;
2463 rpcap_senderror(pars->sockctrl, pars->ssl, ver, PCAP_ERR_UPDATEFILTER,
2482 status = rpcapd_recv(pars->sockctrl, pars->ssl, (char *) &rpcap_samp, sizeof(struct rpcap_sampling), &plen, errmsgbuf);
2483 if (status == -1)
2485 return -1;
2487 if (status == -2)
2493 samp_param->method = rpcap_samp.method;
2494 samp_param->value = ntohl(rpcap_samp.value);
2499 if (sock_send(pars->sockctrl, pars->ssl, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
2503 return -1;
2506 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2508 return -1;
2514 if (rpcap_senderror(pars->sockctrl, pars->ssl, ver, PCAP_ERR_SETSAMPLING,
2515 errmsgbuf, errbuf) == -1)
2519 return -1;
2523 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2525 return -1;
2538 char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered
2539 int sendbufidx = 0; // index which keeps the number of bytes currently buffered
2543 if (rpcapd_discard(pars->sockctrl, pars->ssl, plen) == -1)
2546 return -1;
2550 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
2559 &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
2562 if (session && session->fp)
2564 if (pcap_stats(session->fp, stats) == -1)
2566 snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "%s", pcap_geterr(session->fp));
2570 netstats->ifdrop = htonl(stats->ps_ifdrop);
2571 netstats->ifrecv = htonl(stats->ps_recv);
2572 netstats->krnldrop = htonl(stats->ps_drop);
2573 netstats->svrcapt = htonl(session->TotCapt);
2580 netstats->ifdrop = htonl(stats->ps_ifdrop);
2581 netstats->ifrecv = htonl(stats->ps_recv);
2582 netstats->krnldrop = htonl(stats->ps_drop);
2583 netstats->svrcapt = htonl(svrcapt);
2587 if (sock_send(pars->sockctrl, pars->ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
2590 return -1;
2596 rpcap_senderror(pars->sockctrl, pars->ssl, ver, PCAP_ERR_GETSTATS,
2615 char *sendbuf; // temporary buffer in which data to be sent is buffered
2616 int sendbufidx; // index which keeps the number of bytes currently buffered
2624 session->TotCapt = 0; // counter which is incremented each time a packet is received
2631 // for a maximum-size packet for this pcap_t.
2633 if (pcap_snapshot(session->fp) < 0)
2636 // The snapshot length is negative.
2640 "Unable to allocate the buffer for this child thread: snapshot length of %d is negative",
2641 pcap_snapshot(session->fp));
2649 // a maximum-sized packet is impossibly large, the sum of the
2657 // do so on 64-bit UN*Xes, but can't do so on Windows, not even
2658 // 64-bit Windows, as the send() buffer size argument is an int
2661 sendbufsize = sizeof(struct rpcap_header) + sizeof(struct rpcap_pkthdr) + pcap_snapshot(session->fp);
2682 // packets - we dn't want any other system calls, such as
2700 retval = pcap_next_ex(session->fp, &pkt_header, (const u_char **) &pkt_data); // cast to avoid a compiler warning
2717 PCAP_ERRBUF_SIZE) == -1)
2726 session->protocol_version, RPCAP_MSG_PACKET, 0,
2727 (uint16) (sizeof(struct rpcap_pkthdr) + pkt_header->caplen));
2734 PCAP_ERRBUF_SIZE) == -1)
2742 net_pkt_header->caplen = htonl(pkt_header->caplen);
2743 net_pkt_header->len = htonl(pkt_header->len);
2744 net_pkt_header->npkt = htonl(++(session->TotCapt));
2747 // before 2038-01-19 03:14:07 UTC.
2749 net_pkt_header->timestamp_sec = htonl((uint32)pkt_header->ts.tv_sec);
2750 net_pkt_header->timestamp_usec = htonl((uint32)pkt_header->ts.tv_usec);
2753 if (sock_bufferize((char *) pkt_data, pkt_header->caplen,
2755 errbuf, PCAP_ERRBUF_SIZE) == -1)
2766 status = sock_send(session->sockdata, session->data_ssl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE);
2769 if (status == -1)
2797 snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error reading the packets: %s", pcap_geterr(session->fp));
2798 rpcap_senderror(session->sockctrl, session->ctrl_ssl, session->protocol_version,
2813 // Do-nothing handler for SIGUSR1; the sole purpose of SIGUSR1 is to
2848 // neatly aligned on 4-byte boundaries, so we must fill
2851 switch (sockaddrin->ss_family)
2861 sockaddrout_ipv4.port = htons(sockaddrin_ipv4->sin_port);
2862 memcpy(&sockaddrout_ipv4.addr, &sockaddrin_ipv4->sin_addr, sizeof(sockaddrout_ipv4.addr));
2877 sockaddrout_ipv6.port = htons(sockaddrin_ipv6->sin6_port);
2878 sockaddrout_ipv6.flowinfo = htonl(sockaddrin_ipv6->sin6_flowinfo);
2879 memcpy(&sockaddrout_ipv6.addr, &sockaddrin_ipv6->sin6_addr, sizeof(sockaddrout_ipv6.addr));
2880 sockaddrout_ipv6.scope_id = htonl(sockaddrin_ipv6->sin6_scope_id);
2920 if (nread == -1)
2924 return -1;
2929 return -2;
2931 headerp->plen = ntohl(headerp->plen);
2938 * message into errmsgbuf and returns -2. Otherwise, tries to read
2941 * Returns 0 on success, logs a message and returns -1 on a network
2954 return -2;
2958 if (nread == -1)
2961 return -1;
2963 *plen -= nread;
2969 * Mostly used to discard wrong-sized messages.
2970 * Returns 0 on success, logs a message and returns -1 on a network
2980 if (sock_discard(sock, ssl, len, errbuf, PCAP_ERRBUF_SIZE) == -1)
2984 return -1;
2991 // Shut down any packet-capture thread associated with the session,
3001 if (session->have_thread)
3010 pcap_breakloop(session->fp);
3022 // XXX - what about modules other than NPF?
3024 SetEvent(pcap_getevent(session->fp));
3030 // XXX - have a timeout, so we don't wait forever?
3032 WaitForSingleObject(session->thread, INFINITE);
3038 CloseHandle(session->thread);
3039 session->have_thread = 0;
3040 session->thread = INVALID_HANDLE_VALUE;
3049 pthread_kill(session->thread, SIGUSR1);
3055 // XXX - have a timeout, so we don't wait forever?
3057 pthread_join(session->thread, NULL);
3058 session->have_thread = 0;
3059 memset(&session->thread, 0, sizeof(session->thread));
3064 if (session->data_ssl)
3068 ssl_finish(session->data_ssl);
3069 session->data_ssl = NULL;
3073 if (session->sockdata != INVALID_SOCKET)
3075 sock_close(session->sockdata, NULL, 0);
3076 session->sockdata = INVALID_SOCKET;
3079 if (session->fp)
3081 pcap_close(session->fp);
3082 session->fp = NULL;
3100 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
3102 * hier-part = "//" authority path-abempty
3103 * / path-absolute
3104 * / path-rootless
3105 * / path-empty
3109 * userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
3128 * hier-part = "//" authority path-abempty, not
3129 * hier-part = path-absolute
3130 * hier-part = path-rootless
3131 * hier-part = path-empty