~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to epan/dissectors/packet-rtcp.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* packet-rtcp.c
2
2
 *
3
 
 * $Id: packet-rtcp.c 19627 2006-10-20 14:05:18Z martinm $
 
3
 * $Id: packet-rtcp.c 20304 2007-01-04 13:25:25Z martinm $
4
4
 *
5
5
 * Routines for RTCP dissection
6
6
 * RTCP = Real-time Transport Control Protocol
412
412
static gint  ett_xr_loss_chunk = -1;
413
413
static gint ett_poc1_conn_contents      = -1;
414
414
 
 
415
/* Protocol registration */
 
416
void proto_register_rtcp(void);
 
417
void proto_reg_handoff_rtcp(void);
 
418
 
415
419
/* Main dissection function */
416
420
static void dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo,
417
421
     proto_tree *tree );
433
437
static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo,
434
438
                                      proto_tree *tree, guint32 lsr, guint32 dlsr);
435
439
static void add_roundtrip_delay_info(tvbuff_t *tvb, packet_info *pinfo,
436
 
                                     proto_tree *tree, guint frame, guint delay);
 
440
                                     proto_tree *tree, guint frame, gint delay);
437
441
 
438
442
 
439
443
/* Set up an RTCP conversation using the info given */
685
689
                                {
686
690
                                        return offset;
687
691
                                }
688
 
                                
 
692
 
689
693
                                /* Look for a code in the first byte */
690
694
                                code = tvb_get_guint8(tvb, offset);
691
695
                                offset += 1;
859
863
                                        return offset;
860
864
                                }
861
865
 
862
 
                                /* Item length, 8 bits */
863
 
                                item_len = tvb_get_guint8( tvb, offset );
864
 
                                proto_tree_add_item( PoC1_tree, hf_rtcp_sdes_length, tvb, offset, 1, FALSE );
865
 
                                offset++;
866
 
                                packet_len--;
867
 
 
868
866
                                /* SIP URI */
869
 
                                proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_sip_uri, tvb, offset, item_len, FALSE );
 
867
                                item_len = tvb_get_guint8( tvb, offset );
 
868
                                proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_sip_uri, tvb, offset, 1, FALSE );
870
869
 
871
870
                                if (check_col(pinfo->cinfo, COL_INFO))
872
871
                                {
874
873
                                                        tvb_get_ephemeral_string(tvb, offset, item_len));
875
874
                                }
876
875
                                
877
 
                                offset = offset + item_len;
878
 
                                packet_len = packet_len - item_len;
 
876
                                offset = offset + item_len + 1;
 
877
                                packet_len = packet_len - item_len - 1;
879
878
                                
880
879
                                /* In the application dependent data, the TBCP Talk Burst Taken message SHALL carry
881
880
                                 * a SSRC field and SDES items, CNAME and MAY carry SDES item NAME to identify the
895
894
                                        proto_tree_add_item( PoC1_tree, hf_rtcp_sdes_type, tvb, offset, 1, FALSE );
896
895
                                        offset++;
897
896
                                        packet_len--;
898
 
        
899
 
                                        /* Item length, 8 bits */
 
897
 
 
898
                                        /* Display name */
900
899
                                        item_len = tvb_get_guint8( tvb, offset );
901
 
                                        proto_tree_add_item( PoC1_tree, hf_rtcp_sdes_length, tvb, offset, 1, FALSE );
902
 
                                        offset++;
903
 
                                        packet_len--;
904
 
        
905
 
                                        /* Display name */
906
 
                                        if ( item_len != 0 )
907
 
                                                proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_disp_name, tvb, offset, item_len, FALSE );
908
 
                                        offset = offset + item_len;
909
 
                                        packet_len = packet_len - item_len;
 
900
                                        if (item_len != 0)
 
901
                                        {
 
902
                                                proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_disp_name, tvb, offset, 1, FALSE );
 
903
                                        }
 
904
                                        offset = offset + item_len + 1;
 
