Пример #1
0
extern void decompress(FILE* input_stream, FILE* output_stream)
{
    CODETAB* code_table;
    HTREE* huffman_tree;

    /*Codebook aus der komprimierten Datei lesen*/
    code_table = read_codetab(input_stream);

#ifdef DEBUG_HUFFMAN
    /*Codebuch auf Bildschirm ausgeben*/
    codetab_print(code_table);
#endif

    /*Huffmanbaum erstellen*/
    huffman_tree = create_htree_from_codetab(code_table);

#ifdef DEBUG_HUFFMAN
    /*Huffmanbaum auf Bildschirm ausgeben*/
    htree_print(huffman_tree);
#endif

    /*Inhalt dekomprimieren*/
    decode_content(input_stream, output_stream, huffman_tree);

    /*Resourcen wieder freigeben*/
    delete_codetab(&code_table);
    delete_htree(&huffman_tree);
    
    return;
}
Пример #2
0
void
decode_subscribe(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  if (tree){
    gboolean has_content = FALSE;
    gboolean has_previous_parent = FALSE;

    /*visit*/
    offset = decode_visit(tvb, tree, offset);
    if (offset == -1){
        return;
    }

    /*has content?*/
    if (tvb_get_guint8(tvb, offset) != 0){
      has_content = TRUE;
    }
    proto_tree_add_boolean(tree, hf_scribe_has_content, tvb, offset, 1, has_content);
    offset++;

    if (has_content){
      decode_content(tvb, tree, offset);
    } else {
      proto_tree_add_item(tree, hf_scribe_id, tvb, offset, 4, FALSE);
      offset += 4;
      /*has previous parent?*/
      if (tvb_get_guint8(tvb, offset) != 0){
        has_previous_parent = TRUE;
      }
      proto_tree_add_boolean(tree, hf_scribe_has_previous_parent, tvb, offset, 1, has_previous_parent);
      offset++;

      if (has_previous_parent){
        proto_tree_add_item(tree, hf_scribe_previous_parent_type, tvb, offset, 2, FALSE);
        offset += 2;
        proto_tree_add_string(tree, hf_scribe_previous_parent, tvb, offset, 20, get_id_full(tvb, offset));
        offset +=20;
      }

      decode_nodehandle(tvb, tree, offset, "Subscriber");
    }
  }
}
Пример #3
0
void
decode_anycast(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  if (tree){
    gboolean has_content = FALSE;

    /*visit*/
    offset = decode_visit(tvb, tree, offset);
    if (offset == -1){
        return;
    }

    /*has content?*/
    if (tvb_get_guint8(tvb, offset) != 0){
      has_content = TRUE;
    }
    proto_tree_add_boolean(tree, hf_scribe_has_content, tvb, offset, 1, has_content);
    offset++;

    if (has_content){
      decode_content(tvb, tree, offset);
    }
  }
}
Пример #4
0
static void
dissect_scribe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_item *ti = NULL;
	proto_tree *scribe_tree = NULL;
  const gchar *type_string = NULL;
  guint16 type;
  gboolean has_source = FALSE;
  gint offset = 0;

  if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
			col_set_str(pinfo->cinfo, COL_PROTOCOL, "Scribe");

  type = tvb_get_ntohs(tvb, offset);
  type_string = val_to_str(type, scribe_msg_type, "<Unknown type %d>");

  if (check_col(pinfo->cinfo, COL_INFO)){
    col_clear (pinfo->cinfo, COL_INFO);
    col_add_fstr(pinfo->cinfo, COL_INFO, "%d > %d %s",
      pinfo->srcport, pinfo->destport, type_string);
  }
  
  /*has source?*/
  if (tvb_get_guint8(tvb, offset+3) != 0){
    has_source = TRUE;
  }

  if (tree){
    ti = proto_tree_add_item(tree, proto_scribe, tvb, 0, -1, FALSE);
    scribe_tree = proto_item_add_subtree(ti, ett_scribe);
    proto_tree_add_item(scribe_tree, hf_scribe_type, tvb, offset, 2, FALSE);
    proto_tree_add_item(scribe_tree, hf_scribe_version, tvb, offset + 2, 1, FALSE);
    proto_tree_add_boolean(scribe_tree, hf_scribe_has_source, tvb, offset + 3, 1, has_source);
    if (has_source){
      offset = decode_nodehandle(tvb, scribe_tree, offset + 4 , "Source");
    }
  } else {
    if (has_source){
      offset = get_node_handle_len(tvb, offset + 3);
    }
  }
  if (offset == -1){
    return;
  }

  if(check_col(pinfo->cinfo,COL_INFO)){
    print_id_into_col_info(tvb, pinfo, offset, "Topic");
  }

  if (tree){
    offset = decode_type_and_id(tvb, scribe_tree, offset);
    if (offset == -1){
      return;
    }

    switch (type){
      case SCRIBE_ANYCAST_MSG:
        decode_anycast(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_MSG:
        decode_subscribe(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_ACK_MSG:
        decode_scribe_subscribe_ack(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_FAILED_MSG:
        decode_scribe_failed(tvb, scribe_tree, offset);
        break;
      case SCRIBE_PUBLISH_MSG:
      case SCRIBE_PUBLISH_REQUEST_MSG:
        decode_content(tvb, scribe_tree, offset);
        break;
      case SCRIBE_DROP_MSG:
      case SCRIBE_UNSUBSCRIBE_MSG:
      default:
        return;/*stop dissection*/
    }
  }
}