capture_threads_example.c
Go to the documentation of this file.
115 * will return NT_SUCCESS when a segment is returned. Segments with NT_NET_GET_SEGMENTLENGTH()==0
117 * the segment. The NT_NET_GET_SEGMENT_TIMESTAMP() macro can still be used on the empty segments.
162 int pthread_create(HANDLE *thread, DWORD *attr, start_address_t start_routine, void *parameter);
266 NtNetBuf_t hNetBuf = NULL; // Net buffer container. Segment data is returned in this when calling NT_NetRxGet().
269 struct ntpcap_ts_s* pTs = (struct ntpcap_ts_s *)(void *)&(pRxThread->ntplTs); // Used if PCAP header is used
275 // Get a stream handle with stream ID. NT_NET_INTERFACE_SEGMENT specify that we will receive data in a segment based matter.
280 fprintf(stderr, "RxStream [%i]: NT_NetRxOpen() failed: %s\n", pRxThread->streamId, errorBuffer);
292 fprintf(stderr, "RxStream [%i]: NT_NetRxRead() failed: %s\n", pRxThread->streamId, errorBuffer);
297 if (fwrite(readCmd.u.fileheader.data, (size_t)readCmd.u.fileheader.size, 1, pRxThread->hf) <= 0) {
324 fprintf(stderr, "RxStream [%i]: NT_NetRxRead() failed: %s\n", pRxThread->streamId, errorBuffer);
328 // We got a segment. Check if the timestamp is newer than when the NTPL assign command was applied
331 if ((((struct ntpcap_ts_s *)NT_NET_GET_SEGMENT_PTR(hNetBuf))->sec * 1000000 + ((struct ntpcap_ts_s *)NT_NET_GET_SEGMENT_PTR(hNetBuf))->usec) >
333 break; // Break out, we have received a segment that is received after the NTPL assign command was applied
337 if ((((struct ntpcap_ts_s *)NT_NET_GET_SEGMENT_PTR(hNetBuf))->sec * 1000000000 + ((struct ntpcap_ts_s *)NT_NET_GET_SEGMENT_PTR(hNetBuf))->usec) >
339 break; // Break out, we have received a segment that is received after the NTPL assign command was applied
343 break; // Break out, we have received a segment that is received after the NTPL assign command was applied
352 fprintf(stderr, "RxStream [%i]: NT_NetRxRelease() failed: %s\n", pRxThread->streamId, errorBuffer);
366 (unsigned long long)NT_NET_GET_SEGMENT_TIMESTAMP(hNetBuf), pRxThread->streamId, NT_NET_GET_SEGMENT_LENGTH(hNetBuf));
393 if (fwrite(NT_NET_GET_SEGMENT_PTR(hNetBuf), NT_NET_GET_SEGMENT_LENGTH(hNetBuf), 1, pRxThread->hf) <= 0) {
404 fprintf(stderr, "RxStream [%i]: NT_NetRxRelease() failed: %s\n", pRxThread->streamId, errorBuffer);
436 fprintf(stderr, "RxStream [%i]: NT_NetRxClose() failed: %s\n", pRxThread->streamId, errorBuffer);
473 // Initialize the NTAPI library and thereby check if NTAPI_VERSION can be used together with this library
549 printf("Done: %16d segments, %16d packets, %16llu bytes, %16llu bytes on wire\n", numSegments, numPackets, numBytes, numBytesWire);