0

I am displaying all connected Ip addresses in a drop down and I need to check whether the particular port is free in particular Ip(both Ipv4 and Ipv6).Ip will be selected from dropdown, How can I check whether the selected Ip is Ipv4 or Ipv6 and then how can i check free port availability in ipv6 Ip case

user1234
  • 289
  • 6
  • 13
  • 1
    What makes you sure that if it's free at install time it'll be free by the next reboot? (Or any other arbitrary point in the future) – Flexo Mar 14 '12 at 17:34
  • What I would like to know is **1.** Is there any windows api (can be used in .nsi file) which tells the passed Ip is Ipv4 or Ipv6. **2.** In Ipv4 we use inet_addr to convert string addr to network address, Is there any other windows api which will do this same for Ipv6 Ip? – user1234 Mar 15 '12 at 04:55

1 Answers1

0

Why do you keep asking basically the same question over and over? The answer is always the same: There are no existing NSIS plugins that can do this AFAIK so your options are:

  • Write a new plugin
  • Call the native windows api with the system plugin
  • Use nsExec to execute a external tool like netstat
Community
  • 1
  • 1
Anders
  • 97,548
  • 12
  • 110
  • 164
  • this question is to know abt how to differentiate selected ip address is ipv6 or ipv4? – user1234 Mar 15 '12 at 04:48
  • I am sorry If the way of asking all my questions seems the same to u. I tried to give the whole same contect in all my question. I will correct this going forward – user1234 Mar 15 '12 at 04:57
  • If all you want to do is check if an address is IPv6, you have many functions to choose from: WSAStringToAddress, inet_pton, getaddrinfo or RtlIpv6StringToAddress. Trying to listen on a port would require changes to the sample code I wrote for you in another answer... – Anders Mar 15 '12 at 17:14
  • Hi,
    `code` System::Call 'Ws2_32::inet_pton(ir6,tr4,ir5)i.r0?e' ;r6->af_family(23),r4->ip as string,r5 must be the output structure.
    pop $7 ; inet_pton return value- this is 1 as success
    System::Call '*$2(&i4 ${AF_INET6},&i4 r3,&i8 0,&i16 r5,&i16 0)' ; sockaddr6 structure needed for bind function
    System::Call 'Ws2_32::bind(ir1,ir2,i16)i.r0?e'
    `code` Above bind function returns 10014 Bad address
    could you please help what has gone wrong in the above structure defnition.
    – user1234 Apr 12 '12 at 05:56
  • sockaddr_in6 is probably closer to something like (&i2,&i2,&i4,&i16,&i4). To use the system plugin you really need know C and have the SDK installed... – Anders Apr 12 '12 at 09:17