Changeset 9231fe5 for lib/trace.c


Ignore:
Timestamp:
04/07/06 00:17:36 (15 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:
d320b63
Parents:
a842286
Message:

Minor cleanups in format_rt
Shuffled protocols.c around for better vlan support
Cleaned up IPv6 support to be more generic (less duplicated code)
added trace_get_{source,destination}_address

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    ra842286 r9231fe5  
    906906}
    907907
    908 /* Get the source MAC addres
    909  * @param packet        a pointer to a libtrace_packet structure
    910  * @returns a pointer to the source mac, (or NULL if there is no source MAC)
    911  * @author Perry Lorier
    912  */
    913 uint8_t *trace_get_source_mac(const struct libtrace_packet_t *packet) {
    914         void *link = trace_get_link(packet);
    915         libtrace_80211_t *wifi = link;
    916         libtrace_ether_t *ethptr = link;
    917         if (!link)
    918                 return NULL;
    919         switch (trace_get_link_type(packet)) {
    920                 case TRACE_TYPE_80211:
    921                         return (uint8_t*)&wifi->mac2;
    922                 case TRACE_TYPE_ETH:
    923                         return (uint8_t*)&ethptr->ether_shost;
    924                 default:
    925                         fprintf(stderr,"Not implemented\n");
    926                         assert(0);
    927         }
    928 }
    929 
    930 /* Get the destination MAC addres
    931  * @param packet a libtrace_packet pointer
    932  * @returns a pointer to the destination mac, (or NULL if there is no
    933  * destination MAC)
    934  * @author Perry Lorier
    935  */
    936 uint8_t *trace_get_destination_mac(const struct libtrace_packet_t *packet) {
    937         void *link = trace_get_link(packet);
    938         libtrace_80211_t *wifi = link;
    939         libtrace_ether_t *ethptr = link;
    940         if (!link)
    941                 return NULL;
    942         switch (trace_get_link_type(packet)) {
    943                 case TRACE_TYPE_80211:
    944                         return (uint8_t*)&wifi->mac1;
    945                 case TRACE_TYPE_ETH:
    946                         return (uint8_t*)&ethptr->ether_dhost;
    947                 default:
    948                         fprintf(stderr,"Not implemented\n");
    949                         assert(0);
    950         }
    951 }
    952 
    953 
    954908/* process a libtrace event
    955909 * @param trace the libtrace opaque pointer
     
    11141068        }
    11151069        return -1;
    1116 }
    1117 
    1118 struct ports_t {
    1119         uint16_t src;
    1120         uint16_t dst;
    1121 };
    1122 
    1123 /* Return the client port
    1124  */
    1125 uint16_t trace_get_source_port(const struct libtrace_packet_t *packet)
    1126 {
    1127         struct ports_t *port = trace_get_transport(packet, NULL);
    1128 
    1129         return ntohs(port->src);
    1130 }
    1131 
    1132 /* Same as get_source_port except use the destination port */
    1133 uint16_t trace_get_destination_port(const struct libtrace_packet_t *packet)
    1134 {
    1135         struct ports_t *port = trace_get_transport(packet, NULL);
    1136 
    1137         return ntohs(port->dst);
    11381070}
    11391071
Note: See TracChangeset for help on using the changeset viewer.