905
                                        packet_len = packet_len - item_len - 1;
910
906
 
911
907
                                        if (packet_len == 0)
 
908
                                        {
912
909
                                                return offset;
 
910
                                        }
913
911
                                }
914
912
 
915
913
                                /* Participants (optional) */
980
978
                        case TBCP_BURST_RELEASE:
981
979
                                {
982
980
                                guint16 last_seq_no;
983
 
                                guint8  ignore_last_seq_no;
 
981
                                guint16 ignore_last_seq_no;
984
982
 
985
983
                                /* Sequence number of last RTP packet in burst */
986
984
                                proto_tree_add_item( PoC1_tree, hf_rtcp_app_poc1_last_pkt_seq_no, tvb, offset, 2, FALSE );
1215
1213
                proto_tree_add_item( tree, hf_rtcp_sdes_length, tvb, offset, 1, FALSE );
1216
1214
                offset++;
1217
1215
 
1218
 
                reason_text = tvb_get_ephemeral_string(tvb, offset, reason_length);
 
1216
                reason_text = (char*)tvb_get_ephemeral_string(tvb, offset, reason_length);
1219
1217
                proto_tree_add_string( tree, hf_rtcp_sdes_text, tvb, offset, reason_length, reason_text );
1220
1218
                /* Allow for terminating null character */
1221
1219
                offset += (reason_length+1);
1507
1505
            
1508
1506
            /* MOS LQ */
1509
1507
            proto_tree_add_float(content_tree, hf_rtcp_xr_voip_metrics_moslq, tvb, offset, 1, 
1510
 
                                 (gfloat)tvb_get_guint8(tvb, offset) / 10);
 
1508
                                 (gfloat)(int)(tvb_get_guint8(tvb, offset) / 10));
1511
1509
            offset++;
1512
1510
            
1513
1511
            /* MOS CQ */
1514
1512
            proto_tree_add_float(content_tree, hf_rtcp_xr_voip_metrics_moscq, tvb, offset, 1, 
1515
 
                                 (gfloat)tvb_get_guint8(tvb, offset) / 10);
 
1513
                                 (gfloat)(int)(tvb_get_guint8(tvb, offset) / 10));
1516
1514
            offset++;
1517
1515
            
1518
1516
            /* PLC, JB Adaptive, JB Rate */
2032
2030
        /* Copy current conversation data into packet info */
2033
2031
        p_packet_data->last_received_set = TRUE;
2034
2032
        p_packet_data->last_received_frame_number = p_conv_data->last_received_frame_number;
2035
 
        p_packet_data->last_received_timestamp = p_conv_data->last_received_timestamp;
2036
2033
}
2037
2034
 
2038
2035
 
2106
2103
                        p_add_proto_data(pinfo->fd, proto_rtcp, p_packet_data);
2107
2104
                }
2108
2105
 
2109
 
                /* Don't allow match seemingly calculated from same frame! */
2110
 
                if (pinfo->fd->num == p_conv_data->last_received_frame_number)
 
2106
                /* Don't allow match seemingly calculated from same (or later!) frame */
 
2107
                if (pinfo->fd->num <= p_conv_data->last_received_frame_number)
2111
2108
                {
2112
2109
                        return;
2113
2110
                }
2114
 
        
2115
 
                /* Any previous report must match the lsr given here */
 
2111
 
 
2112
                /* The previous report must match the lsr given here */
2116
2113
                if (p_conv_data->last_received_ts == lsr)
