Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,32 @@ Building
The rpcapd source code is a few levels deep in the winpcap folder:
[winpcap/wpcap/libpcap/rpcapd/](winpcap/wpcap/libpcap/rpcapd/)

To build, first install gcc and libpcap-dev:
### Linux
To build on Linux, first install gcc and libpcap-dev:

sudo apt-get install build-essential libpcap-dev

Then make in the top-level folder:

make

The resulting binary, `rpcapd`, will be in the rpcapd directory:
[winpcap/wpcap/libpcap/rpcapd/](winpcap/wpcap/libpcap/rpcapd/)
### macOS
To build on macOS, first install libpcap (if not already available):

brew install libpcap

Then make in the top-level folder with the OSX platform:

make PLATFORM=osx

### Windows
(Optional) To build the windows binary, install x86_64-w64-mingw32-gcc (or
edit vars.mk). Running `make` will output rpcapd.exe in the rpcapd directory
in addition to the linux binary.

The resulting binary, `rpcapd`, will be in the rpcapd directory:
[winpcap/wpcap/libpcap/rpcapd/](winpcap/wpcap/libpcap/rpcapd/)


ExtraHop Modifications
----------------------
Expand Down
2 changes: 1 addition & 1 deletion vars.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OSXCC = xcrun -sdk macosx10.8 clang
OSXCC = xcrun clang
LINUXCC = gcc
WINCC = x86_64-w64-mingw32-gcc # 64-bit

Expand Down
2 changes: 1 addition & 1 deletion winpcap/wpcap/libpcap/bpf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.14.4.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
#endif

Expand Down
6 changes: 2 additions & 4 deletions winpcap/wpcap/libpcap/bpf_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/bpf_image.c,v 1.27.2.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
#endif

Expand All @@ -38,9 +38,7 @@ static const char rcsid[] _U_ =
#endif

