Help! I can not read Ethernet headers.

Home Forums Discussions General Discussion Help! I can not read Ethernet headers.

This topic contains 1 reply, has 2 voices, and was last updated by  Taras 13 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4902

    atruhinov
    Participant

    I can not read Ethernet headers.

    ***************************************************

    type
    ETHERNET_HDR = packed record
    Destination: TEtherAddr;
    Source: TEtherAddr;
    Protocol: word;
    Data: array[0..0] of UCHAR;
    end;
    PETHERNET_HDR = ^ETHERNET_HDR;
    .
    .
    .

    const
    MAX_CHAR = 1024 * 5;

    var
    buf: Array[0..MAX_CHAR] Of char;
    iRet: Integer;
    EthernetHdr: PETHERNET_HDR;
    RawSocket: TSocket;

    begin
    iRet:=recv(RawSocket,buf,sizeof(buf),0);

    EthernetHdr:=PETHERNET_HDR(@buf);

    but from buf I read only IP, UDP, TCP


    IP – UDP


    4500 00CA DC6D 0000 8011 DB63 C0A8 0002 C0A8 00FF 008A 008A
    00B6 03CA 1102 8384 C0A8 0002 008A 00A0 0000 2045 4945 5045
    4E45 4643 4143 ….
    …………….

    Help!

    #5691

    Taras
    Participant

    You can not read ethernet header form raw socket. Never. You should use one of kernel traffic capture method. Foe example, winpcap, NDIS IM and so on.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.