views:

596

answers:

2

I am doing a project where I must craft custom packets. That is, I have to have control of each packet header. I am trying to do this using sockets. Basically, what I need to do is this:

SOCKET s = socket(PF_UNSPEC, SOCK_RAW, ethernet_type);

The ethernet_type is something that is customized, non-standard, like 0xAAAA. I am using htons(). Also, it is very preferable for me not to use winPcap.

Right now, I am getting error 10043, protocol not supported.

The error message seems to suggest that I can configure the protocol into my system, but I have no idea how to do that.

It says:

Protocol not supported. The requested protocol has not been configured into the system, or no implementation for it exists. For example, a socket call requests a SOCK_DGRAM socket, but specifies a stream protocol.

There are a few different issues here, so if anyone has any input at all I'd really appreciate it.

+1  A: 

According to these articles, Microsoft removed raw socket support from Windows in a non-removable hotfix. So you may be out of luck unless you want to switch to another OS.

Rick Copeland
I can open the raw socket using other options though. Also, the error is about the protocol type (the last option, I called it ethernet_type).
devin
A: 

I think that adding new protocols to the socket call would be something quite difficult. You'd have to make sure that socket supports that call. I think you would have to recompile the socket function and I dont think it's easily possible under windows.

Crafting custom packets does not require you to create a new protocol

I think that the correct way of specifying a RAW socket is like this

SOCKET s;
s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);

If you're really trying to play with raw ethernet like your variable names suggest, then either you use winpcap driver or write your own driver

I don't think there is another "easy" solution to raw ethernet. winpcap is rather easy so you might want to check it out

Eric