source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPOfflineCapture.cpp @ 35

Last change on this file since 35 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 803 bytes
Line 
1/**
2 * @file PCAPOfflineCapture.cpp
3 * @author Tomas Urban
4 * @version 0.4
5 * @date 23/07/2009
6 */
7#include "PCAPOfflineCapture.h"
8#include "Logger/Logger.h"
9
10PCAPOfflineCapture::PCAPOfflineCapture()
11{
12}
13
14PCAPOfflineCapture::~PCAPOfflineCapture(void)
15{
16}
17
18ECaptureInitResult PCAPOfflineCapture::OpenDevice(const std::string sParams)
19{
20        CloseDevice();
21        char errbuf[PCAP_ERRBUF_SIZE];
22        char source[PCAP_BUF_SIZE];
23
24        if ( pcap_createsrcstr( source, PCAP_SRC_FILE, NULL, NULL, sParams.c_str(), errbuf) != 0)
25                return ECaptureInit_Failed;
26
27        pcap_t * fp = OpenPcapSource(source);
28        if (!fp)
29                return ECaptureInit_Failed;
30
31        pcap_pkthdr header;
32        if (pcap_next(fp, &header))
33                SetStartPoint(header.ts);
34        pcap_close(fp);
35        fp = OpenPcapSource(source);
36       
37
38        SetPcapHandles(&fp, 1);
39        return ECaptureInit_Successful;
40}
Note: See TracBrowser for help on using the repository browser.