2117
2114
                {
2118
2115
                        /* Look at time of since original packet was sent */
2123
2120
 
2124
2121
                        gint total_gap = (seconds_between_packets*1000) +
2125
2122
                                         (nseconds_between_packets / 1000000);
2126
 
                        gint delay = total_gap - (int)(((double)dlsr/(double)65536) * 1000.0);
2127
 
 
2128
 
            /* Record that the LSR matches */
2129
 
            p_packet_data->lsr_matched = TRUE;
 
2123
                        gint dlsr_ms = (int)(((double)dlsr/(double)65536) * 1000.0);
 
2124
                        gint delay;
 
2125
 
 
2126
                        /* Delay is gap - dlsr  (N.B. this is allowed to be -ve) */
 
2127
                        delay = total_gap - dlsr_ms;
 
2128
 
 
2129
                        /* Record that the LSR matches */
 
2130
                        p_packet_data->lsr_matched = TRUE;
2130
2131
 
2131
2132
                        /* No useful calculation can be done if dlsr not set... */
2132
2133
                        if (dlsr)
2144
2145
/* Show the calcaulted roundtrip delay info by adding protocol tree items
2145
2146
   and appending text to the info column */
2146
2147
static void add_roundtrip_delay_info(tvbuff_t *tvb, packet_info *pinfo,
2147
 
                                     proto_tree *tree, guint frame, guint delay)
 
2148
                                     proto_tree *tree, guint frame, gint delay)
2148
2149
{
2149
2150
        /* 'Last SR' frame used in calculation.  Show this even if no delay shown */
2150
2151
        proto_item* item = proto_tree_add_uint(tree,
2153
2154
        PROTO_ITEM_SET_GENERATED(item);
2154
2155
 
2155
2156
        /* Don't report on calculated delays below the threshold.
2156
 
           Won't report a delay of 0 (which also indicates no valid
2157
 
           calculated value to report) */
2158
 
        if (delay < global_rtcp_show_roundtrip_calculation_minimum)
 
2157
           Will report delays less than -threshold, to highlight
 
2158
           problems with generated reports */
 
2159
        if (abs(delay) < global_rtcp_show_roundtrip_calculation_minimum)
2159
2160
        {
2160
2161
                return;
2161
2162
        }
2162
2163
 
2163
2164
        /* Calculated delay in ms */
2164
 
        item = proto_tree_add_uint(tree, hf_rtcp_roundtrip_delay, tvb, 0, 0, delay);
 
2165
        item = proto_tree_add_int(tree, hf_rtcp_roundtrip_delay, tvb, 0, 0, delay);
2165
2166
        PROTO_ITEM_SET_GENERATED(item);
2166
2167
 
2167
2168
        /* Add to expert info */
2168
 
        expert_add_info_format(pinfo, item,
2169
 
                               PI_SEQUENCE, PI_NOTE,
2170
 
                               "RTCP round-trip delay detected (%u ms)",
2171
 
                               delay);
 
2169
        if (delay >= 0)
 
2170
        {
 
2171
                expert_add_info_format(pinfo, item,
 
2172
                                       PI_SEQUENCE, PI_NOTE,
 
2173
                                       "RTCP round-trip delay detected (%d ms)",
 
2174
                                       delay);
 
2175
        }
 
2176
        else
 
2177
        {
 
2178
                expert_add_info_format(pinfo, item,
 
2179
                                       PI_SEQUENCE, PI_ERROR,
 
2180
                                       "Negative RTCP round-trip delay detected (%d ms)",
 
2181
                                       delay);
 
2182
        }
2172
2183
 
2173
2184
        /* Report delay in INFO column */
2174
2185
        if (check_col(pinfo->cinfo, COL_INFO))
2175
2186
        {
2176
 
                if (delay > 0)
2177
 
                {
2178
 
                        col_append_fstr(pinfo->cinfo, COL_INFO,
2179
 
                                        " (roundtrip delay <-> %s = %ums, using frame %u)",
2180
 
                                        address_to_str(&pinfo->net_src), delay, frame);
2181
 
                }
 
2187
                col_append_fstr(pinfo->cinfo, COL_INFO,
 
2188
                                " (roundtrip delay <-> %s = %dms, using frame %u)  ",
 
2189
                                address_to_str(&pinfo->net_src), delay, frame);
2182
2190
        }
2183
2191
}
2184
2192
 
2203
2211
                col_set_str( pinfo->cinfo, COL_PROTOCOL, "RTCP" );
2204
2212
        }
2205
2213
 
