Changeset 87910 in vbox
- Timestamp:
- Mar 2, 2021 12:03:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxIntnetPcap/VBoxIntnetPcap.cpp
r87908 r87910 35 35 36 36 IntNetIf g_net; 37 RTFILE g_hPcapFile = NIL_RTFILE;37 PRTSTREAM g_pStrmOut; 38 38 uint64_t g_u64Count; 39 39 size_t g_cbSnapLen; … … 153 153 154 154 if (g_cbSnapLen == 0) 155 g_cbSnapLen = 262144; /* traditional limit is 256K */ 156 157 158 rc = RTFileOpen(&g_hPcapFile, strPcapFile.c_str(), 159 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE); 160 if (RT_FAILURE(rc)) 161 return RTMsgErrorExit(RTEXITCODE_FAILURE, 162 "%s: %Rrf", strPcapFile.c_str(), rc); 155 g_cbSnapLen = 0xffff; 156 157 158 if (strPcapFile == "-") 159 { 160 g_pStrmOut = g_pStdOut; 161 } 162 else 163 { 164 rc = RTStrmOpen(strPcapFile.c_str(), "wb", &g_pStrmOut); 165 if (RT_FAILURE(rc)) 166 return RTMsgErrorExit(RTEXITCODE_FAILURE, 167 "%s: %Rrf", strPcapFile.c_str(), rc); 168 } 163 169 164 170 g_net.setInputCallback(captureFrame, NULL); … … 181 187 strNetworkName.c_str(), rc); 182 188 183 rc = Pcap FileHdr(g_hPcapFile, RTTimeNanoTS());189 rc = PcapStreamHdr(g_pStrmOut, RTTimeNanoTS()); 184 190 if (RT_FAILURE(rc)) 185 191 return RTMsgErrorExit(RTEXITCODE_FAILURE, … … 187 193 188 194 g_net.ifPump(); 189 RT FileClose(g_hPcapFile);195 RTStrmClose(g_pStrmOut); 190 196 191 197 return RTEXITCODE_SUCCESS; … … 211 217 RT_NOREF(pvUser); 212 218 213 rc = Pcap FileFrame(g_hPcapFile, RTTimeNanoTS(),214 pvFrame, cbFrame, g_cbSnapLen);219 rc = PcapStreamFrame(g_pStrmOut, RTTimeNanoTS(), 220 pvFrame, cbFrame, g_cbSnapLen); 215 221 if (RT_FAILURE(rc)) { 216 222 RTMsgError("write: %Rrf", rc);
Note:
See TracChangeset
for help on using the changeset viewer.