pcap lookupnet

0

Czy ktoś może mi powiedzieć czemu wartość net_wan jest podmieniania na wartość net_local?

     
    char errbuf[PCAP_ERRBUF_SIZE];
    pcap_t* descr;
    struct bpf_program fp;      /* hold compiled program     */
    bpf_u_int32 maskp;          /* subnet mask               */
    bpf_u_int32 netp;           /* ip                        */
    bpf_u_int32 maskp_lan;          /* subnet mask               */
    bpf_u_int32 netp_lan;           /* ip                        */
    u_char* args = NULL;
    struct in_addr addr, addr_local;
    char *net_wan, *net_local;

  pcap_lookupnet(wan_card,&netp,&maskp,errbuf); //WAN card - eth0
  addr.s_addr = netp;
  net_wan = inet_ntoa(addr);

fprintf(stdout,"\n%s\n",net_wan);

  pcap_lookupnet(local_card,&netp_lan,&maskp_lan,errbuf); //LAN card - eth1
  addr_local.s_addr = netp_lan;
  net_local = inet_ntoa(addr_local);

fprintf(stdout,"\n%s\n",net_wan);

Pierwszy print daje wynik 192.168.0.0, drugi daje wynik 192.168.138.0.

0

Linux Manual:

   The inet_ntoa() function converts the Internet host  address  in,  given  in
   network byte order, to a string in IPv4 dotted-decimal notation.  **The string**
   **is returned in a statically allocated buffer, which  subsequent  calls  will**
   **overwrite.**

1 użytkowników online, w tym zalogowanych: 0, gości: 1