]> sjero.net Git - dccp2tcp/commitdiff
Cleanup types throughout code
authorSamuel Jero <sj323707@ohio.edu>
Wed, 6 Feb 2013 02:12:55 +0000 (21:12 -0500)
committerSamuel Jero <sj323707@ohio.edu>
Wed, 6 Feb 2013 02:12:55 +0000 (21:12 -0500)
connections.c
dccp2tcp.c
dccp2tcp.h

index 732399ed1ffc96abc6ac0cb9b42ee005d38f44d2..afe6fd8dda16598de710ee5b364bb5173037fb3b 100644 (file)
@@ -22,11 +22,11 @@ Date: 02/2013
 ******************************************************************************/
 #include "dccp2tcp.h"
 
 ******************************************************************************/
 #include "dccp2tcp.h"
 
-int isClosed(struct hcon *A, struct hcon *B, int pkt_type);
+int isClosed(struct hcon *A, struct hcon *B, enum dccp_pkt_type pkt_type);
 
 /*Lookup a connection. If it doesn't exist, add a new connection and return it.*/
 int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port,
 
 /*Lookup a connection. If it doesn't exist, add a new connection and return it.*/
 int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port,
-               int pkt_type, struct hcon **fwd, struct hcon **rev){
+               enum dccp_pkt_type pkt_type, struct hcon **fwd, struct hcon **rev){
        struct connection *ptr;
 
        /*Empty list*/
        struct connection *ptr;
 
        /*Empty list*/
@@ -69,7 +69,7 @@ int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest
 
 /*Returns true if the connection is closed and any packets should go to
  * a new connection with the same four-tuple*/
 
 /*Returns true if the connection is closed and any packets should go to
  * a new connection with the same four-tuple*/
-int isClosed(struct hcon *A, struct hcon *B, int pkt_type){
+int isClosed(struct hcon *A, struct hcon *B, enum dccp_pkt_type pkt_type){
        if(pkt_type==DCCP_PKT_REQUEST || pkt_type==DCCP_PKT_RESPONSE){
                if(A->state==CLOSE && B->state==CLOSE){
                        /*We're opening a new connection on hosts/ports we've used before, mark
        if(pkt_type==DCCP_PKT_REQUEST || pkt_type==DCCP_PKT_RESPONSE){
                if(A->state==CLOSE && B->state==CLOSE){
                        /*We're opening a new connection on hosts/ports we've used before, mark
@@ -154,7 +154,7 @@ return;
 }
 
 /* Setup Half Connection Structure*/
 }
 
 /* Setup Half Connection Structure*/
-u_int32_t initialize_hcon(struct hcon *hcn, __be32 initial)
+u_int32_t initialize_hcon(struct hcon *hcn, d_seq_num initial)
 {
        /*set default values*/
        hcn->cur=0;
 {
        /*set default values*/
        hcn->cur=0;
@@ -178,7 +178,7 @@ return initial;
 }
 
 /*Convert Sequence Numbers*/
 }
 
 /*Convert Sequence Numbers*/
-u_int32_t add_new_seq(struct hcon *hcn, __be32 num, int size, enum dccp_pkt_type type)
+u_int32_t add_new_seq(struct hcon *hcn, d_seq_num num, int size, enum dccp_pkt_type type)
 {
        int prev;
        if(hcn==NULL){
 {
        int prev;
        if(hcn==NULL){
@@ -230,7 +230,7 @@ return hcn->table[hcn->cur].new +1;
 }
 
 /*Convert Ack Numbers*/
 }
 
 /*Convert Ack Numbers*/
-u_int32_t convert_ack(struct hcon *hcn, __be32 num, struct hcon *o_hcn)
+u_int32_t convert_ack(struct hcon *hcn, d_seq_num num, struct hcon *o_hcn)
 {
        if(hcn==NULL){
                dbgprintf(0,"ERROR NULL POINTER!\n");
 {
        if(hcn==NULL){
                dbgprintf(0,"ERROR NULL POINTER!\n");
@@ -255,7 +255,7 @@ return o_hcn->high_ack;
 }
 
 /* Get size of packet being acked*/
 }
 
 /* Get size of packet being acked*/
-int acked_packet_size(struct hcon *hcn, __be32 num)
+int acked_packet_size(struct hcon *hcn, d_seq_num num)
 {
        if(hcn==NULL){
                dbgprintf(0,"ERROR NULL POINTER!\n");
 {
        if(hcn==NULL){
                dbgprintf(0,"ERROR NULL POINTER!\n");
index 488b6f309201080f412cc607a0c0db6f95be7d09..6697681b99636008dc3472262720f6ac472fc51b 100644 (file)
@@ -56,7 +56,7 @@ int handle_data(struct packet* new, const struct const_packet* old, struct hcon*
 int parse_options(const u_char* opt_start, int len, struct hcon* A, struct hcon* B);
 int process_feature(const u_char* feat, int len, int confirm, int L, struct hcon* A, struct hcon* B);
 void ack_vect2sack(struct hcon *seq, struct tcphdr *tcph, u_char* tcpopts, u_char* dccphdr,
 int parse_options(const u_char* opt_start, int len, struct hcon* A, struct hcon* B);
 int process_feature(const u_char* feat, int len, int confirm, int L, struct hcon* A, struct hcon* B);
 void ack_vect2sack(struct hcon *seq, struct tcphdr *tcph, u_char* tcpopts, u_char* dccphdr,
-                               __be32 dccpack, struct hcon* o_hcn);
+                               d_seq_num dccpack, struct hcon* o_hcn);
 void version();
 void usage();
 
 void version();
 void usage();
 
@@ -1058,13 +1058,13 @@ int process_feature(const u_char* feat, int len, int confirm, int L, struct hcon
 
 /*Ack Vector to SACK Option*/
 void ack_vect2sack(struct hcon *hcn, struct tcphdr *tcph, u_char* tcpopts, u_char* dccphdr,
 
 /*Ack Vector to SACK Option*/
 void ack_vect2sack(struct hcon *hcn, struct tcphdr *tcph, u_char* tcpopts, u_char* dccphdr,
-                                                                                                                               __be32 dccpack, struct hcon* o_hcn)
+                                                                                                                               d_seq_num dccpack, struct hcon* o_hcn)
 {
        int hdrlen=((struct dccp_hdr*)dccphdr)->dccph_doff*4;
        int optlen;
        int len;
        int tmp;
 {
        int hdrlen=((struct dccp_hdr*)dccphdr)->dccph_doff*4;
        int optlen;
        int len;
        int tmp;
-       __be32 bp;
+       d_seq_num bp;
        u_char* temp;
        u_char* opt;
        u_char* cur;
        u_char* temp;
        u_char* opt;
        u_char* cur;
index 3a071a6c8446ca5061b829844f38e810bd061673..23b5af0f3be0410633930458603bd15b49dc5c80 100644 (file)
@@ -56,8 +56,11 @@ Notes:
 #define MAX_PACKET     1600    /*Maximum size of TCP packet */
 #define        TBL_SZ          40000   /*Size of Sequence Number Table*/
 
 #define MAX_PACKET     1600    /*Maximum size of TCP packet */
 #define        TBL_SZ          40000   /*Size of Sequence Number Table*/
 
+
 #define TRUE 1
 #define FALSE 0
 #define TRUE 1
 #define FALSE 0
+typedef __be16 dccp_port;
+typedef __be32 d_seq_num;
 
 /*Packet structure*/
 struct packet{
 
 /*Packet structure*/
 struct packet{
@@ -99,7 +102,7 @@ enum con_type{
 struct hcon{
        int                                     id_len; /*Length of ID*/
        u_char                          *id;    /*Host ID*/
 struct hcon{
        int                                     id_len; /*Length of ID*/
        u_char                          *id;    /*Host ID*/
-       __be16                          port;   /*Host DCCP port*/
+       dccp_port                       port;   /*Host DCCP port*/
        struct tbl                      *table; /*Host Sequence Number Table*/
        int                                     size;   /*Size of Sequence Number Table*/
        int                                     cur;    /*Current TCP Sequence Number*/
        struct tbl                      *table; /*Host Sequence Number Table*/
        int                                     size;   /*Size of Sequence Number Table*/
        int                                     cur;    /*Current TCP Sequence Number*/
@@ -117,7 +120,7 @@ struct connection{
 
 /*sequence number table structure */
 struct tbl{
 
 /*sequence number table structure */
 struct tbl{
-       __be32                          old;    /*DCCP sequence number */
+       d_seq_num                       old;    /*DCCP sequence number */
        u_int32_t                       new;    /*TCP sequence number */
        int                                     size;   /*packet size*/
        enum dccp_pkt_type      type;   /*packet type*/
        u_int32_t                       new;    /*TCP sequence number */
        int                                     size;   /*packet size*/
        enum dccp_pkt_type      type;   /*packet type*/
@@ -144,17 +147,17 @@ int do_encap(int link, struct packet *new, const struct const_packet *old);
 
 /*Connection functions*/
 int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port,
 
 /*Connection functions*/
 int get_host(u_char *src_id, u_char* dest_id, int id_len, int src_port, int dest_port,
-               int pkt_type, struct hcon **fwd, struct hcon **rev);
+               enum dccp_pkt_type pkt_type, struct hcon **fwd, struct hcon **rev);
 struct connection *add_connection(u_char *src_id, u_char* dest_id, int id_len,
                int src_port, int dest_port);
 int update_state(struct hcon* hst, enum con_state st);
 void cleanup_connections();
 
 /*Half Connection/Sequence number functions*/
 struct connection *add_connection(u_char *src_id, u_char* dest_id, int id_len,
                int src_port, int dest_port);
 int update_state(struct hcon* hst, enum con_state st);
 void cleanup_connections();
 
 /*Half Connection/Sequence number functions*/
-u_int32_t initialize_hcon(struct hcon *hcn, __be32 initial);
-u_int32_t add_new_seq(struct hcon *hcn, __be32 num, int size, enum dccp_pkt_type type);
-u_int32_t convert_ack(struct hcon *hcn, __be32 num, struct hcon *o_hcn);
-int acked_packet_size(struct hcon *hcn, __be32 num);
+u_int32_t initialize_hcon(struct hcon *hcn, d_seq_num initial);
+u_int32_t add_new_seq(struct hcon *hcn, d_seq_num num, int size, enum dccp_pkt_type type);
+u_int32_t convert_ack(struct hcon *hcn, d_seq_num num, struct hcon *o_hcn);
+int acked_packet_size(struct hcon *hcn, d_seq_num num);
 unsigned int interp_ack_vect(u_char* hdr);
 
 #endif
 unsigned int interp_ack_vect(u_char* hdr);
 
 #endif