/** * @brief Sends a IPv4 fragment to libntoh */ void send_ipv4_fragment ( struct ip *iphdr , pipv4_dfcallback_t callback ) { ntoh_ipv4_tuple4_t ipt4; pntoh_ipv4_flow_t flow; size_t total_len; int32_t ret; uint32_t error; total_len = ntohs( iphdr->ip_len ); ntoh_ipv4_get_tuple4 ( iphdr , &ipt4 ); if ( !( flow = ntoh_ipv4_find_flow( ipv4_session , &ipt4 ) ) ) { if ( ! (flow = ntoh_ipv4_new_flow( ipv4_session , &ipt4, callback, 0 , &error )) ) { if (DEBUG) { fprintf ( stderr , "\n[e] Error %d creating new IPv4 flow: %s" , error , ntoh_get_errdesc ( error ) ); } return; } } if ( ( ret = ntoh_ipv4_add_fragment( ipv4_session , flow, iphdr, total_len ) ) ) { if (DEBUG) { fprintf( stderr, "\n[e] Error %d adding IPv4: %s", ret, ntoh_get_retval_desc( ret ) ); } } return; }
/** * @brief Sends a IPv4 fragment to libntoh */ void send_ipv4_fragment ( struct ip *iphdr , pipv4_dfcallback_t callback ) { ntoh_ipv4_tuple4_t ipt4; pntoh_ipv4_flow_t flow; int ret; unsigned int error; ntoh_ipv4_get_tuple4 ( iphdr , &ipt4 ); if ( !( flow = ntoh_ipv4_find_flow( ipv4_session , &ipt4 ) ) ) if ( ! (flow = ntoh_ipv4_new_flow( ipv4_session , &ipt4, callback, 0 , &error )) ) { fprintf ( stderr , "\n[e] Error %d creating new IPv4 flow: %s" , error , ntoh_get_errdesc ( error ) ); return; } if ( ( ret = ntoh_ipv4_add_fragment( ipv4_session , flow, iphdr ) ) ) fprintf( stderr, "\n[e] Error %d adding IPv4: %s", ret, ntoh_get_retval_desc( ret ) ); return; }