NmGetFieldName

May 27, 2009 at 9:54 AM
Edited May 27, 2009 at 9:56 AM

Hi

I'm trying to do program that lists frames all properties with NMApi using C#.
Below sample populates Fields-list only when RequestedName attribute is

NamePath (about 109 entries on http frame). It fails on DataTypeName and ContainingProtocolName.
For those NmGetFieldName returns error 160 (Bad argument).
What I'm doing wrong?

List<string> Fields = new List<string>();
uint fcount;
NetmonAPI.NmGetFieldCount(myParsedFrame, out fcount);
for (uint i = 0; i < fcount; i++)
{
    unsafe
    {
        char[] Data = new char[1024];
        fixed (char* c = &Data[0])
            ret = NetmonAPI.NmGetFieldName(myParsedFrame, i, NmParsedFieldNames.DataTypeName, 1024, c);
        if (ret != 0)
            continue;
        Fields.Add(new string(Data, 0, 1024).Trim('\0'));
    }
}

May 28, 2009 at 7:33 PM

Hi Mauno,

When you call NmParseFrame, you need to make sure you pass all the options you want to collect from the NmGetFieldName function.

ret = NetmonAPI.NmParseFrame(myFrameParser,
                      hRawFrame,
                      curFrame,
                      NmFrameParsingOption.FieldFullNameRequired |
                      NmFrameParsingOption.FieldDisplayStringRequired | 
                      
NmFrameParsingOption.DataTypeNameRequired |
                     
NmFrameParsingOption.ContainingProtocolNameRequired
                      out myParsedFrame, 
                      out insertedFrame);

If you don't have the ContainingProtocolName or DataTypeName, then you'll get the bad argument error when calling NmGetFieldName.

Michael