private String GetIPAddr(uint fieldId)
        {
            IpAddress reAddr = new IpAddress()
            {
                ad1 = 0,
                ad2 = 0,
                ad3 = 0,
                ad4 = 0
            };

            unsafe
            {
                IntPtr add = Marshal.AllocHGlobal(4);

                uint relen;
                uint ret1;
                ret1   = NetmonAPI.NmGetFieldInBuffer(_FrameInfoUnit.ParsedFrame, fieldId, (uint)4, (byte *)add, out relen);
                reAddr = (IpAddress)Marshal.PtrToStructure(add, typeof(IpAddress));
                Marshal.Release(add);
            }

            return(IpAddrToString(reAddr));
        }
Ejemplo n.º 2
0
        public byte[] GetFieldBuffer(string name)
        {
            if (this.Parser == null)
            {
                return(null);
            }

            if (!this.Parser.HasField(name))
            {
                return(null);
            }

            uint offset, bsize;
            uint fieldId = this.Parser.Field(name);

            if (0 == NetmonAPI.NmGetFieldOffsetAndSize(ParsedFrame, fieldId, out offset, out bsize))
            {
                if (bsize > 0)
                {
                    uint   size  = bsize / 8;
                    byte[] bytes = new byte[bsize / 8];
                    UInt32 uRet;
                    unsafe
                    {
                        fixed(byte *ptr = bytes)
                        {
                            if (0 == NetmonAPI.NmGetFieldInBuffer(ParsedFrame, fieldId, size, ptr, out uRet))
                            {
                                return(bytes);
                            }
                        }
                    }
                }
            }
            return(null);
        }