******************************************************************************/
#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,
- 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*/
/*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
}
/* 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;
}
/*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){
}
/*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");
}
/* 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");
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();
/*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;
- __be32 bp;
+ d_seq_num bp;
u_char* temp;
u_char* opt;
u_char* cur;
#define MAX_PACKET 1600 /*Maximum size of TCP packet */
#define TBL_SZ 40000 /*Size of Sequence Number Table*/
+
#define TRUE 1
#define FALSE 0
+typedef __be16 dccp_port;
+typedef __be32 d_seq_num;
/*Packet structure*/
struct packet{
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*/
/*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*/
/*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*/
-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