Changeset 16da8f3


Ignore:
Timestamp:
10/25/06 13:06:05 (14 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
d5e1796
Parents:
01bc623
Message:

Add ATM support

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    r5696294 r16da8f3  
    431431} PACKED libtrace_8021q_t;
    432432
    433 /** ATM cell */
     433/** ATM User Network Interface (UNI) Cell. */
    434434typedef struct libtrace_atm_cell
    435435{
    436436  LT_BITFIELD32 gfc:4;          /**< Generic Flow Control */
    437437  LT_BITFIELD32 vpi:8;          /**< Virtual Path Identifier */
    438   LT_BITFIELD32 vci:8;          /**< Virtual Channel Identifier */
     438  LT_BITFIELD32 vci:16;         /**< Virtual Channel Identifier */
    439439  LT_BITFIELD32 pt:3;           /**< Payload Type */
    440440  LT_BITFIELD32 clp:1;          /**< Cell Loss Priority */
    441441  LT_BITFIELD32 hec:8;          /**< Header Error Control */
    442442} PACKED libtrace_atm_cell_t;
     443
     444/** ATM Network Node/Network Interface (NNI) Cell. */
     445typedef struct libtrace_atm_nni_cell
     446{
     447  LT_BITFIELD32 vpi:12;         /**< Virtual Path Identifier */
     448  LT_BITFIELD32 vci:16;         /**< Virtual Channel Identifier */
     449  LT_BITFIELD32 pt:3;           /**< Payload Type */
     450  LT_BITFIELD32 clp:1;          /**< Cell Loss Priority */
     451  LT_BITFIELD32 hec:8;          /**< Header Error Control */
     452} PACKED libtrace_atm_nni_cell_t;
     453
     454/** Captured UNI cell.
     455 *
     456 * Endance don't capture the HEC, presumably to keep alignment.  This
     457 * version of the \ref{libtrace_atm_cell} is used when dealing with dag
     458 * captures of uni cells.
     459 *
     460 */
     461typedef struct libtrace_atm_capture_cell
     462{
     463  LT_BITFIELD32 gfc:4;          /**< Generic Flow Control */
     464  LT_BITFIELD32 vpi:8;          /**< Virtual Path Identifier */
     465  LT_BITFIELD32 vci:16;         /**< Virtual Channel Identifier */
     466  LT_BITFIELD32 pt:3;           /**< Payload Type */
     467  LT_BITFIELD32 clp:1;          /**< Cell Loss Priority */
     468} PACKED libtrace_atm_capture_cell_t;
     469
     470/** Captured NNI cell.
     471 *
     472 * Endance don't capture the HEC, presumably to keep alignment.  This
     473 * version of the \ref{libtrace_atm_nni_cell} is used when dealing with dag
     474 * captures of nni cells.
     475 *
     476 */
     477typedef struct libtrace_atm_nni_capture_cell
     478{
     479  LT_BITFIELD32 vpi:12;         /**< Virtual Path Identifier */
     480  LT_BITFIELD32 vci:16;         /**< Virtual Channel Identifier */
     481  LT_BITFIELD32 pt:3;           /**< Payload Type */
     482  LT_BITFIELD32 clp:1;          /**< Cell Loss Priority */
     483  LT_BITFIELD32 hec:8;          /**< Header Error Control */
     484} PACKED libtrace_atm_nni_capture_cell_t;
    443485
    444486/** POS header */
  • lib/protocols.c

    r7c3be58 r16da8f3  
    175175
    176176static void *trace_get_payload_from_atm(void *link,
     177                uint8_t *type, uint32_t *remaining)
     178{
     179        libtrace_atm_capture_cell_t *cell;
     180        if (remaining && *remaining<sizeof(libtrace_atm_capture_cell_t))
     181                return NULL;
     182        cell=(libtrace_atm_capture_cell_t*)link;
     183
     184        if (type)
     185                type=cell->pt;
     186
     187        if (remaining)
     188                *remaining-=sizeof(libtrace_atm_capture_cell_t);
     189
     190        return ((char*)link)+sizeof(libtrace_atm_capture_cell_t);
     191}
     192
     193static void *trace_get_payload_from_llcsnap(void *link,
    177194                uint16_t *type, uint32_t *remaining)
    178195{
     
    181198
    182199        if (remaining) {
    183                 if (*remaining < sizeof(libtrace_llcsnap_t)+4)
    184                         return NULL;
    185                 *remaining-=(sizeof(libtrace_llcsnap_t)+4);
    186         }
    187 
    188         /* advance the llc ptr +4 into the link layer.
    189          * TODO: need to check what is in these 4 bytes.
    190          * don't have time!
    191          */
    192         llc = (libtrace_llcsnap_t*)((char *)llc + 4);
     200                if (*remaining < sizeof(libtrace_llcsnap_t))
     201                        return NULL;
     202                *remaining-=(sizeof(libtrace_llcsnap_t));
     203        }
     204
     205        llc = (libtrace_llcsnap_t*)((char *)llc);
    193206
    194207        if (type) *type = ntohs(llc->type);
     
    302315                        return trace_get_payload_from_pos(link,type,remaining);
    303316                case TRACE_TYPE_ATM:
    304                         return trace_get_payload_from_atm(link,type,remaining);
     317                        l=trace_get_payload_from_atm(link,NULL,remaining);
     318                        return (l ? trace_get_payload_from_llcsnap(l,
     319                                                type, remaining):NULL);
    305320                case TRACE_TYPE_DUCK:
    306321                        return NULL; /* duck packets have no payload! */
Note: See TracChangeset for help on using the changeset viewer.