char *
bpf_image(p, n)
const struct bpf_insn *p;
int n;
bpf_image(const struct bpf_insn *p, int n)
{
int v;
const char *fmt, *op;
Expand Down
2 changes: 1 addition & 1 deletion winpcap/wpcap/libpcap/gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.290.2.16 2008-09-22 20:16:01 guy Exp $ (LBL)";
#endif

Expand Down
5 changes: 5 additions & 0 deletions winpcap/wpcap/libpcap/gencode.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _GENCODE_H_
#define _GENCODE_H_

/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
Expand Down Expand Up @@ -337,3 +340,5 @@ void sappend(struct slist *, struct slist *);
#define JF(b) ((b)->ef.succ)

extern int no_optimize;

#endif /* _GENCODE_H_ */
5 changes: 4 additions & 1 deletion winpcap/wpcap/libpcap/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
*
*/
#ifndef lint
static const char rcsid[] _U_ =
#ifndef GRAMMAR_RCSID_DEFINED
#define GRAMMAR_RCSID_DEFINED
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.99.2.2 2007/11/18 02:04:55 guy Exp $ (LBL)";
#endif
#endif

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down
20 changes: 7 additions & 13 deletions winpcap/wpcap/libpcap/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.75.2.4 2008-04-20 18:19:24 guy Exp $ (LBL)";
#endif

Expand Down Expand Up @@ -73,8 +73,10 @@ struct rtentry; /* declarations in <net/if.h> */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#else
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#endif

#include "pcap-int.h"

Expand Down Expand Up @@ -602,8 +604,7 @@ pcap_freealldevs(pcap_if_t *alldevs)
* lowest unit number is preferred; loopback is ignored.
*/
char *
pcap_lookupdev(errbuf)
register char *errbuf;
pcap_lookupdev(register char *errbuf)
{
pcap_if_t *alldevs;
/* for old BSD systems, including bsdi3 */
Expand Down Expand Up @@ -644,10 +645,7 @@ pcap_lookupdev(errbuf)
}

int
pcap_lookupnet(device, netp, maskp, errbuf)
register const char *device;
register bpf_u_int32 *netp, *maskp;
register char *errbuf;
pcap_lookupnet(register const char *device, register bpf_u_int32 *netp, register bpf_u_int32 *maskp, register char *errbuf)
{
register int fd;
register struct sockaddr_in *sin4;
Expand Down Expand Up @@ -735,8 +733,7 @@ pcap_lookupnet(device, netp, maskp, errbuf)
* lowest unit number is preferred; loopback is ignored.
*/
char *
pcap_lookupdev(errbuf)
register char *errbuf;
pcap_lookupdev(register char *errbuf)
{
DWORD dwVersion;
DWORD dwWindowsMajorVersion;
Expand Down Expand Up @@ -817,10 +814,7 @@ pcap_lookupdev(errbuf)


int
pcap_lookupnet(device, netp, maskp, errbuf)
register const char *device;
register bpf_u_int32 *netp, *maskp;
register char *errbuf;
pcap_lookupnet(register const char *device, register bpf_u_int32 *netp, register bpf_u_int32 *maskp, register char *errbuf)
{
/*
* We need only the first IPv4 address, so we must scan the array returned by PacketGetNetInfo()
Expand Down
5 changes: 2 additions & 3 deletions winpcap/wpcap/libpcap/nametoaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.82.2.1 2008/02/06 10:21:47 guy Exp $ (LBL)";
#endif

Expand Down Expand Up @@ -346,8 +346,7 @@ pcap_nametollc(const char *s)

/* Hex digit to integer. */
static inline int
xdtoi(c)
register int c;
xdtoi(register int c)
{
if (isdigit(c))
return c - '0';
Expand Down
2 changes: 1 addition & 1 deletion winpcap/wpcap/libpcap/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Optimization module for tcpdump intermediate representation.
*/
#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.90.2.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
#endif

Expand Down
8 changes: 6 additions & 2 deletions winpcap/wpcap/libpcap/pcap-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
extern "C" {
#endif

#ifndef _U_
#define _U_
#endif

#ifdef HAVE_LIBDLPI
#include <libdlpi.h>
#endif
Expand Down Expand Up @@ -446,7 +450,7 @@ int yylex(void);
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);

#ifndef HAVE_STRLCPY
#if !defined(HAVE_STRLCPY) && !defined(__APPLE__)
#define strlcpy(x, y, z) \
(strncpy((x), (y), (z)), \
((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
Expand All @@ -460,7 +464,7 @@ int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
extern int snprintf (char *, size_t, const char *, ...);
#endif

#if !defined(HAVE_VSNPRINTF)
#if !defined(HAVE_VSNPRINTF) && !defined(__APPLE__)
#define vsnprintf pcap_vsnprintf
extern int vsnprintf (char *, size_t, const char *, va_list ap);
#endif
Expand Down
2 changes: 1 addition & 1 deletion winpcap/wpcap/libpcap/pcap-new.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pcap_if_t *dev; // Previous device into the pcap_if_t chain
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

if ( (port == NULL) || (port[0] == 0) )
if (port[0] == 0)
{
// the user chose not to specify the port
if (sock_initaddress(host, RPCAP_DEFAULT_NETPORT, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
Expand Down
9 changes: 5 additions & 4 deletions winpcap/wpcap/libpcap/pcap-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ struct timeval tv; // maximum time the select() can block waiting for data
else
{
// In case of TCP, read the remaining of the packet from the socket
if ( (nread+= sock_recv(p->rmt_sockdata, *pkt_data, (*pkt_header)->caplen, SOCK_RECEIVEALL_YES, p->errbuf, PCAP_ERRBUF_SIZE)) == -1)
if ( (nread+= sock_recv(p->rmt_sockdata, (char *)*pkt_data, (*pkt_header)->caplen, SOCK_RECEIVEALL_YES, p->errbuf, PCAP_ERRBUF_SIZE)) == -1)
return -1;

// Checks if all the data has been read; if not, discard the data in excess
Expand Down Expand Up @@ -723,7 +723,7 @@ struct rpcap_openreply openreply; // open reply message
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;

if ( (ctrlport == NULL) || (ctrlport[0] == 0) )
if (ctrlport[0] == 0)
{
// the user chose not to specify the port
if (sock_initaddress(host, RPCAP_DEFAULT_NETPORT, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1)
Expand Down Expand Up @@ -891,7 +891,8 @@ struct rpcap_startcapreq *startcapreq; // start capture request message
struct rpcap_startcapreply startcapreply; // start capture reply message

// Variables related to the buffer setting
int res, itemp;
int res;
socklen_t itemp;
int sockbufsize= 0;


Expand Down Expand Up @@ -1894,7 +1895,7 @@ void rpcap_createhdr(struct rpcap_header *header, uint8 type, uint16 value, uint
it discards the message body (i.e. it reads the remaining part of the message from the
network and it discards it) so that the application is ready to receive a new message.
*/
int rpcap_checkmsg(char *errbuf, SOCKET sock, struct rpcap_header *header, uint8 first, ...)
int rpcap_checkmsg(char *errbuf, SOCKET sock, struct rpcap_header *header, int first, ...)
{
va_list ap;
uint8 type;
Expand Down
2 changes: 1 addition & 1 deletion winpcap/wpcap/libpcap/pcap-remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void pcap_cleanup_remote(pcap_t *p);

void rpcap_createhdr(struct rpcap_header *header, uint8 type, uint16 value, uint32 length);
int rpcap_deseraddr(struct sockaddr_storage *sockaddrin, struct sockaddr_storage **sockaddrout, char *errbuf);
int rpcap_checkmsg(char *errbuf, SOCKET sock, struct rpcap_header *header, uint8 first, ...);
int rpcap_checkmsg(char *errbuf, SOCKET sock, struct rpcap_header *header, int first, ...);
int rpcap_senderror(SOCKET sock, char *error, unsigned short errcode, char *errbuf);
int rpcap_sendauth(SOCKET sock, struct pcap_rmtauth *auth, char *errbuf);

Expand Down
4 changes: 2 additions & 2 deletions winpcap/wpcap/libpcap/pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/

#ifndef lint
static const char rcsid[] _U_ =
static const char rcsid[] __attribute__((unused)) =
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.112.2.12 2008-09-22 20:16:01 guy Exp $ (LBL)";
#endif

Expand Down Expand Up @@ -1022,7 +1022,7 @@ pcap_strerror(int errnum)
#ifdef HAVE_STRERROR
return (strerror(errnum));
#else
extern int sys_nerr;
extern const int sys_nerr;
extern const char *const sys_errlist[];
static char ebuf[15+10+1];

Expand Down
Loading