Changeset 1372

Show
Ignore:
Timestamp:
24/10/08 09:58:02 (2 months ago)
Author:
salcock
Message:
  • Renamed hideous get_*_payload_from_ethernet_payload API functions to match the get_payload_from_* naming convention
  • trace_get_payload_from_vlan now returns NULL if passed something other than a vlan header or there is no header present after the vlan header, instead of returning the original header that was passed in
  • trace_get_payload_from_ip* functions now check if the ip header passed in is NULL and return NULL appropriately
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/libtrace.h.in

    r1360 r1372  
    12191219 
    12201220/** Skips over any 802.1q headers, if present. 
    1221  * @param ethernet      A pointer to the payload following an ethernet header 
    1222  * -usually the result of calling trace_get_payload_from_link 
     1221 * @param vlan      A pointer to the vlan header 
    12231222 * @param[in,out] type  The ethernet type, replaced with the vlan ether type 
    12241223 * @param[in,out] remaining Updated with the number of bytes remaining 
    12251224 * 
    12261225 * @return a pointer to the header beyond the vlan header, if present. 
    1227  * Otherwise, returns the ethernet payload that was passed in 
     1226 * Otherwise, returns NULL 
    12281227 * 
    12291228 * Remaining may be NULL. If Remaining is not NULL it must point to the number 
     
    12351234 * 
    12361235 */ 
    1237 DLLEXPORT void *trace_get_vlan_payload_from_ethernet_payload
    1238                 void *ethernet_payload, uint16_t *type, uint32_t *remaining); 
     1236DLLEXPORT void *trace_get_payload_from_vlan
     1237                void *vlan, uint16_t *type, uint32_t *remaining); 
    12391238 
    12401239/** Skips over any MPLS headers, if present. 
    1241  * @param ethernet_payload      A pointer to the payload following an ethernet 
    1242  * header - usually the result of calling trace_get_payload_from_link 
     1240 * @param mpls      A pointer to the mpls header 
    12431241 * @param[in,out] type  The ethernet type, replaced by the ether type of the 
    12441242 * following header - 0x0000 if an Ethernet header is deemed to be next 
     
    12611259 * 
    12621260 */ 
    1263 DLLEXPORT void *trace_get_mpls_payload_from_ethernet_payload
    1264                 void *ethernet_payload, uint16_t *type, uint32_t *remaining); 
     1261DLLEXPORT void *trace_get_payload_from_mpls
     1262                void *mpls, uint16_t *type, uint32_t *remaining); 
    12651263 
    12661264/** Gets a pointer to the payload given a pointer to a tcp header 
  • trunk/lib/protocols_l2.c

    r1360 r1372  
    3131 * type is input/output 
    3232 */ 
    33 void *trace_get_vlan_payload_from_ethernet_payload(void *ethernet, uint16_t *type, 
     33void *trace_get_payload_from_vlan(void *ethernet, uint16_t *type, 
    3434                uint32_t *remaining) 
    3535{ 
     
    5050 
    5151                return (void*)((char *)ethernet + sizeof(*vlanhdr)); 
    52         } 
    53  
    54         return ethernet; 
     52        } else 
     53                return NULL; 
     54 
    5555} 
    5656 
     
    5959 * return a type of 0x0000. 
    6060 */ 
    61 void *trace_get_mpls_payload_from_ethernet_payload(void *ethernet, 
    62                 uint16_t *type, uint32_t *remaining) 
     61void *trace_get_payload_from_mpls(void *ethernet, uint16_t *type,  
     62                uint32_t *remaining) 
    6363{ 
    6464        assert(type != NULL); 
  • trunk/lib/protocols_l3.c

    r1360 r1372  
    4949        void *trans_ptr = 0; 
    5050 
    51         if ((ntohs(ipptr->ip_off) & SW_IP_OFFMASK) != 0) { 
     51        if (ipptr == NULL) 
     52                return NULL; 
     53 
     54        if ((ntohs(ipptr->ip_off) & SW_IP_OFFMASK) != 0) { 
    5255                if (remaining) 
    5356                        *remaining = 0;          
     
    7679        uint8_t nxt = ipptr->nxt; 
    7780 
     81        if (ipptr == NULL) 
     82                return NULL; 
     83         
    7884        if (remaining) { 
    7985                if (*remaining<sizeof(libtrace_ip6_t)) { 
     
    156162                switch(*ethertype) { 
    157163                case 0x8100: /* VLAN */ 
    158                         iphdr=trace_get_vlan_payload_from_ethernet_payload
     164                        iphdr=trace_get_payload_from_vlan
    159165                                          iphdr,ethertype,remaining); 
    160166                        continue; 
    161167                case 0x8847: /* MPLS */ 
    162                         iphdr=trace_get_mpls_payload_from_ethernet_payload
     168                        iphdr=trace_get_payload_from_mpls
    163169                                          iphdr,ethertype,remaining); 
    164170