Changeset aa22b5b for lib/libtrace.h.in


Ignore:
Timestamp:
10/31/08 13:51:59 (13 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:
13fd6e1
Parents:
5d4e520
Message:

If we have a complete header, but truncated at the end of it, we shouldn't return NULL from
get_payload_from_* functions so we can distinguish it from a truncated header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    r530cef6 raa22b5b  
    10771077 * wireless monitoring header.
    10781078 *
     1079 * If the header is truncated, this function will return NULL, and remaining will be 0.
     1080 * If there are 0 bytes of payload, the function will return a pointer, and remaining will be 0.
     1081 *
    10791082 * @param[in] meta a pointer to a header
    10801083 * @param[in,out] linktype the linktype of meta (updated to indicate the
     
    10851088 * unchanged.
    10861089 *
    1087  * All parameters are mandatory. NULL will be returned if any are NULL.
     1090 * All parameters are mandatory.
    10881091 */
    10891092DLLEXPORT void *trace_get_payload_from_meta(const void *meta,
     
    11161119 * @param l2                    The pointer to the current layer2 header
    11171120 * @param linktype              The type of the layer2 header
    1118  * @param[out] ethertype        An optional output variable of the ethernet type
    1119  * @param[in,out] remaining     Optionally updated with the length remaining
     1121 * @param[out] ethertype        An optional output variable of the ethernet type of the new header
     1122 * @param[in,out] remaining     Updated with the length remaining
    11201123 *
    11211124 * @return a pointer to the transport layer header, or NULL if header isn't
    11221125 * present.
    11231126 *
    1124  * type may be NULL if not needed.
    1125  *
    1126  * Remaining may be NULL.  If Remaining is not NULL it must point to the number
    1127  * of bytes captured of the layer2 header and beyond.  It will be decremented
    1128  * by the number of bytes skipped to find the payload.
     1127 * Remaining must point to the number of bytes captured of the layer2 header
     1128 * and beyond.  It will be decremented by the number of bytes skipped to find
     1129 * the payload.
     1130 *
     1131 * If the layer2 header is complete but there are zero bytes of payload after the end of the header,
     1132 * a pointer to where the payload would be is returned and remaining will be set to 0.  If the
     1133 * layer2 header is incomplete (truncated), then NULL is returned and remaining will be set to 0.
    11291134 *
    11301135 */
     
    11691174 * present.
    11701175 *
    1171  * Remaining may be NULL.  If Remaining is not NULL it must point to the number
    1172  * of bytes captured of the IP header and beyond.  It will be decremented by
    1173  * the length of the IPv4 header (including any options).
    1174  *
    1175  * proto may be NULL if not needed.
     1176 * Remaining will be decremented by the size of the IPv4 header (including any options).
     1177 * If the IPv4 header is complete but there are zero bytes of payload after the IPv4 header, a pointer
     1178 * to where the payload would be is returned and remaining will be set to 0.  If the IPv4 header is
     1179 * incomplete, NULL will be returned and remaining will be set to 0.
     1180 *
     1181 * proto may be NULL, in which case it won't be updated
    11761182 *
    11771183 * @note This is similar to trace_get_transport_from_ip in libtrace2
     
    11881194 * isn't complete.
    11891195 *
    1190  * Remaining may be NULL.  If Remaining is not NULL it must point to the number
    1191  * of bytes captured of the IP header and beyond.  It will be decremented by
    1192  * this function by the length of the IPV6 header.
    1193  *
    1194  * proto may be NULL if not needed.
     1196 * Remaining will be decremented by the size of the IPv6 header (including any options).
     1197 * If the IPv6 header is complete but there are zero bytes of payload after the IPv6 header, a pointer
     1198 * to where the payload would be is returned and remaining will be set to 0.  If the IPv6 header is
     1199 * incomplete, NULL will be returned and remaining will be set to 0.
     1200 *
     1201 * proto may be NULL, in which case it won't be updated.
    11951202 *
    11961203 */
     
    12181225                uint16_t *type, uint32_t *remaining);
    12191226
    1220 /** Skips over any 802.1q headers, if present.
     1227/** Skips over any 802.1q header, if present.
    12211228 * @param vlan      A pointer to the vlan header
    1222  * @param[in,out] type  The ethernet type, replaced with the vlan ether type
     1229 * @param[out] type  The ethernet type, replaced with the vlan ether type
    12231230 * @param[in,out] remaining Updated with the number of bytes remaining
    12241231 *
    12251232 * @return a pointer to the header beyond the vlan header, if present.
    1226  * Otherwise, returns NULL
    1227  *
    1228  * Remaining may be NULL. If Remaining is not NULL it must point to the number
    1229  * of bytes captured past (but not including) the link layer. This function
    1230  * will decrement it by the length of the 802.1q headers if present.
    1231  *
    1232  * Type must point to the value of the ethernet type. Libtrace will assert
    1233  * fail if type is NULL.
     1233 * Otherwise, returns NULL. 
     1234 *
     1235 * Remaining will be decremented by the size of the vlan header.  If the vlan
     1236 * header is complete but there are zero bytes of payload after the vlan
     1237 * header, a pointer to where the payload would be is returned and remaining
     1238 * will be set to 0.  If the vlan header is incomplete, NULL will be returned
     1239 * and remaining will be set to 0.
     1240 *
     1241 * type will be set to the ethertype contained within the vlan payload.
    12341242 *
    12351243 */
     
    12371245                void *vlan, uint16_t *type, uint32_t *remaining);
    12381246
    1239 /** Skips over any MPLS headers, if present.
     1247/** Skips over a MPLS header
    12401248 * @param mpls      A pointer to the mpls header
    1241  * @param[in,out] type  The ethernet type, replaced by the ether type of the
     1249 * @param[out] type  The ethernet type, replaced by the ether type of the
    12421250 * following header - 0x0000 if an Ethernet header is deemed to be next
    12431251 * @param[in,out] remaining     Updated with the number of bytes remaining
     
    12451253 * @return a pointer to the header beyond the MPLS label, if present. Will
    12461254 * return NULL if there is not enough bytes remaining to skip past the MPLS
    1247  * label or if the ether type is not MPLS.
    1248  *
    1249  * Remaining may be NULL. If remaining is not NULL it must point to the number
    1250  * of bytes captured past (but not including) the link layer. This function
    1251  * will decrement it by the length of the topmost MPLS label if present.
     1255 * label.
     1256 *
     1257 * Remaining will be decremented by the size of the MPLS header.  If the MPLS
     1258 * header is complete but there are zero bytes of payload after the MPLS
     1259 * header, a pointer to where the payload would be is returned and remaining
     1260 * will be set to 0.  If the MPLS header is incomplete, NULL will be returned
     1261 * and remaining will be set to 0.
    12521262 *
    12531263 * Type must point to the value of the ethernet type. Libtrace will assert
     
    12661276 * @param[in,out] remaining Updated with the number of bytes remaining
    12671277 *
    1268  * @return a pointer to the tcp payload, or NULL if the payload isn't present.
    1269  *
    1270  * Remaining may be NULL.  If remaining is not NULL it must point to the number
    1271  * of bytes captured of the TCP header and beyond.  It will be decremented by
    1272  * this function by the length of the TCP header (including any options).
     1278 * @return a pointer to the tcp payload, or NULL if the tcp header is truncated.
     1279 *
     1280 * Remaining will be decremented by the size of the TCP header.  If the TCP
     1281 * header is complete but there are zero bytes of payload after the TCP
     1282 * header, a pointer to where the payload would be is returned and remaining
     1283 * will be set to 0.  If the TCP header is incomplete, NULL will be returned
     1284 * and remaining will be set to 0.
    12731285 *
    12741286 */
     
    12801292 * @param[in,out] remaining Updated with the number of bytes remaining
    12811293 *
    1282  * @return a pointer to the udp payload, or NULL if the payload isn't present.
    1283  *
    1284  * Remaining may be NULL.  If Remaining is not NULL it must point to the number
    1285  * of bytes captured of the UDP header and beyond.  It will be decremented by
    1286  * this function to the number of bytes remaining after the UDP header.
     1294 * @return a pointer to the udp payload, or NULL if the udp header is truncated.
     1295 *
     1296 * Remaining will be decremented by the size of the TCP header.  If the TCP
     1297 * header is complete but there are zero bytes of payload after the TCP
     1298 * header, a pointer to where the payload would be is returned and remaining
     1299 * will be set to 0.  If the TCP header is incomplete, NULL will be returned
     1300 * and remaining will be set to 0.
    12871301 *
    12881302 */
     
    12931307 * @param[in,out] remaining Updated with the number of bytes remaining
    12941308 *
    1295  * @return a pointer to the icmp payload, or NULL if the payload isn't present.
    1296  *
    1297  * Remaining may be NULL.  If remaining is not NULL it must point to the number
    1298  * of bytes captured of the ICMP header and beyond.  It will be decremented
    1299  * by the number of bytes in the ICMP header.
     1309 * @return a pointer to the icmp payload, or NULL if the icmp header is truncated.
     1310 *
     1311 * Remaining will be decremented by the size of the TCP header.  If the TCP
     1312 * header is complete but there are zero bytes of payload after the TCP
     1313 * header, a pointer to where the payload would be is returned and remaining
     1314 * will be set to 0.  If the TCP header is incomplete, NULL will be returned
     1315 * and remaining will be set to 0.
    13001316 *
    13011317 */
Note: See TracChangeset for help on using the changeset viewer.