--- /dev/null
+.DS_Store
+*.xcodeproj/project.xcworkspace
+*.xcodeproj/xcuserdata
+.svn
+build
+*~.m
+*~.c
+*~.h
/*
- * Copyright (c) 2013-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2013-2016 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
kv.filter = EVFILT_READ;
kv.flags = EV_ADD;
if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1)
- err(1, "kevent(sf)");
-
- bzero(&kv, sizeof(struct kevent));
- kv.ident = fdin;
- kv.filter = EVFILT_READ;
- kv.flags = EV_ADD;
- if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1)
- err(1, "kevent(sf)");
+ err(1, "kevent(sf %d)", sf);
+
+ /*
+ * We can only read from an interactive terminal
+ */
+ if (isatty(fdin)) {
+ bzero(&kv, sizeof(struct kevent));
+ kv.ident = fdin;
+ kv.filter = EVFILT_READ;
+ kv.flags = EV_ADD;
+ if (kevent(kq, &kv, 1, NULL, 0, NULL) == -1)
+ err(1, "kevent(fdin %d)", fdin);
+ }
buffer = malloc(MAX_BUFFER);
if (buffer == NULL)
pcap_t *pc; /* pcap device */
int datalinkOffset; /* offset of ip packet from datalink packet */
-int captureDebug = 0;
+int captureDebug = 1;
unsigned int thisTimeZone;
void CaptureInit(u_int32_t sourceIP, u_int16_t sourcePort,
DataPktPathCheck(session.filename, 3, 0);
return;
}
+
+
+void
+SynTest(u_int32_t sourceAddress, u_int16_t sourcePort,
+ u_int32_t targetAddress, u_int16_t targetPort, int mss, int syn_reply)
+{
+ int rawSocket, flag;
+ struct IPPacket *synPacket = NULL, *ackPacket = NULL;
+ char *read_packet;
+ struct pcap_pkthdr pi;
+ int synAckReceived = 0;
+ int numRetransmits = 0;
+ double timeoutTime;
+ int tcpoptlen = 4; /* For negotiating MSS */
+ u_int8_t *opt = NULL;
+ struct IPPacket *p = NULL;
+
+ arc4random_stir();
+
+ session.src = sourceAddress;
+ session.sport = sourcePort;
+ session.dst = targetAddress;
+ session.dport = targetPort;
+ session.rcv_wnd = 5*mss;
+ session.snd_nxt = arc4random();
+ session.iss = session.snd_nxt;
+ session.rcv_nxt = 0;
+ session.irs = 0;
+ session.mss = mss;
+ session.maxseqseen = 0;
+ session.epochTime = GetTime();
+ session.maxpkts = 1000;
+
+ if ((session.dataRcvd = (u_int8_t *)calloc(sizeof(u_int8_t),
+ mss * session.maxpkts)) == NULL) {
+ printf("no memory to store data, error: %d \n", ERR_MEM_ALLOC);
+ Quit(ERR_MEM_ALLOC);
+ }
+
+ if ((rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
+ perror("ERROR: couldn't open socket:");
+ Quit(ERR_SOCKET_OPEN);
+ }
+
+ flag = 1;
+ if (setsockopt(rawSocket, IPPROTO_IP, IP_HDRINCL,
+ (char *)&flag, sizeof(flag)) < 0) {
+ perror("ERROR: couldn't set raw socket options:");
+ Quit(ERR_SOCKOPT);
+ }
+
+ session.socket = rawSocket;
+
+
+ /* allocate the syn packet -- Changed for new IPPacket structure */
+ synPacket = AllocateIPPacket(0, tcpoptlen, 0, "ECN (SYN)");
+ opt = (((u_int8_t *)synPacket->tcp) + sizeof(struct TcpHeader));
+ opt[0] = (u_int8_t)TCPOPT_MAXSEG;
+ opt[1] = (u_int8_t)TCPOLEN_MAXSEG;
+ *((u_int16_t *)((u_int8_t *)opt + 2)) = htons(session.mss);
+
+ SendSessionPacket(synPacket,
+ sizeof(struct IpHeader) + sizeof(struct TcpHeader) + tcpoptlen,
+ TCPFLAGS_SYN , 0, tcpoptlen, 0);
+ timeoutTime = GetTime() + 1;
+
+ /*
+ * Wait for SYN/ACK and retransmit SYN if appropriate
+ * not great, but it gets the job done
+ */
+
+ while(!synAckReceived && numRetransmits < 3) {
+ while(GetTime() < timeoutTime) {
+ /* Have we captured any packets? */
+ if ((read_packet = (char *)CaptureGetPacket(&pi)) != NULL) {
+ p = (struct IPPacket *)FindHeaderBoundaries(read_packet);
+ /* Received a packet from us to them */
+ if (INSESSION(p, session.src, session.sport,
+ session.dst, session.dport)) {
+ /* Is it a SYN/ACK? */
+ if (p->tcp->tcp_flags & TCPFLAGS_SYN) {
+ if (session.debug >= SESSION_DEBUG_LOW) {
+ PrintTcpPacket(p);
+ }
+ StorePacket(p);
+ session.totSeenSent++ ;
+ } else {
+ processBadPacket(p);
+ }
+ continue;
+ }
+
+ /* Received a packet from them to us */
+ if (INSESSION(p, session.dst, session.dport, session.src,
+ session.sport)) {
+ /* Is it a SYN/ACK? */
+ if ((p->tcp->tcp_flags & TCPFLAGS_SYN) &&
+ (p->tcp->tcp_flags & TCPFLAGS_ACK)) {
+ timeoutTime = GetTime(); /* force exit */
+ synAckReceived++;
+ if (session.debug >= SESSION_DEBUG_LOW) {
+ PrintTcpPacket(p);
+ }
+ StorePacket(p);
+
+ /*
+ * Save ttl for,admittedly poor,indications of reverse
+ * route change
+ */
+ session.ttl = p->ip->ip_ttl;
+ session.snd_wnd = ntohl(p->tcp->tcp_win);
+ session.totRcvd ++;
+ break;
+ } else {
+ if ((p->tcp->tcp_flags)& (TCPFLAGS_RST)) {
+ printf ("ERROR: EARLY_RST\n");
+ goto done;
+ }
+ }
+ }
+ }
+ }
+
+ if (!synAckReceived) {
+ if (session.debug >= SESSION_DEBUG_LOW) {
+ printf("SYN timeout. Retransmitting\n");
+ }
+ SendSessionPacket(synPacket,
+ sizeof(struct IpHeader) + sizeof(struct TcpHeader) + tcpoptlen,
+ TCPFLAGS_SYN , 0, tcpoptlen, 0);
+ timeoutTime = GetTime() + 1;
+ numRetransmits++;
+ }
+ }
+
+ if (numRetransmits >= 3) {
+ printf("ERROR: No connection after 3 retries...\nRETURN CODE: %d\n",
+ NO_CONNECTION);
+ goto done;
+ }
+ if (session.debug >= SESSION_DEBUG_LOW)
+ printf("Received SYN-ACK\n");
+ if (syn_reply != 0) {
+ /* Update session variables */
+ session.irs = ntohl(p->tcp->tcp_seq);
+ session.dataRcvd[0] = 1 ;
+ session.rcv_nxt = session.irs + 1; /* SYN/ACK takes up a byte of seq space */
+ session.snd_nxt = session.iss + 1; /* SYN takes up a byte of seq space */
+ session.snd_una = session.iss + 1;
+ session.maxseqseen = ntohl(p->tcp->tcp_seq);
+ session.initSession = 1;
+ if (session.debug >= SESSION_DEBUG_LOW) {
+ printf("try to send the %s\n", syn_reply == TCPFLAGS_ACK ? "third Ack" : "RST");
+ printf("src = %s:%d (%u)\n", InetAddress(session.src),
+ session.sport, session.iss);
+ printf("dst = %s:%d (%u)\n",InetAddress(session.dst),
+ session.dport, session.irs);
+ }
+
+ /* allocate the syn packet -- Changed for new IPPacket structure */
+ ackPacket = AllocateIPPacket(0, 0, 0, "SYN reply");
+ /* send an ACK */
+ SendSessionPacket(ackPacket,
+ sizeof(struct IpHeader) + sizeof(struct TcpHeader),
+ syn_reply, 0, 0, 0);
+ FreeIPPacket(&ackPacket);
+ }
+done:
+ FreeIPPacket(&synPacket);
+}
void checkECN ();
void ECNPathCheckTest(u_int32_t sourceIpAddress, u_int16_t surcePort,
u_int32_t targetIpAddress, u_int16_t targetPort, int mss);
+void SynTest(u_int32_t sourceIpAddress, u_int16_t surcePort, u_int32_t targetIpAddress, u_int16_t targetPort, int mss, int syn_reply);
printf("\t-f <file-name to get>\n");
printf("\t-d <interface name>\n");
printf("\t-C for CE path check\n");
+ printf("\t-S [A|R|X] SYN followed by ACK or RST or nothing\n");
+ printf("\t-F [set|clear|skip] how to handle firewall rules\n");
return;
}
{
char pfcmd[512];
char *pf_file_name = "/tmp/pf.conf";
- int pf_fd = 0, rc;
+ int pf_fd = 0, rc;
ssize_t bytes;
- char *args[4];
+ char *args[4];
bzero(pfcmd, sizeof(pfcmd));
- bzero(args, sizeof(args));
+ bzero(args, sizeof(args));
sprintf(pfcmd, "block in quick on %s inet proto tcp from %s port %u\n",
- dev, InetAddress(targetIP), port);
+ dev, InetAddress(targetIP), port);
if (session.debug >= SESSION_DEBUG_LOW)
- printf("PF rule: %s\n", pfcmd);
+ printf("PF rule: %s\n", pfcmd);
pf_fd = open(pf_file_name, O_RDWR|O_TRUNC|O_CREAT);
if (pf_fd < 0) {
}
bytes = write(pf_fd, pfcmd, strlen(pfcmd) + 1);
close(pf_fd);
- args[0] = "pfctl";
- args[1] = "-d";
- args[2] = NULL;
- rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
- if (rc != 0) {
- printf("Failed to exec: pfctl -d: %d\n", rc);
- Quit(FAIL);
- }
-
- args[1] = "-f";
- args[2] = pf_file_name;
- args[3] = NULL;
- rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
- if (rc != 0) {
- printf("Failed to exec: pfctl -f /tmp/pf.conf: %d\n", rc);
- Quit(FAIL);
- }
-
- args[1] = "-e";
- args[2] = NULL;
- rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
- if (rc != 0) {
- printf("Failed to exec: pfctl -e: %d\n", rc);
- Quit(FAIL);
- }
+ args[0] = "pfctl";
+ args[1] = "-d";
+ args[2] = NULL;
+ rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
+ if (rc != 0) {
+ printf("Failed to exec: pfctl -d: %d\n", rc);
+ Quit(FAIL);
+ }
+
+ args[1] = "-f";
+ args[2] = pf_file_name;
+ args[3] = NULL;
+ rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
+ if (rc != 0) {
+ printf("Failed to exec: pfctl -f /tmp/pf.conf: %d\n", rc);
+ Quit(FAIL);
+ }
+
+ args[1] = "-e";
+ args[2] = NULL;
+ rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
+ if (rc != 0) {
+ printf("Failed to exec: pfctl -e: %d\n", rc);
+ Quit(FAIL);
+ }
+}
+
+void CleanupFirewall()
+{
+ char * args[3];
+ int rc;
+
+ args[0] = "pfctl";
+ args[1] = "-d";
+ args[2] = NULL;
+ rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
+ if (rc != 0) {
+ printf("Failed to exec: pfctl -d: %d\n", rc);
+ Quit(FAIL);
+ }
}
void Cleanup()
{
- char * args[3];
- int rc;
if (session.initSession > 0) {
shutdown(session.socket, 2);
}
-
if (session.initCapture > 0) {
CaptureEnd();
}
- args[0] = "pfctl";
- args[1] = "-d";
- args[2] = NULL;
- rc = posix_spawn(NULL, "/sbin/pfctl", NULL, NULL, args, NULL);
- if (rc != 0) {
- printf("Failed to exec: pfctl -d: %d\n", rc);
- Quit(FAIL);
- }
+ if (session.initFirewall > 0) {
+ CleanupFirewall();
+ }
}
void Quit(int how)
++port;
sockName.sin_addr.s_addr = INADDR_ANY;
sockName.sin_family = AF_INET;
- sockName.sin_port = htons(port);
+ sockName.sin_port = 0; //htons(port);
result = bind(sockfd, (struct sockaddr *)&sockName,
sizeof(sockName));
} while ((result < 0) && (port < END_PORT));
+
if (result < 0) {
/* No free ports */
perror("bind");
port = 0;
- }
+ } else {
+ socklen_t len = sizeof(sockName);
+ result = getsockname(sockfd, (struct sockaddr *)&sockName, &len);
+ if (result < 0) {
+ perror("getsockname");
+ port = 0;
+ } else {
+ port = ntohs(sockName.sin_port);
+ }
+ }
return port;
}
-
+#define FIREWALL_DEFAULT 0
+#define FIREWALL_SET_ONLY 1
+#define FIREWALL_CLEAR_ONLY 2
+#define FIREWALL_SKIP 3
int main(int argc, char **argv)
{
int mss = DEFAULT_MSS;
int mtu = DEFAULT_MTU;
int fd, opt, usedev = 0, rc = 0, path_check = 0;
+ int syn_test = 0, syn_reply = 0;
struct sockaddr_in saddr;
char dev[11]; /* device name for pcap init */
struct ifaddrs *ifap, *tmp;
+ int firewall_mode = FIREWALL_DEFAULT;
bzero(&session, sizeof(session));
- while ((opt = getopt(argc, argv, "n:p:w:m:M:s:d:f:-C")) != -1) {
+ while ((opt = getopt(argc, argv, "n:p:w:m:M:s:d:f:-CS:vF:")) != -1) {
switch (opt) {
- case 'n':
- if (strlen(optarg) > (MAXHOSTNAMELEN - 1)) {
- printf("Target host name too long, max %u chars\n", MAXHOSTNAMELEN);
- Quit(FAIL);
- }
- strncpy(session.targetHostName, optarg,
- MAXHOSTNAMELEN);
- strncpy(session.targetName, session.targetHostName,
- MAXHOSTNAMELEN);
- break;
- case 'p':
- targetPort = atoi(optarg);
- break;
- case 'm':
- mss = atoi(optarg);
- break;
- case 'M':
- mtu = atoi(optarg);
- break;
- case 'w':
- sourcePort = atoi(optarg);
- break;
- case 's':
- if (strlen(optarg) > (MAXHOSTNAMELEN - 1)) {
- printf("Source host name too long, max %u chars\n", MAXHOSTNAMELEN);
- Quit(FAIL);
- }
- strncpy(session.sourceHostName, optarg,
- MAXHOSTNAMELEN);
- break;
- case 'd':
- if (strlen(optarg) > (sizeof(dev) - 1)) {
- printf("Interface nae is too large, max %lu chars\n", (sizeof(dev) - 1));
- Quit(FAIL);
- }
- bzero(dev, sizeof(dev));
- strncpy(dev, optarg, (sizeof(dev) - 1));
- usedev = 1;
- break;
- case 'f':
- if (strlen(optarg) > 0) {
- session.filename = strndup(optarg, strlen(optarg) + 1);
- } else {
- printf("Invalid file name \n");
- }
- break;
- case 'C':
- path_check = 1;
- break;
- default:
- usage(argv[0]);
- exit(1);
+ case 'n':
+ if (strlen(optarg) > (MAXHOSTNAMELEN - 1)) {
+ printf("Target host name too long, max %u chars\n", MAXHOSTNAMELEN);
+ Quit(FAIL);
+ }
+ strncpy(session.targetHostName, optarg,
+ MAXHOSTNAMELEN);
+ strncpy(session.targetName, session.targetHostName,
+ MAXHOSTNAMELEN);
+ break;
+ case 'p':
+ targetPort = atoi(optarg);
+ break;
+ case 'm':
+ mss = atoi(optarg);
+ break;
+ case 'M':
+ mtu = atoi(optarg);
+ break;
+ case 'w':
+ sourcePort = atoi(optarg);
+ break;
+ case 's':
+ if (strlen(optarg) > (MAXHOSTNAMELEN - 1)) {
+ printf("Source host name too long, max %u chars\n", MAXHOSTNAMELEN);
+ Quit(FAIL);
+ }
+ strncpy(session.sourceHostName, optarg,
+ MAXHOSTNAMELEN);
+ break;
+ case 'd':
+ if (strlen(optarg) > (sizeof(dev) - 1)) {
+ printf("Interface nae is too large, max %lu chars\n", (sizeof(dev) - 1));
+ Quit(FAIL);
+ }
+ bzero(dev, sizeof(dev));
+ strncpy(dev, optarg, (sizeof(dev) - 1));
+ usedev = 1;
+ break;
+ case 'f':
+ if (strlen(optarg) > 0) {
+ session.filename = strndup(optarg, strlen(optarg) + 1);
+ } else {
+ printf("Invalid file name \n");
+ }
+ break;
+ case 'F':
+ if (strcasecmp(optarg, "default") == 0)
+ firewall_mode = FIREWALL_DEFAULT;
+ else if (strcasecmp(optarg, "set") == 0)
+ firewall_mode = FIREWALL_SET_ONLY;
+ else if (strcasecmp(optarg, "clear") == 0)
+ firewall_mode = FIREWALL_CLEAR_ONLY;
+ else if (strcasecmp(optarg, "skip") == 0)
+ firewall_mode = FIREWALL_SKIP;
+ else
+ printf("firewall mode\n");
+ break;
+ case 'C':
+ path_check = 1;
+ break;
+ case 'S':
+ syn_test = 1;
+ if (strcasecmp(optarg, "A") == 0)
+ syn_reply = TCPFLAGS_ACK;
+ else if (strcasecmp(optarg, "R") == 0)
+ syn_reply = TCPFLAGS_RST;
+ else if (strcasecmp(optarg, "X") == 0)
+ syn_reply = 0;
+ else
+ printf("Invalid SYN reply \n");
+ break;
+ case 'v':
+ session.debug++;
+ break;
+ default:
+ usage(argv[0]);
+ exit(1);
}
}
signal(SIGTERM, SigHandle);
signal(SIGINT, SigHandle);
signal(SIGHUP, SigHandle);
-
+
if (GetCannonicalInfo(session.targetHostName, &targetIpAddress) < 0)
{
printf("Failed to convert targetIP address\n");
Quit(NO_TARGET_CANON_INFO);
- }
-/*
- if (GetCannonicalInfo(session.sourceHostName, &sourceIpAddress) < 0)
- {
+ }
+ /*
+ if (GetCannonicalInfo(session.sourceHostName, &sourceIpAddress) < 0)
+ {
printf("Failed to convert source IP address\n");
Quit(NO_TARGET_CANON_INFO);
- }
-*/
+ }
+ */
rc = getifaddrs(&ifap);
if (rc != 0 || ifap == NULL) {
printf("Failed to get source addresswith getifaddrs: %d\n", rc);
sin = (struct sockaddr_in *)tmp->ifa_addr;
sourceIpAddress = sin->sin_addr.s_addr;
strncpy(session.sourceHostName,
- inet_ntoa(sin->sin_addr),
- MAXHOSTNAMELEN);
+ inet_ntoa(sin->sin_addr),
+ MAXHOSTNAMELEN);
} else {
continue;
}
sin = (struct sockaddr_in *)tmp->ifa_addr;
sourceIpAddress = sin->sin_addr.s_addr;
strncpy(session.sourceHostName,
- inet_ntoa(sin->sin_addr),
- MAXHOSTNAMELEN);
- strncpy(dev, tmp->ifa_name, sizeof(dev));
+ inet_ntoa(sin->sin_addr),
+ MAXHOSTNAMELEN);
+ strncpy(dev, tmp->ifa_name, sizeof(dev));
}
}
freeifaddrs(ifap);
return (-1);
}
}
- CaptureInit(sourceIpAddress, sourcePort, targetIpAddress,
- targetPort, dev);
- session.initCapture = 1;
-
printf("Source: %s:%d\n", session.sourceHostName, sourcePort);
printf("Destination: %s:%d\n", session.targetHostName, targetPort);
- SetupFirewall(targetIpAddress, targetPort, dev);
+ switch (firewall_mode) {
+ case FIREWALL_DEFAULT:
+ SetupFirewall(targetIpAddress, targetPort, dev);
+ session.initFirewall = 1;
+ break;
+ case FIREWALL_SET_ONLY:
+ SetupFirewall(targetIpAddress, targetPort, dev);
+ goto done;
+ case FIREWALL_CLEAR_ONLY:
+ session.initFirewall = 1;
+ goto done;
+ case FIREWALL_SKIP:
+ break;
+ }
+
+ CaptureInit(sourceIpAddress, sourcePort, targetIpAddress,
+ targetPort, dev);
+ session.initCapture = 1;
+
printf("Starting ECN test\n");
- if (path_check) {
- ECNPathCheckTest(sourceIpAddress, sourcePort, targetIpAddress,
- targetPort, mss);
+ if (syn_test) {
+ session.dont_send_reset = 1;
+ SynTest(sourceIpAddress, sourcePort, targetIpAddress,
+ targetPort, mss, syn_reply);
+ } else if (path_check) {
+ ECNPathCheckTest(sourceIpAddress, sourcePort, targetIpAddress,
+ targetPort, mss);
} else {
- ECNTest(sourceIpAddress, sourcePort, targetIpAddress,
- targetPort, mss);
+ ECNTest(sourceIpAddress, sourcePort, targetIpAddress,
+ targetPort, mss);
}
+done:
Quit(SUCCESS);
close(session.socket);
return (0);
uint16 *ip_addr = ip;
uint16 *tcp_addr = tcp;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In InetChecksum...\n");
printf("iplen: %d, tcplen: %d\n", ip_len, tcp_len);
}
sum = (sum & 0xffff) + (sum >> 16);
}
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out InetChecksum...\n");
}
struct IpHeader *ip = p->ip;
struct TcpHeader *tcp = p->tcp;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In WriteIPPacket...\n");
}
ip->ip_off = IP_DF;
ip->ip_len = (uint16)(sizeof(struct IpHeader) + ip_optlen + sizeof(struct TcpHeader) + optlen + datalen);
- if (session.debug == SESSION_DEBUG_HIGH) {
+ ip->ip_xsum = 0;
+ ip->ip_xsum = InetChecksum((uint16 *)ip, NULL,
+ (uint16)sizeof(struct IpHeader) + ip_optlen, /* IP Options should aren't included */
+ 0);
+
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out WriteIPPacket...\n");
}
{
struct IPPacket *p;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In AllocateIPPacket: %s...\n", str);
}
Quit(ERR_MEM_ALLOC);
}
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out of AllocateIPPacket: %s...\n", str);
}
return(p);
double ts1 = 0, ts2;
int flag = 1;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In EstablishSession...\n");
}
free(synPacket->tcp);
free(synPacket);
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out of EstablishSession...\n");
}
char deffile[] = DEFAULT_FILENAME;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In PrepareRequest...\n");
}
h4);
}
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out PrepareRequest...\n");
}
int datalen;
int ipsz;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In SendRequest...\n");
}
free(datapkt->tcp);
free(datapkt);
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out of SendRequest...\n");
}
}
uint16 ip_len, uint8 tcp_flags, uint16 ip_optlen, uint16 optlen,
uint8 iptos)
{
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In SendSessionPacket...\n");
}
WriteIPPacket(p,
ip_optlen, /* ip options len */
optlen); /* tcp options len */
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out of SendSessionPacket...\n");
}
struct IpHeader *ip = p->ip;
struct TcpHeader *tcp = p->tcp;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In SendICMPReply...\n");
}
SendICMPPkt(icmp_pkt, sizeof(struct ICMPUnreachableErrorPacket));
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out of SendICMPReply...\n");
}
struct sockaddr_in sockAddr;
char *assembled_pkt;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In SendPkt...\n");
}
/* Assemble contiguos packet to be sent */
free(assembled_pkt);
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("Out SendPkt...\n");
}
char *read_packet;
double startTime = GetTime () ;
- if (session.debug == SESSION_DEBUG_HIGH) {
+ if (session.debug >= SESSION_DEBUG_HIGH) {
printf("In rcvData...\n");
}
/* For MidBoxTTL test */
int curr_ttl;
+ int dont_send_reset;
};
//void SendSessionPacket(struct IPPacket *packet,
struct IPPacket *p;
int i;
+ if (session.dont_send_reset)
+ return;
+
if ((p = (struct IPPacket *)calloc(1, sizeof(struct IPPacket))) == NULL) {
perror("ERROR: Could not allocate RST packet:") ;
Quit(ERR_MEM_ALLOC) ;
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-deprecated-declarations",
+ "-Wno-address-of-packed-member",
);
};
name = "Ignore Me";
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-deprecated-declarations",
+ "-Wno-address-of-packed-member",
);
};
name = Debug;
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-deprecated-declarations",
+ "-Wno-address-of-packed-member",
);
};
name = Release;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;