Changeset 1276

Show
Ignore:
Timestamp:
13/09/07 16:51:57 (1 year ago)
Author:
perry
Message:

Add support for cisco hdlc over pos

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/format_legacy.c

    r1243 r1276  
    270270                 
    271271 
    272 static libtrace_linktype_t legacypos_get_link_type(const libtrace_packet_t *packet UNUSED) { 
     272static libtrace_linktype_t legacypos_get_link_type( 
     273                const libtrace_packet_t *packet) { 
     274        /* Is this a cisco hdlc frame? */ 
     275        if ((((uint8_t*)packet->payload)[0] == 0x0F /* Unicast */ 
     276                || ((uint8_t*)packet->payload)[0] == 0x8F /* Multicast */) 
     277                && ((uint8_t*)packet->payload)[1] == 0x00 /* control == 0x00 */ 
     278           ) 
     279                return TRACE_TYPE_HDLC_POS; 
    273280        return TRACE_TYPE_PPP; 
    274281} 
    275282 
    276 static libtrace_linktype_t legacyatm_get_link_type(const libtrace_packet_t *packet UNUSED) { 
     283static libtrace_linktype_t legacyatm_get_link_type( 
     284                const libtrace_packet_t *packet UNUSED) { 
    277285        return TRACE_TYPE_ATM; 
    278286} 
  • trunk/lib/linktypes.c

    r1269 r1276  
    6969                case TRACE_TYPE_LLCSNAP: return TRACE_DLT_ATM_RFC1483; 
    7070                case TRACE_TYPE_PPP:    return TRACE_DLT_PPP; 
     71                case TRACE_TYPE_HDLC_POS: return TRACE_DLT_C_HDLC; 
    7172                /* Below here are unsupported conversions */ 
    7273                /* Dispite hints to the contrary, there is no DLT 
     
    8687                /* TODO: We haven't researched these yet */ 
    8788                case TRACE_TYPE_AAL5: 
    88                 case TRACE_TYPE_HDLC_POS: 
    8989                case TRACE_TYPE_METADATA: 
    9090                        break; 
  • trunk/lib/protocols.c

    r1269 r1276  
    233233 
    234234        return (void*)((char *)ppp+sizeof(*ppp)); 
     235} 
     236 
     237typedef struct libtrace_chdlc_t { 
     238        uint8_t address;        /** 0xF0 for unicast, 0xF8 for multicast */ 
     239        uint8_t control; 
     240        uint16_t ethertype; 
     241} libtrace_chdlc_t; 
     242 
     243static void *trace_get_payload_from_chdlc(void *link,  
     244                uint16_t *type, uint32_t *remaining) 
     245{ 
     246        libtrace_chdlc_t *chdlc = (libtrace_chdlc_t*)link; 
     247 
     248        if (remaining) { 
     249                if (*remaining < sizeof(libtrace_chdlc_t)) 
     250                        return NULL; 
     251                *remaining-=sizeof(libtrace_chdlc_t); 
     252        } 
     253 
     254        if (type) { 
     255                *type=ntohs(chdlc->ethertype); 
     256        } 
     257 
     258 
     259        return (void*)((char *)chdlc+sizeof(*chdlc)); 
    235260} 
    236261 
     
    381406        void *trans_ptr = 0; 
    382407 
    383         if ((ipptr->ip_off & SW_IP_OFFMASK) != 0) { 
     408        if ((ntohs(ipptr->ip_off) & SW_IP_OFFMASK) != 0) { 
    384409                return NULL; 
    385410        } 
     
    460485                case TRACE_TYPE_80211_PRISM: 
    461486                        return pktbuf; 
     487                /* Non metadata packets */ 
    462488                case TRACE_TYPE_HDLC_POS: 
    463489                case TRACE_TYPE_ETH: 
     
    605631                        return trace_get_payload_from_llcsnap(link,ethertype,remaining); 
    606632 
     633                case TRACE_TYPE_HDLC_POS: 
     634                        return trace_get_payload_from_chdlc(link,ethertype, 
     635                                        remaining); 
    607636                /* TODO: Unsupported */ 
    608                 case TRACE_TYPE_HDLC_POS: 
    609637                case TRACE_TYPE_POS: 
    610638                case TRACE_TYPE_AAL5: