Developers

Unable to add a column to the packet list

A place for developers to exchange information about extending OmniPeek, and ask technical questions about plugins on MyPeek, scripting, and programming.
matman13
Posts: 6
Joined: Mon Jul 19, 2010 6:45 pm

Unable to add a column to the packet list

Postby matman13 » Mon Jul 19, 2010 7:00 pm

I'm using OP v6.0.7. I downloaded the Visual Studio 2008 Wizard and generated a plugin called TestPlugin. I have successfully compiled the plugin and see default behavior, namely the counting of TCP SYN and FIN packets. So far so good.

Now I'm trying to add a custom column to the packet list using the DoSetPacketListColumn() API. At first, the return code was -1, but I tracked this down - the PeekPlugin::s_procSetPacketListColumn callback was not being set in the CPeekApp::Init() function (apparently just an oversight in the wizard). I've fixed this, and now the return code is 87. I have no idea what this means and need some direction.

Here's the code I've got:


Code: Select all

int CTestPluginPlugin::OnCreateContext(
    PluginCreateContextParam *ioParams)
{
    CTestPluginContext *pContext = new CTestPluginContext(m_pPeekApp, this);
    if (pContext == NULL) return PLUGIN_RESULT_ERROR;

    if (ioParams->fContextFlags == kContextType_Global) {
        m_pGlobalContext = pContext;
    }

    if (pContext != NULL) {
        pContext->Init(ioParams);
        m_aContextList.Add(pContext);
        if (GetAPIVersion() < kPluginAPIVersion12) {
            AddListener(pContext);
        }
        *(ioParams->fContextPtr) = pContext;

        // Cannot get this to work...
        if (ioParams->fContextFlags == kContextType_CaptureWindow) {
            int nResult = DoSetPacketListColumn(
                pContext,
                &s_ColumnID,
                _T("My Column"),
                _T("My Column"),
                false,
                100,
                kPluginColumnAlighment_Left);
            if (nResult != PLUGIN_RESULT_SUCCESS) {
                int value = nResult; // set breakpoint here...
            }
        }
    }
}


The plugin still loads sucessfully, but the "My Column" is not available to be shown in the packet list from the Options. Any help would be greatly appreciated.

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

RE: Unable to add a column to the packet list

Postby gdvc84@motorola.com » Tue Jul 20, 2010 5:59 pm

Well, looking at the API, it looks like you've set the defaultVisibility to "False". Did you try to right click on the column labels and see whether "My Column" is present or not?

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

RE: RE: Unable to add a column to the packet list

Postby gdvc84@motorola.com » Tue Jul 20, 2010 6:28 pm

OK, I got this to work by putting it inside Init() method of your C*Context class.

Looks like OP does not know about the pContext parameter that you are passing. Will leave it to someone from WildPackets to give a detailed explanation if needed :)

matman13
Posts: 6
Joined: Mon Jul 19, 2010 6:45 pm

RE: RE: RE: Unable to add a column to the packet list

Postby matman13 » Wed Jul 21, 2010 9:10 am

Thanks so much, gdvc84!!! That fixed it for me.

Spacepacket
Posts: 78
Joined: Thu May 22, 2008 9:36 am

RE: RE: RE: RE: Unable to add a column to the packet list

Postby Spacepacket » Wed Jul 21, 2010 11:54 am

Thanks gdvc84!

matman13, is you call DoSetPacketListColumn() from within the context object, you do not have to pass the context pointer.

Once you created the column, were you able to put stuff in it?

Here is a sample:


// ----------------------------------------------------------------------------
// OnDrawPacketListCell
// ----------------------------------------------------------------------------

int CMyContext::OnDrawPacketListCell(
PluginDrawPacketListCellParam* ioParams )
{
_tcscpy( ioParams->fOutCellText, _T("Stuff") );
ioParams->fInCellTextMaxLength = _tcslen(ioParams->fOutCellText) * 2;

return 0;
}

-spacepacket

matman13
Posts: 6
Joined: Mon Jul 19, 2010 6:45 pm

RE: RE: RE: RE: RE: Unable to add a column to the packet lis

Postby matman13 » Wed Jul 21, 2010 12:10 pm

Spacepacket, yes, I was able to insert text into the column using code very similar to what you've shown. Out of curiosity, does the "fInCellTextMaxLength" need to be set as you've shown? I didn't update the field in my project, and the text shows fine. The field name indicates it is an input parameter, so is there any reason to set this value?

I'm beginning to build up my functionality now. Thanks for the help!

Spacepacket
Posts: 78
Joined: Thu May 22, 2008 9:36 am

RE: RE: RE: RE: RE: RE: Unable to add a column to the packet

Postby Spacepacket » Wed Jul 21, 2010 1:44 pm

I think it needs to be set. Maybe there is random value in there?

matman13
Posts: 6
Joined: Mon Jul 19, 2010 6:45 pm

RE: RE: RE: RE: RE: RE: RE: Unable to add a column to the pa

Postby matman13 » Thu Jul 22, 2010 8:33 am

It didn't look random to me. It was set to 1024 when I checked it in the debugger.

Spacepacket
Posts: 78
Joined: Thu May 22, 2008 9:36 am

RE: RE: RE: RE: RE: RE: RE: RE: Unable to add a column to th

Postby Spacepacket » Thu Jul 22, 2010 3:15 pm

I checked the OmniPeek code. Look like I was wrong. That value is the size of the buffer, not the length of the string. It does not look like you need to specify the length of the string. It must do a strlen() on what you give.


Return to “Developers”

Who is online

Users browsing this forum: No registered users and 2 guests