Hello together
I've a question about layer-2 (ethernet frames) capturing.
I have a Network and Linux Admin background, but not a really heavy programmer.
In C i can create a socket( AF_PACKET, SOCK_RAW, 0 ) and thats it.
import core.stdc ... # there is no socket.d ...
# i used a:
$ grep -ir socket /usr/include/dlang/dmd/core/stdc/"
# but no success.
Ok so it's have to be possible with D there is all i need i think and at this moment i'm struggle on:
import std.stdio;
import std.socket;
Socket init_sock() {
auto socket = new Socket( AddressFamily.INET, SocketType.RAW, ProtocolType.RAW );
socket.setOption( SocketOptionLevel.RAW, SocketOption.TYPE, 3 );
return socket;
}
void main() {
ubyte[1500] socket_buffer;
writeln("init socket.");
auto sock = init_sock();
sock.receiveFrom( socket_buffer );
writeln(socket_buffer);
}
But for the moment i think it's really impossible to capture ethernet frames with D.
Or can someone explain where my "error in head" is?
Capture ip packets or tcp / udp segments, thats all easy and i already did, but it is not what i need.
I need the whole Ethernet Frame.
Best regards
Erich Zann