Changeset 97678 in vbox
- Timestamp:
- Nov 24, 2022 7:09:04 PM (2 years ago)
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/Makefile.kmk
r96407 r97678 57 57 include $(PATH_SUB_CURRENT)/VirtualBox/Makefile.kmk 58 58 endif 59 ifdef VBOX_WITH_INTNET_PCAP 60 include $(PATH_SUB_CURRENT)/VBoxIntNetPcap/Makefile.kmk 61 endif 59 62 include $(PATH_SUB_CURRENT)/Common/Makefile.kmk 60 63 endif # !VBOX_ONLY_DOCS -
trunk/src/VBox/Frontends/VBoxIntnetPcap/Makefile.kmk
r96407 r97678 31 31 PROGRAMS += VBoxIntnetPcap 32 32 VBoxIntnetPcap_TEMPLATE := VBOXR3EXE 33 VBoxIntnetPcap_DEFS := \ 34 $(if $(VBOX_WITH_INTNET_SERVICE_IN_R3),VBOX_WITH_INTNET_SERVICE_IN_R3,) 33 35 VBoxIntnetPcap_INCS := \ 34 36 ../../NetworkServices/NetLib \ -
trunk/src/VBox/Frontends/VBoxIntnetPcap/VBoxIntnetPcap.cpp
r96407 r97678 48 48 * Internal Functions * 49 49 *********************************************************************************************************************************/ 50 static DECLCALLBACK(void) captureFrame(void *pvUser, void *pvFrame, uint32_t cbFrame);51 static DECLCALLBACK(void) captureGSO(void *pvUser, PCPDMNETWORKGSO pcGso, uint32_t cbFrame);52 50 53 51 … … 55 53 * Global Variables * 56 54 *********************************************************************************************************************************/ 57 static I ntNetIf g_net;55 static INTNETIFCTX g_hIntNetCtx; 58 56 static PRTSTREAM g_pStrmOut; 59 57 static uint64_t g_StartNanoTS; … … 70 68 { "--write", 'w', RTGETOPT_REQ_STRING }, 71 69 }; 70 71 72 static void checkCaptureLimit(void) 73 { 74 if (g_cCountDown > 0) 75 { 76 if (g_cCountDown-- == 1) 77 IntNetR3IfWaitAbort(g_hIntNetCtx); 78 } 79 } 80 81 82 static DECLCALLBACK(void) captureFrame(void *pvUser, void *pvFrame, uint32_t cbFrame) 83 { 84 RT_NOREF(pvUser); 85 86 int rc = PcapStreamFrame(g_pStrmOut, g_StartNanoTS, pvFrame, cbFrame, g_cbSnapLen); 87 if (RT_FAILURE(rc)) 88 { 89 RTMsgError("write: %Rrf", rc); 90 IntNetR3IfWaitAbort(g_hIntNetCtx); 91 } 92 93 if (g_fPacketBuffered) 94 RTStrmFlush(g_pStrmOut); 95 96 checkCaptureLimit(); 97 } 98 99 100 static DECLCALLBACK(void) captureGSO(void *pvUser, PCPDMNETWORKGSO pcGso, uint32_t cbFrame) 101 { 102 RT_NOREF(pvUser, pcGso, cbFrame); 103 104 checkCaptureLimit(); 105 } 72 106 73 107 … … 167 201 } 168 202 169 /* 170 * Configure the snooper. 171 */ 172 g_net.setInputCallback(captureFrame, NULL); 173 g_net.setInputGSOCallback(captureGSO, NULL); 174 175 /* 176 * NB: There's currently no way to prevent an intnet from being 177 * created when one doesn't exist, so there's no way to catch a 178 * typo... beware. 179 */ 180 rc = g_net.init(pszNetworkName); 181 if (RT_FAILURE(rc)) 182 return RTMsgErrorExitFailure("%s: %Rrf", pszNetworkName, rc); 183 184 rc = g_net.ifSetPromiscuous(); 185 if (RT_FAILURE(rc)) 186 return RTMsgErrorExitFailure("%s: failed to set promiscuous mode: %Rrf", pszNetworkName, rc); 203 rc = IntNetR3IfCreate(&g_hIntNetCtx, pszNetworkName); 204 if (RT_FAILURE(rc)) 205 return RTMsgErrorExitFailure("Opening the internal network '%s' failed with %Rrc\n", pszNetworkName, rc); 206 207 rc = IntNetR3IfSetPromiscuous(g_hIntNetCtx, true /*fPromiscuous*/); 208 if (RT_FAILURE(rc)) 209 return RTMsgErrorExitFailure("Enabling promiscuous mode on the internal network '%s' failed with %Rrc\n", pszNetworkName, rc); 210 211 rc = IntNetR3IfSetActive(g_hIntNetCtx, true /*fActive*/); 212 if (RT_FAILURE(rc)) 213 return RTMsgErrorExitFailure("Activating interface on the internal network '%s' failed with %Rrc\n", pszNetworkName, rc); 187 214 188 215 /* … … 196 223 RTStrmFlush(g_pStrmOut); 197 224 198 g_net.ifPump(); 225 rc = IntNetR3IfPumpPkts(g_hIntNetCtx, captureFrame, NULL /*pvUser*/, 226 captureGSO, NULL /*pvUserGso*/); 199 227 200 228 RTEXITCODE rcExit = RT_SUCCESS(RTStrmError(g_pStrmOut)) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; … … 204 232 return rcExit; 205 233 } 206 207 208 static void checkCaptureLimit(void)209 {210 if (g_cCountDown > 0)211 {212 if (g_cCountDown-- == 1)213 g_net.ifAbort();214 }215 }216 217 218 static DECLCALLBACK(void) captureFrame(void *pvUser, void *pvFrame, uint32_t cbFrame)219 {220 RT_NOREF(pvUser);221 222 int rc = PcapStreamFrame(g_pStrmOut, g_StartNanoTS, pvFrame, cbFrame, g_cbSnapLen);223 if (RT_FAILURE(rc))224 {225 RTMsgError("write: %Rrf", rc);226 g_net.ifAbort();227 }228 229 if (g_fPacketBuffered)230 RTStrmFlush(g_pStrmOut);231 232 checkCaptureLimit();233 }234 235 236 static DECLCALLBACK(void) captureGSO(void *pvUser, PCPDMNETWORKGSO pcGso, uint32_t cbFrame)237 {238 RT_NOREF(pvUser, pcGso, cbFrame);239 240 checkCaptureLimit();241 }
Note:
See TracChangeset
for help on using the changeset viewer.