local ip address

Home Forums Discussions Support Portal local ip address

This topic contains 1 reply, has 2 voices, and was last updated by  Vadim Smirnov 11 years, 11 months ago.

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

    dalgin
    Participant

    I am building on top of PassThru and it seems like I am parsing the ip header incorrectly. can anyone help?
    here is the code:
    if(ntohs(pEthHeader->h_proto) == ETH_P_IP){
    pIPHeader = (iphdr*)PacketBuffer.m_IBuffer+14;
    printf(“tInternet Protocol (IP) packetn”);
    printf(“Source:%u.%u.%u.%un”,pIPHeader->ip_src.S_un.S_un_b.s_b1,pIPHeader->ip_src.S_un.S_un_b.s_b2,
    pIPHeader->ip_src.S_un.S_un_b.s_b4,pIPHeader->ip_src.S_un.S_un_b.s_b4);
    printf(“Destin:%u.%u.%u.%un”,pIPHeader->ip_dst.S_un.S_un_b.s_b1,pIPHeader->ip_dst.S_un.S_un_b.s_b2,
    pIPHeader->ip_dst.S_un.S_un_b.s_b4,pIPHeader->ip_dst.S_un.S_un_b.s_b4);
    }

    When I generate traffic, neither source nor dest ip is my machines ip address. [/quote]

    #5866

    Vadim Smirnov
    Moderator

    pIPHeader = (iphdr*)PacketBuffer.m_IBuffer+14;

    Typecasting has a higher priority than operator + above. You have to change it to:

    pIPHeader = (iphdr*)PacketBuffer.m_IBuffer[14];

    or

    pIPHeader = (iphdr*)(PacketBuffer.m_IBuffer+14);

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

You must be logged in to reply to this topic.