Developers

Per capture options

A place for developers to exchange information about extending OmniPeek, and ask technical questions about plugins on MyPeek, scripting, and programming.
gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 2:03 pm

Hi,

In plugin-primer you mentioned about per capture option setting using tabs. I'm curious to know how will this work?

- Should I prompt the user to enter options when creating the context (onCreateContext) and return from this only when the options are entered?

- Or can I have a tab where the user can specify the options and then have the packets processed all over again - How to do this?

Thanks,

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

RE: Per capture options

Postby GVWP » Thu Aug 12, 2010 3:45 pm

A quick overview of Per Context Preferences:
Create a new plugin from the Plugin Wizard and with both the 'Tab' and the 'Support Context Preferences' check boxes checked. And Finish the plugin.

Build the plugin and launch Peek. Create a new capture and the Capture Options dialog will now have a 'new' tab item: Analysis Modules. Select that tab, select the plugin you just created and click the Options button. The OnContextOptions method gets called.

If the plugin's options have been modified then OnSetContextPrefs will be called after the context has been created.

On the plugin's tab you could display the current settings or a button that displays the plugin's Option dialog. If you allow the user to modify the plugin's settings while a capture is running, be aware that the OnFilter method runs on a different thread from all the other methods, so access control of the context's m_Options is needed.

Hope this helps.

gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

RE: RE: Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 4:00 pm

Hi,

Thanks for your help and info. But I realized that I wasn't clear in my earlier post so this doesn't completely answer me.

The plug-in I'm developing actually is being used as an offline-analysis module. We use OmniEngine to capture the packets and then try to analyse on OmniPeek later.

So how does the per-capture setting work with this setting?

gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

RE: RE: RE: Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 4:08 pm

i.e. how to specify the options for the file windows?

"If you allow the user to modify the plugin's settings while a capture is running"

Say I have an option to specify TCP/UDP. My plug-in calculates the total no of packets in the capture (either TCP or UDP).

Initially I keep TCP selected. Half way through I select UDP. Now, how does this work exactly? Will the already processed UDP packets be lost from the count?

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

Per capture options

Postby GVWP » Thu Aug 12, 2010 4:59 pm

One method is to display the plugin's Option dialog during the Context's Init() method.

In Context::Init() add:
if (ioParams->fContextFlags == kContextType_FileWindow ) {
AFX_MANAGE_STATE( AfxGetStaticModuleState() );
OnContextOptions( NULL );
}

in Context::OnContextOptions() check ioParams before using it:
if ( ioParams ) m_Options.SetContextPrefs( ioParams->fInOldPrefs );
and:
if ( ioParams ) {
ioParams->fOutNewPrefs = m_strPrefs.GetBuffer();
ioParams->fOutNewPrefsLength = m_strPrefs.GetLength();
}

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

RE: Per capture options

Postby GVWP » Thu Aug 12, 2010 5:10 pm

It's up to you to decide how you want to handle what happens when the context's settings are changed during a capture.

If you provide a button that displays the plugin's Option dialog, then Peek doesn't even know about the change in settings. Be sure to call DoSaveContext() so that Peek can get a copy of the context's current settings.

gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

RE: RE: Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 5:13 pm

Hi,

Thanks for your input. I will try these.

Regarding the TCP/UDP question: If a user changes the option mid-way, is there any way that I can force OmniPeek to send me all the prior packets? Something like a Reset and do-over call?

Thanks,
Vasanth

gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

RE: RE: RE: Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 5:21 pm

Sorry for spamming again :)

Is it really necessary to send the XML to Peek? Is it required if I do not have any global options?

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

Per capture options

Postby GVWP » Thu Aug 12, 2010 5:27 pm

You can get all the packets that are in the capture buffer.
Use DoGetPacketCount(), GetFirstPacketIndex() and DoGetPacket().

Note that the capture buffer is a ring-buffer. The first packet in the buffer may no longer be packet 1. If the buffer has wrapped, then the 'old' packets are gone.

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

RE: Per capture options

Postby GVWP » Thu Aug 12, 2010 5:37 pm

Calling DoSaveContext() keeps Peek's copy of the plugin's context preferences (settings) consistent with what the plugin is using.

This is important for when the user creates a Capture Template File (CTF). The CTF is created with Peek's copy of the plugin's preferences (Peek does not query the plugin during creation of the CTF).

You don't need to call DoSaveContext() for capture files, since the user can't create a CTF from a capture file.

gdvc84@motorola.com
Posts: 17
Joined: Wed Jun 23, 2010 11:36 am

RE: RE: Per capture options

Postby gdvc84@motorola.com » Thu Aug 12, 2010 5:39 pm

Perfect! Thanks for all the help!

Really appreciate you and Spacepacket's prompt replies!! Keep it going!

GVWP
Posts: 7
Joined: Fri Apr 03, 2009 11:27 am

RE: RE: RE: Per capture options

Postby GVWP » Thu Aug 12, 2010 5:40 pm

You are very welcome.


Return to “Developers”

Who is online

Users browsing this forum: No registered users and 2 guests