コード例 #1
0
static void dissect_minecraft_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 type,  guint32 offset, guint32 length)
{
    gboolean c2s;
    //   if (check_col(pinfo->cinfo, COL_PROTOCOL))
    //    col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_MC);
    /* Clear out stuff in the info column */
//    if(check_col(pinfo->cinfo,COL_INFO)){
//        col_clear(pinfo->cinfo,COL_INFO);
//    }
    c2s = TRUE;//pinfo->match_port == pinfo->destport;

    //  if (check_col(pinfo->cinfo, COL_INFO)) {
    //    col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
    //		     c2s ? "C -> S" : "S -> C",
    //		     val_to_str(type, packettypenames, "Unknown Type:0x%02x")                     
    //		     );
    //}
    if ( tree ) {
        mc_item = proto_tree_add_protocol_format(tree, proto_minecraft, tvb, offset, length,
                                                "MC Packet: 0x%02x \"%s\"", type, val_to_str(type, packettypenames, "Unknown"));
        mc_tree = proto_item_add_subtree(mc_item, ett_mc);
        
        proto_tree_add_item(mc_tree, hf_mc_type, tvb, offset, 1, FALSE);
        proto_tree_add_text(mc_tree, tvb, offset, length, "Direction: %s", c2s?"Client -> Server":"Server -> Client");        
        proto_tree_add_item(mc_tree, hf_mc_data, tvb, offset, length, FALSE);
        
        switch (type) {
        case 0x01:
            add_login_details(mc_tree, tvb, pinfo, offset, c2s);
            break;
        case 0x02:
            add_handshake_details(mc_tree, tvb, pinfo, offset, c2s);
            break;
        case 0x03:
            add_chat_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x04:
            add_time_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x06:
            add_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x08:
            add_update_health_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x09:
            add_respawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0A:
            add_loaded_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0B:
            add_player_position_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0C:
            add_player_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0D:
            add_player_move_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0E:
            add_block_dig_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0F:
            add_place_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x10:
            add_change_slot_selection(mc_tree, tvb, pinfo, offset, c2s);
            break;
        case 0x12:
            add_animation_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x14:
            add_named_entity_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x15:
            add_pickup_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x16:
            add_collect_item_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x17:
            add_object_vehicle_details(mc_tree, tvb, pinfo, offset);
            break;
	case 0x18:
	    add_mobspawn_details(mc_tree, tvb, pinfo, offset);
	    break;
        case 0x1D:
            add_destroy_entity_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x1F:
            add_relative_entity_move_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x20:
            add_entity_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x21:
            add_relative_entity_move_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x26:
            add_entity_status_details(mc_tree, tvb, pinfo, offset);
            break;
        /* ... */
        case 0x32:
            add_pre_chunk_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x33:
            add_map_chunk_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x35:
            add_block_change_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x6B:
            add_creative_inventory_action_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x3b:
            add_complex_entity_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x82:
            add_update_sign_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0xc8:
            add_increment_statistic_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0xc9:
            add_player_list_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0xff:
            add_kick_details(mc_tree, tvb, pinfo, offset);
            break;
        }
    }
}
コード例 #2
0
static void dissect_minecraft_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 type,  guint32 offset, guint32 length)
{
    if (check_col(pinfo->cinfo, COL_PROTOCOL))
        col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_MC);
    /* Clear out stuff in the info column */
//    if(check_col(pinfo->cinfo,COL_INFO)){
//        col_clear(pinfo->cinfo,COL_INFO);
//    }

    if (check_col(pinfo->cinfo, COL_INFO)) {
        col_add_fstr(pinfo->cinfo, COL_INFO, pinfo->match_port == pinfo->destport ? "C->S" : "S->C" ": %d > %d Info Type:[%s]",
                     pinfo->srcport, pinfo->destport,
                     val_to_str(type, packettypenames, "Unknown Type:0x%02x"));
    }
    if ( tree ) {
        mc_item = proto_tree_add_item(tree, proto_minecraft, tvb, offset, length, FALSE);
        mc_tree = proto_item_add_subtree(mc_item, ett_mc);

        proto_tree_add_item(mc_tree, hf_mc_type, tvb, offset, 1, FALSE);
        proto_tree_add_item(mc_tree, hf_mc_data, tvb, offset, length, FALSE);
        switch (type) {
        case 0x01:
            add_login_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x02:
            add_handshake_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x03:
            add_chat_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x04:
            add_time_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x06:
            add_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0A:
            add_loaded_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0B:
            add_player_position_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0C:
            add_player_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0D:
            add_player_move_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0E:
            add_block_dig_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x0F:
            add_place_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x10:
            add_block_item_switch_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x11:
            add_add_to_inventory_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x12:
            add_arm_animation_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x14:
            add_named_entity_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x15:
            add_pickup_spawn_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x16:
            add_collect_item_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x17:
            add_object_vehicle_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x1D:
            add_destroy_entity_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x1F:
            add_relative_entity_move_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x20:
            add_entity_look_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x21:
            add_relative_entity_move_look_details(mc_tree, tvb, pinfo, offset);
            break;
            /* ... */
        case 0x32:
            add_pre_chunk_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x33:
            add_map_chunk_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x35:
            add_block_change_details(mc_tree, tvb, pinfo, offset);
            break;
        case 0x3b:
            add_complex_entity_details(mc_tree, tvb, pinfo, offset);
            break;
        }
    }
}