Pointer problems

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
 
M

Mattias Sjögren

Not sure what to try next. Any suggestions?

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


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top