Browse Source

delays processing of application-level packets in case of future packet

cecylia 6 years ago
parent
commit
b9064640e4
2 changed files with 34 additions and 4 deletions
  1. 32 4
      relay_station/slitheen.c
  2. 2 0
      relay_station/webm.c

+ 32 - 4
relay_station/slitheen.c

@@ -258,11 +258,39 @@ void process_packet(struct inject_args *iargs, const struct pcap_pkthdr *header,
 
             if(observed->application){
                 if(seq_num > expected_seq){
-                    //For now, enters into FORFEIT state
-                    //TODO: change upstream behaviour to try to mask slitheen hdr
-                    //printf("ERROR: future packet in app data, forfeiting flow\n");
+                    /*For now, enters into FORFEIT state
+                    fprintf(stderr,"ERROR: future packet in app data, forfeiting flow\n");
+                    fflush(stderr);
                     remove_flow(observed);
-                    goto err;
+                    goto err;*/
+
+                    //Delay and process later
+                    frame *new_frame = scalloc(1, sizeof(frame));
+                    new_frame->iargs = iargs;
+                    new_frame->packet = packet;
+                    new_frame->header = header;
+                    new_frame->seq_num = seq_num;
+                    new_frame->next = NULL;
+                    frame_queue *queue = (incoming) ? observed->ds_frame_queue : observed->us_frame_queue;
+                    printf("Delay processing of frame (seq = %u )\n", seq_num);
+
+                    //add to end of list
+                    if(queue->first_frame == NULL){
+                        queue->first_frame = new_frame;
+                    } else {
+                        frame *last = queue->first_frame;
+                        while(last->next != NULL){
+                            last = last->next;
+                        }
+                        last->next = new_frame;
+                    }
+
+                    free(info);
+                    observed->ref_ctr--;
+                    printf("Misordered packet. %p ref_ctr %d\n", observed, observed->ref_ctr);
+
+                    return; //TODO: fix terrible spaghetti returns
+
                 }
 
                 replace_packet(observed, info);

+ 2 - 0
relay_station/webm.c

@@ -85,6 +85,8 @@ int32_t parse_webm(flow *f, uint8_t *ptr, uint32_t len) {
                     p[2] = 0x6c; //'l'
                     p[3] = 0x69; //'i'
 
+                    printf("Replaced cluster with slitheen segment!\n");
+
                 } else {
                     //we want to skip this element
                     f->webmstate = MID_ELEMENT;