Adam,
at the very least, you will need to include the IP_HDRINCL socket option
with a value of TRUE. Something like this:
Socket sok = new
Socket(AddressFamily.InterNetwork,System.Net.Socke ts.SocketType.Raw,
ProtocolType.Raw);
sok.SetSocketOption(SocketOptionLevel.IP,SocketOpt ionName.HeaderIncluded,tru
e);
and then you MUST send the 28 bytes of IP header information.
Note - the IP_HDRINCL option, and raw sockets in general are a security
issue in Windows NT and later - and you need to be a member of the
administrators group to create sockes of this type. To disable this
restriction, the value of this registry variable to the value of 1 as DWORD
type:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Servic es\Afd\Parameters\DisableR
awSecurity
regards
roy fine
"Adam Clauss" <cabadam@tamu.edu> wrote in message
news:eTRoO6rZEHA.2388@TK2MSFTNGP09.phx.gbl...[color=blue]
> I am (attempting) to move an existing socket application to use raw[/color]
sockets.[color=blue]
>
> Right now, my application is essentially a port forwarder. Upon receiving[/color]
a[color=blue]
> connection, it will open a connection to an "internal" server and simply
> relay all information back and forth (when the client sends something, my
> app sends that to the server, when server sends something, my app sends[/color]
that[color=blue]
> to the client).
>
> While what I have right DOES work, the downside is that to the server, all
> connections appear to come from the IP address where my program is[/color]
running.[color=blue]
> I want it to instead appear as if it came from the original client IP (as[/color]
a[color=blue]
> true port forwarding router/etc would).
>
> I understand to do this I will have to use Raw sockets, and that I will[/color]
need[color=blue]
> to recreate the IP header. But beyond this, I am not sure where to go.
>
> Partly in a conceptual sense - (HOW to actually create the IP header) and
> partly in a literal sense - I tried creating a raw socket:
> serverSocket = new Socket(AddressFamily.InterNetwork,
> System.Net.Sockets.SocketType.Raw, ProtocolType.Raw);
>
> and then connected to the server as I do for the normal sockets - but the
> server did not even register the connection.
>
> Any advise? Examples or good articles on this would be greatly
> appreciated!!
>
> Thanks,
> Adam Clauss
>
Join Bytes!
>
>[/color]