Navigation Menu

Skip to content

Commit

Permalink
fixing compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
reggani authored and reggani committed Aug 31, 2012
1 parent 22ceb4e commit 21c54f4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -52,9 +52,11 @@ SRCS = \
$(SRC_DIR)/drop_statistics.c \
$(SRC_DIR)/flow_table.c \
$(SRC_DIR)/flow_flag.c \
$(SRC_DIR)/flag_parser.c \
$(SRC_DIR)/main.c \
$(SRC_DIR)/packet_series.c \
$(SRC_DIR)/packet_seqack.c \
$(SRC_DIR)/seqack_parser.c \
$(SRC_DIR)/sha1.c \
$(SRC_DIR)/upload_failures.c \
$(SRC_DIR)/util.c \
Expand Down
1 change: 0 additions & 1 deletion src/constants.h
Expand Up @@ -19,7 +19,6 @@
/* Defining this variable enables frequent updates support, with writes
* smaller, aggregated updates every 15 seconds. */
/*#define ENABLE_FREQUENT_UPDATES*/
ie
#define FILE_FORMAT_VERSION 5
#define FREQUENT_FILE_FORMAT_VERSION 3
#ifndef BUILD_ID
Expand Down
57 changes: 27 additions & 30 deletions src/main.c
Expand Up @@ -126,13 +126,13 @@ static uint16_t get_flow_entry_for_packet(
int* const http_bytes_len
#endif
#ifdef ENABLE_PACKET_SEQACK
,uint32_t* int seq_bytes,
uint32_t* const ack_bytes
#ifdef ENABLE_FLOW
,uint8_t* int flag_bytes,
,uint32_t* seq_bytes,
uint32_t* ack_bytes
#endif
#ifdef ENABLE_FLOW_FLAGS
,uint8_t* flag_bytes,
#endif

) {
) {
const struct ether_header* const eth_header = (struct ether_header*)bytes;
uint16_t ether_type = ntohs(eth_header->ether_type);
#ifdef ENABLE_FREQUENT_UPDATES
Expand Down Expand Up @@ -169,8 +169,8 @@ static uint16_t get_flow_entry_for_packet(
}
#endif
#ifdef ENABLE_PACKET_SEQACK //AHLEM changed to what defined up
seq_bytes = tcp_header->seq;
ack_bytes = tcp_header->ack;
seq_bytes = tcp_header->th_seq;
ack_bytes = tcp_header->th_ack;
#endif
#ifdef ENABLE_FLOW_FLAGS
flag_bytes = tcp_header->th_flags;
Expand Down Expand Up @@ -202,8 +202,7 @@ static void process_packet(
u_char* const user,
const struct pcap_pkthdr* const header,
const u_char* const bytes) {
const struct seqackstruct * mydata = (seqackstruct *)user;
if (sigprocmask(SIG_BLOCK, &block_set, NULL) < 0) {
if (sigprocmask(SIG_BLOCK, &block_set, NULL) < 0) {
perror("sigprocmask");
exit(1);
}
Expand Down Expand Up @@ -237,11 +236,11 @@ static void process_packet(
int http_bytes_len = -1;
#endif
#ifdef ENABLE_PACKET_SEQACK
uint32_t* int seq_bytes = 0;
uint32_t* int ack_bytes = 0;
uint32_t* seq_bytes = 0;
uint32_t* ack_bytes = 0;
#endif
#ifdef ENABLE_FLOW_FLAGS
uint8_t* int flag_bytes = 0;
uint8_t* flag_bytes = 0;
#endif
int ether_type = get_flow_entry_for_packet(
bytes, header->caplen, header->len, &flow_entry, &mac_id, &dns_bytes, &dns_bytes_len
Expand Down Expand Up @@ -275,7 +274,6 @@ static void process_packet(
#ifndef NDEBUG
if (flow_id == FLOW_ID_ERROR) {
fprintf(stderr, "Error adding to flow table\n");
//AHLEM question 8
#endif
}
break;
Expand Down Expand Up @@ -306,15 +304,16 @@ static void process_packet(
}
#ifdef ENABLE_HTTP_URL
if (http_bytes_len > 0) {
process_http_packet(http_bytes, http_bytes_len, & http_table, flow_id);
process_http_packet(http_bytes, http_bytes_len, &http_table, flow_id);
}
#endif
//FABIAN: for both seq/ack and flags you should check here for TCP.
//the info is here accesible via flow_entry->transport_protocol,
//AHLEM if the protocl is not TCP set the seq , ack and flags to 0 (even if they are initialized to 0 before?)
//didnt add the else case because it will be field by the process_* (add_* function)to add the seq , ack or flag
//sure flow_entry-> not entry->transport_protocol or ip_header->protocol
#ifdef ENABLE_PACKET_SEQACK
if (flow_entry->transport_protocol <> IPPROTO_TCP) {
if (entry->transport_protocol <> IPPROTO_TCP) {//AHLEM fabian thinks should be ==
seq_bytes = -1;
ack_bytes = -1;
}
Expand All @@ -325,17 +324,16 @@ static void process_packet(
}
#endif
#ifdef ENABLE_PACKET_SEQACK
//AHLEM changed the condition from parameter_len to the right field <> -1. Basically, if the protcol is TCP do that )
//AHLEM changed the condition from parameter_len to the right field <> -1. Basically, if the protcol is TCP do that (seq_bytes <> -1 or ack_bytes <> -1 is the same) )
if (seq_bytes <> -1 && packet_id >= 0) {
process_seq_packet(seq_bytes, &seqack_table, packet_id);
}
if (ack_bytes <> -1 && packet_id >= 0) {
process_ack_packet(ack_bytes, &seqack_table, packet_id);
process_seqack_packet(seq_bytes, ack_bytes, &seqack_table, packet_id);
}

#endif
#ifdef ENABLE_FLOW_FLAGS
if (flag_bytes <> -1) {
process_flag_packet(flag_bytes, &flag_table, flow_id);
#ifdef ENABLE_FLOW_FLAGS /*if TCP and flow acceptance*/
//AHLEM need the variable length in the flag_parser.c (see process dns and process http up)but as we deleted it!?!
if (flag_bytes <> -1 && flow_id <> FLOW_ID_ERROR) {
process_flag_packet(flag_bytes, flag_table.length, &flag_table, flow_id);
}
#endif
if (sigprocmask(SIG_UNBLOCK, &block_set, NULL) < 0) {
Expand Down Expand Up @@ -433,7 +431,7 @@ static void write_update() {
#endif
|| flow_table_write_update(&flow_table, handle)
#ifdef ENABLE_FLOW_FLAGS
|| flag_table_write_update(&flow_flag,handle)
|| flag_table_write_update(&flag_table,handle)
#endif
|| dns_table_write_update(&dns_table, handle)
|| address_table_write_update(&address_table, handle)
Expand Down Expand Up @@ -473,7 +471,7 @@ static void write_update() {
#endif
#ifdef ENABLE_FLOW_FLAGS
flag_table_init(&flag_table);
#ifdef
#endif
drop_statistics_init(&drop_statistics);
}

Expand Down Expand Up @@ -697,9 +695,8 @@ int main(int argc, char *argv[]) {
#endif
#ifdef ENABLE_FLOW_FLAGS
flag_table_init(&flag_table);
#ifdef

address_table_init(&address_table);
#endif
address_table_init(&address_table);
drop_statistics_init(&drop_statistics);
#ifdef ENABLE_FREQUENT_UPDATES
device_throughput_table_init(&device_throughput_table);
Expand All @@ -720,5 +717,5 @@ int main(int argc, char *argv[]) {
if (!pcap_handle) {
return 1;
}
return pcap_loop(pcap_handle, -1, process_packet, mydata);
return pcap_loop(pcap_handle, -1, process_packet, NULL);
}
2 changes: 1 addition & 1 deletion src/packet_seqack.c
Expand Up @@ -26,7 +26,7 @@ int seqack_table_write_update(//
//FABIAN: this does not look right having two const
//statements in their. The first one is likely wrong.
//AHLEM Why is this wrong? we write an entry in the table format
const seqack_table_t* const table,
seqack_table_t* const table,
gzFile handle) {
//FABIAN: You should maybe also print a trailing line with status,
//like in dns_table.c, line 50-56
Expand Down
6 changes: 3 additions & 3 deletions src/packet_seqack.h
Expand Up @@ -30,10 +30,10 @@ typedef struct {
typedef struct{

seqack_entry_t entries[SEQACK_TABLE_ENTRIES];
int length
int length;
int num_dropped_entries;

}seqack_table_t
}seqack_table_t;

void seqack_table_init(seqack_table_t* const table);

Expand All @@ -43,6 +43,6 @@ int seqack_table_add(seqack_table_t* const table, seqack_entry_t* const entry);


/* Serialize all table data to an open gzFile handle. */
int seqack_table_write_update(const seqack_table_t const table, gzFile handle);
int seqack_table_write_update(seqack_table_t const table, gzFile handle);

#endif
4 changes: 2 additions & 2 deletions src/seqack_parser.c
Expand Up @@ -21,13 +21,13 @@ static void add_seqack_packet(seqack_table_t* seqack_table,
entry.packet_id = packet_id;
entry.th_seq = th_seq;
entry.th_ack = th_ack;
seqack_table_add(dns_table, &entry);
seqack_table_add(seqack_table, &entry);
}

/*process the seq and ack before adding the record*/
//AHLEM do I need to check for something before adding the seq and ack or do I simply need the add function?
int process_seqack_packet(const uint8_t* const bytes,
int len,
int len,
dseqack_table_t* const seqack_table,
uint16_t packet_id);
{
Expand Down
14 changes: 10 additions & 4 deletions src/seqack_parser.h
Expand Up @@ -6,11 +6,17 @@
#include "packet_seqack.h"

/* Parse a packet and add seq and ack No to table*/
int add_seqack_packet()
void add_seqack_packet(seqack_table_t* seqack_table,
uint16_t packet_id,
uint32_t th_seq,
uint32_t th_ack)

int process_seqack_packet(const uint8_t* const bytes,
int len,
seqack_table_t* const seqack_table,
int process_seqack_packet(uint32_t* const seq_bytes,
uint32_t* const ack_bytes,
seqack_table_t* const seqack_table,
uint16_t packet_id);

{ add_seqack_packet(seqack_table, packet_id, th_seq, th_ack);
}

#endif

0 comments on commit 21c54f4

Please sign in to comment.