Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ICMP Issue

ICMP Issue

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomtoolshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    no_reg_name
    wrote on last edited by
    #1

    I'm adding IPv6 functionality to an application that has been designed to monitor the hosts by sending periodical ICMP packets (pings). According to MSDN and the checkv4 utility, the addrinfo structure should be used, which works well when calling Icmp6SendEcho2[^] , however the problems arise when calling the IcmpSendEcho2 [^], because the fifth argument, the DestinationAddress is IPAddr struct type. So the real question is: Are there any fuctions that will convert an addrinfo structure to an IPAddr or is there another way of doing this? (Using a bunch of if/else statements to check for IPv4/6 is not an option)

    A 1 Reply Last reply
    0
    • N no_reg_name

      I'm adding IPv6 functionality to an application that has been designed to monitor the hosts by sending periodical ICMP packets (pings). According to MSDN and the checkv4 utility, the addrinfo structure should be used, which works well when calling Icmp6SendEcho2[^] , however the problems arise when calling the IcmpSendEcho2 [^], because the fifth argument, the DestinationAddress is IPAddr struct type. So the real question is: Are there any fuctions that will convert an addrinfo structure to an IPAddr or is there another way of doing this? (Using a bunch of if/else statements to check for IPv4/6 is not an option)

      A Offline
      A Offline
      Alexander M
      wrote on last edited by
      #2

      Declare a new address type like this:

      typedef struct _SOCKADDR_IPv4v6
      {
      union
      {
      sockaddr_in addrv4;
      sockaddr_in6 addrv6;
      };

      } SOCKADDR_IPv4v6, *PSOCKADDR_IPv4v6;

      SOCKADDR_IPv4v6 addr;

      Icmp6SendEcho2( ..., &addr.addrv6, ... ); // if addr is IPv6
      IcmpSendEcho2( ..., addr.addrv4.sin_addr, ... ); // if addr is IPv4

      Don't try it, just do it! ;-)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups