Changeset 5cdb37d for libpacketdump


Ignore:
Timestamp:
02/13/19 10:32:17 (2 years ago)
Author:
GitHub <noreply@…>
Branches:
develop
Children:
33c9a91, fc85f33
Parents:
1c3f8d2 (diff), 4e5a51f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Shane Alcock <salcock@…> (02/13/19 10:32:17)
git-committer:
GitHub <noreply@…> (02/13/19 10:32:17)
Message:

Merge pull request #101 from jacobvw/meta-api

Meta API

Location:
libpacketdump
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/Makefile.am

    r055a2c9 rd0f25d4  
    6161TXT_PROTOCOLS+=link_17.protocol
    6262
     63#22: ERF META
     64BIN_PROTOCOLS+=link_21.la
     65
    6366# 22: ETSI LI
    6467if HAVE_WANDDER
    6568BIN_PROTOCOLS+=link_22.la
    6669endif
     70
     71#23: PCAPNG
     72BIN_PROTOCOLS+=link_23.la
    6773
    6874# Decoders for various ethertypes (in decimal)
     
    140146link_11_la_LDFLAGS=$(modflags)
    141147link_15_la_LDFLAGS=$(modflags)
     148link_21_la_LDFLAGS=$(modflags)
    142149if HAVE_WANDDER
    143150link_22_la_LDFLAGS=$(modflags)
    144151endif
     152link_23_la_LDFLAGS=$(modflags)
    145153eth_0_la_LDFLAGS=$(modflags)
    146154eth_2048_la_LDFLAGS=$(modflags)
  • libpacketdump/libpacketdump.cc

    r8b49230 r23741ec5  
    4141#ifdef HAVE_NETINET_IF_ETHER_H
    4242#  include <netinet/if_ether.h>
    43 #endif 
     43#endif
    4444#include <dlfcn.h>
    4545#include <map>
     
    5757
    5858typedef void (*decode_norm_t)(uint16_t type,const char *packet,int len);
     59typedef void (*decode_norm_meta)(uint16_t type,const char *packet,int len,libtrace_packet_t *p);
    5960typedef void (*decode_parser_t)(uint16_t type,const char *packet,int len, element_t* el);
     61
     62libtrace_packet_t *p;
    6063
    6164typedef union decode_funcs {
    6265    decode_norm_t decode_n;
     66    decode_norm_meta decode_meta;
    6367    decode_parser_t decode_p;
    6468} decode_funcs_t;
     
    130134                        (int)trace_get_wire_length(packet),
    131135                        (int)trace_get_direction(packet));
    132        
    133136
    134137        formatted_hexdump(pkt_ptr, (int)length);
     
    138141void trace_dump_packet(struct libtrace_packet_t *packet)
    139142{
     143        p = packet;
     144
    140145        time_t sec = (time_t)trace_get_seconds(packet);
    141146        libtrace_linktype_t linktype;
    142147        uint32_t length;
    143148        const char *link=(char *)trace_get_packet_buffer(packet,&linktype,NULL);
    144        
     149
    145150        length = trace_get_capture_length(packet);
    146 
    147151        printf("\n%s",ctime(&sec));
    148152        printf(" Capture: Packet Length: %i/%i Direction Value: %i\n",
     
    150154                        (int)trace_get_wire_length(packet),
    151155                        (int)trace_get_direction(packet));
     156
    152157        if (!link)
    153158                printf(" [No link layer available]\n");
    154159        else
    155                 decode_next(link,length, "link",
    156                         linktype);
     160                decode_next(link,length, "link", linktype);
    157161}
    158162
     
    223227                hdl = open_so_decoder(sname.c_str(),type);
    224228                if (hdl) {
    225                         void *s=dlsym(hdl,"decode");
     229
     230                        /* PCAPNG format requires the libtrace_packet_t structure in order
     231                         * to determine the byte ordering */
     232                        void *s;
     233                        if (type == TRACE_TYPE_PCAPNG_META || type == TRACE_TYPE_ERF_META) {
     234                                s=dlsym(hdl,"decode_meta");
     235                                if (s) { func->decode_meta = (decode_norm_meta)s; }
     236                        } else {
     237                                s=dlsym(hdl,"decode");
     238                                if (s) { func->decode_n = (decode_norm_t)s; }
     239                        }
     240
    226241                        if (s) {
    227                                 // use the shared library
    228                                 func->decode_n = (decode_norm_t)s;
    229242                                dec.style = DECODE_NORMAL;
    230243                                dec.el = NULL;
     
    294307        {
    295308                case DECODE_NORMAL:
    296                         decoders[sname][type].func->decode_n(type,packet,len);
     309                        /* If this is a pcapng packet call the correct function and pass the
     310                         * libtrace_packet_t structure. We need this to determine the byte ordering */
     311                        if (type == TRACE_TYPE_PCAPNG_META || type == TRACE_TYPE_ERF_META) {
     312                                decoders[sname][type].func->decode_meta(type,packet,len,p);
     313                        } else {
     314                                decoders[sname][type].func->decode_n(type,packet,len);
     315                        }
    297316                        break;
    298317
  • libpacketdump/libpacketdump.h

    r6654714 rd0f25d4  
    5555
    5656void decode(int link_type, const char *pkt, unsigned len);
     57void decode_meta(int link_type, const char *pkt, unsigned len, libtrace_packet_t *p);
    5758
    5859#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.