Skip to content

Commit

Permalink
spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Dec 20, 2013
1 parent 24f358d commit 9ccb4c7
Show file tree
Hide file tree
Showing 51 changed files with 2,959 additions and 2,937 deletions.
14 changes: 7 additions & 7 deletions src/event-timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
the timeout is actually held within the TCB structure. In other
words, each TCB can have one-and-only-one timeout.
NOTE: a recurring bug is that the TCP code removes a TCB from the
NOTE: a recurring bug is that the TCP code removes a TCB from the
timeout ring and forgets to put it back somewhere else. Since the
TCB is cleaned up on a timeout, such TCBs never get cleaned up,
leading to a memory leak. I keep fixing this bug, then changing the
Expand Down Expand Up @@ -46,7 +46,7 @@ struct Timeouts {
* number minus 1
*/
unsigned mask;

/**
* The ring of entries.
*/
Expand Down Expand Up @@ -87,7 +87,7 @@ timeouts_add(struct Timeouts *timeouts, struct TimeoutEntry *entry,
LOG(1, "***CHANGE %d-seconds\n", (int)((timestamp-entry->timestamp)/16384ULL));
}

/* Initialize the new entry */
/* Initialize the new entry */
entry->timestamp = timestamp;
entry->offset = (unsigned)offset;

Expand All @@ -110,7 +110,7 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp)

/* Search until we find one */
while (timeouts->current_index <= timestamp) {

/* Start at the current slot */
entry = timeouts->slots[timeouts->current_index & timeouts->mask];

Expand All @@ -119,7 +119,7 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp)
entry = entry->next;
if (entry)
break;

/* found nothing at this slot, so move to next slot */
timeouts->current_index++;
}
Expand All @@ -129,10 +129,10 @@ timeouts_remove(struct Timeouts *timeouts, uint64_t timestamp)
* left to timeout, so return NULL */
return NULL;
}

/* unlink this entry from the timeout system */
timeout_unlink(entry);

/* return a pointer to the structure holding this entry */
return ((char*)entry) - entry->offset;
}
Expand Down
36 changes: 18 additions & 18 deletions src/in-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static const size_t BUF_MAX = 1024*1024;
struct MasscanRecord {
unsigned timestamp;
unsigned ip;
unsigned char ip_proto;
unsigned char ip_proto;
unsigned short port;
unsigned char reason;
unsigned char ttl;
Expand All @@ -26,26 +26,26 @@ struct MasscanRecord {
/***************************************************************************
***************************************************************************/
static void
parse_status(struct Output *out,
parse_status(struct Output *out,
enum PortStatus status, /* open/closed */
const unsigned char *buf, size_t buf_length)
{
struct MasscanRecord record;

if (buf_length < 12)
return;
/* parse record */

/* parse record */
record.timestamp = buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3];
record.ip = buf[4]<<24 | buf[5]<<16 | buf[6]<<8 | buf[7];
record.port = buf[8]<<8 | buf[9];
record.reason = buf[10];
record.ttl = buf[11];

/*
* Now report ther result
*/
output_report_status(out,
output_report_status(out,
record.timestamp,
status,
record.ip,
Expand All @@ -65,7 +65,7 @@ static void
parse_banner3(struct Output *out, unsigned char *buf, size_t buf_length)
{
struct MasscanRecord record;

/*
* Parse the parts that are common to most records
*/
Expand Down Expand Up @@ -97,13 +97,13 @@ static void
parse_banner4(struct Output *out, unsigned char *buf, size_t buf_length)
{
struct MasscanRecord record;

/*
* Parse the parts that are common to most records
*/
record.timestamp = buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3];
record.ip = buf[4]<<24 | buf[5]<<16 | buf[6]<<8 | buf[7];
record.ip_proto = buf[8];
record.ip_proto = buf[8];
record.port = buf[9]<<8 | buf[10];
record.app_proto = buf[11]<<8 | buf[12];

Expand Down Expand Up @@ -156,8 +156,8 @@ parse_file(struct Output *out, const char *filename)

/* Make sure it's got the format string */
if (memcmp(buf, "masscan/1.1", 11) != 0) {
fprintf(stderr,
"%s: unknown file format (expeced \"masscan/1.1\")\n",
fprintf(stderr,
"%s: unknown file format (expeced \"masscan/1.1\")\n",
filename);
goto end;
}
Expand All @@ -182,7 +182,7 @@ parse_file(struct Output *out, const char *filename)
break;
type = (type << 7) | (buf[0] & 0x7F);
}

/* [LENGTH]
* Is one byte for lengths smaller than 127 bytes, or two
* bytes for lengths up to 16384.
Expand All @@ -201,8 +201,8 @@ parse_file(struct Output *out, const char *filename)
fprintf(stderr, "file corrupt\n");
goto end;
}


/* get the remainder fo the record */
bytes_read = fread(buf, 1, length, fp);
if (bytes_read < (int)length)
Expand All @@ -219,15 +219,15 @@ parse_file(struct Output *out, const char *filename)
case 3: /* BANNER */
parse_banner3(out, buf, bytes_read);
break;
case 4:
case 4:
if (fread(buf+bytes_read,1,1,fp) != 1) {
fprintf(stderr, "read() error\n");
exit(1);
}
bytes_read++;
bytes_read++;
parse_banner4(out, buf, bytes_read);
break;
case 5:
case 5:
parse_banner4(out, buf, bytes_read);
break;
case 'm': /* FILEHEADER */
Expand Down Expand Up @@ -258,7 +258,7 @@ parse_file(struct Output *out, const char *filename)
* other formats. This preserves the original timestamps.
*****************************************************************************/
void
convert_binary_files(struct Masscan *masscan,
convert_binary_files(struct Masscan *masscan,
int arg_first, int arg_max, char *argv[])
{
struct Output *out;
Expand Down
4 changes: 2 additions & 2 deletions src/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ vLOGip(int level, unsigned ip, unsigned port, const char *fmt, va_list marker)
{
if (level <= global_debug_level) {
char sz_ip[16];
sprintf_s(sz_ip, sizeof(sz_ip), "%u.%u.%u.%u",

sprintf_s(sz_ip, sizeof(sz_ip), "%u.%u.%u.%u",
(ip>>24)&0xFF, (ip>>16)&0xFF, (ip>>8)&0xFF, (ip>>0)&0xFF);
fprintf(stderr, "%-15s:%5u: ", sz_ip, port);
vfprintf(stderr, fmt, marker);
Expand Down
Loading

0 comments on commit 9ccb4c7

Please sign in to comment.