Pointer problems

  • Thread starter Thread starter Blip
  • Start date Start date
B

Blip

Here is the relevant part of my structure...

[StructLayout(LayoutKind.Sequential)]
public unsafe struct PPF_FILTER_DESCRIPTOR
{


public int* SrcAddr;
public int* SrcMask;
public int* DstAddr;
public int* DstMask;

}

private PPF_FILTER_DESCRIPTOR filter;


I'm trying to fill the field, SrcAddr -
an int* PPF_FILTER_DESCRIPTOR.SrcAddr
as filter.SrcAddr

I can't seem to do this w/o errors...
Obviously, this is a hobby project.

Here's what I've been trying

IPAddress sip = IPAddress.Parse("10.1.1.1");
Unsafe {
src = BitConverter.ToInt32(sip.GetAddressBytes(), 0);
filter.SrcAddr = &src;
}

This errors w/: You can only take the address of an unfixed expression
inside of a fixed statement initializer


I've tried:
fixed(filter.SrcAddr = &src;)

This errors w/: Type or namespace name expected, but fieldname found.

Not sure what to try next. Any suggestions?

Thanks
 
Not sure what to try next. Any suggestions?

fixed (int* p = &src)
{
filter.SrcAddr = p;
// ...
}


Mattias
 
Back
Top