2206
 
        if ( check_col( pinfo->cinfo, COL_INFO) ) {
2207
 
                /* The second octet contains the packet type */
2208
 
                /* switch ( pd[ offset + 1 ] ) { */
2209
 
                switch ( tvb_get_guint8( tvb, 1 ) ) {
2210
 
                        case RTCP_SR:
2211
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Sender Report");
2212
 
                                break;
2213
 
                        case RTCP_RR:
2214
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Receiver Report");
2215
 
                                break;
2216
 
                        case RTCP_SDES:
2217
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Source Description");
2218
 
                                break;
2219
 
                        case RTCP_BYE:
2220
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Goodbye");
2221
 
                                break;
2222
 
                        case RTCP_APP:
2223
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Application");
2224
 
                                break;
2225
 
                        case RTCP_XR:
2226
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Extended report");
2227
 
                                break;
2228
 
                        case RTCP_FIR:
2229
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Full Intra-frame Request (H.261)");
2230
 
                                break;
2231
 
                        case RTCP_NACK:
2232
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Negative Acknowledgement (H.261)");
2233
 
                                break;
2234
 
                        default:
2235
 
                                col_set_str( pinfo->cinfo, COL_INFO, "Unknown packet type");
2236
 
                                break;
2237
 
                }
2238
 
        }
2239
 
 
2240
2214
    /*
2241
2215
     * Check if there are at least 4 bytes left in the frame,
2242
2216
     * the last 16 bits of those is the length of the current
2255
2229
        if ( ( packet_type < 192 ) || ( packet_type >  207 ) )
2256
2230
            break;
2257
2231
 
 
2232
        if (check_col(pinfo->cinfo, COL_INFO))
 
2233
        {
 
2234
            col_add_fstr(pinfo->cinfo, COL_INFO, "%s   ",
 
2235
                         val_to_str(packet_type, rtcp_packet_type_vals, "Unknown"));
 
2236
        }
 
2237
 
2258
2238
        /*
2259
2239
         * get the packet-length for the complete RTCP packet
2260
2240
         */
2371
2351
                offset++;
2372
2352
                break;
2373
2353
        }
 
2354
 
 
2355
        col_set_fence(pinfo->cinfo, COL_INFO);
2374
2356
    }
2375
2357
    /* If the padding bit is set, the last octet of the
2376
2358
     * packet contains the length of the padding
2815
2797
                        {
2816
2798
                                "SIP URI",
2817
2799
                                "rtcp.app.poc1.sip.uri",
2818
 
                                FT_STRING,
 
2800
                                FT_UINT_STRING,
2819
2801
                                BASE_NONE,
2820
2802
                                NULL,
2821
2803
                                0x0,
2827
2809
                        {
2828
2810
                                "Display Name",
2829
2811
                                "rtcp.app.poc1.disp.name",
2830
 
                                FT_STRING,
 
2812
                                FT_UINT_STRING,
2831
2813
                                BASE_NONE,
2832
2814
                                NULL,
2833
2815
                                0x0,
3271
3253
                        {
3272
3254
                                "Roundtrip Delay(ms)",
3273
3255
                                "rtcp.roundtrip-delay",
3274
 
                                FT_UINT32,
 
3256
                                FT_INT32,
3275
3257
                                BASE_DEC,
3276
3258
                                NULL,
3277
3259
                                0x0,
3856
3838
                &global_rtcp_show_roundtrip_calculation);
3857
3839
 
3858
3840
        prefs_register_uint_preference(rtcp_module, "roundtrip_min_threshhold",
3859
 
                "Minimum roundtrip calculations to report (ms)",
3860
 
                "Minimum calculated roundtrip delay time in milliseconds that "
 
3841
                "Minimum roundtrip calculation to report (ms)",
 
3842
                "Minimum (absolute) calculated roundtrip delay time in milliseconds that "
3861
3843
                "should be reported",
3862
3844
                10, &global_rtcp_show_roundtrip_calculation_minimum);
3863
3845