public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
       [not found]   ` <a0f1e420-ae48-49a3-9300-c56f1948ad9b.e52b7f5f-5a09-4346-99f8-a6591191169c.56a70ab3-2a48-435e-a1d6-57e7829aa764@emailsignatures365.codetwo.com>
@ 2023-09-27 16:40     ` Mainz, Roland
  2023-09-27 17:02       ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  0 siblings, 1 reply; 7+ messages in thread
From: Mainz, Roland @ 2023-09-27 16:40 UTC (permalink / raw)
  To: cygwin


Hi!

----

Does Cygwin (or Win32) have a function to convert "raw" ASCII IPv6 addresses into *.ipv6-literal.net per https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_UNC_path_names ?

Example:
[fe80::219:99ff:feae:73ce]
should be turned into
fe80--219-99ff-feae-73ce.ipv6-literal.net

----

Bye,
Roland


i. A. Roland Mainz
Entwickler Steuerungssoftware
TEE

ROVEMA GmbH

Industriestr. 1, 35463
Fernwald, Germany
 T  +49 641 409 528
 @ Roland.Mainz@rovema.de
 
www.rovema.com


Rovema
It's about your products.
https://www.rovema-experience.com/


ROVEMA GmbH
Industriestrasse 1, 35463 Fernwald, Germany
Geschäftsführer:
Christoph Gusenleitner
Dr. Dirk Panhans
Handelsregister-Eintrag/Commercial Register: Amtsgericht Gießen, HRB 8551
USt.-Ident./VAT ID No.: DE 301 430 123



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-27 16:40     ` Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ? Mainz, Roland
@ 2023-09-27 17:02       ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  2023-09-27 22:35         ` Brian Inglis
  0 siblings, 1 reply; 7+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] @ 2023-09-27 17:02 UTC (permalink / raw)
  To: Mainz, Roland, cygwin

> Does Cygwin (or Win32) have a function to convert "raw" ASCII IPv6 addresses into *.ipv6-
> literal.net per

If Windows API is documented to have such a function, you should be able find it in the w32api package in Cygwin.

As for the "literal" representation, the only "standard" and documented IPv6 DNS notation is in the
.ip6.arpa domain (the analog for IPv4's "in-addr.arpa").  Microsoft seems to have uniquely "enhanced" that
convention to use a more compact notation...  Even though it says it resolves internally without DNS on Windows,
this convention is not likely portable (and will cause an actual DNS hit on other platforms that do not specially
recognize ".ipv6-literal.net" -- unlike the treatment of ".ip6.arpa").  And a likely result of that is going
to be "NXDOMAIN" (domain does not exist).

HTH,

Anton Lavrentiev
Contractor NIH/NLM/NCBI

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-27 17:02       ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
@ 2023-09-27 22:35         ` Brian Inglis
  2023-09-27 23:56           ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Inglis @ 2023-09-27 22:35 UTC (permalink / raw)
  To: cygwin

On 2023-09-27 11:02, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
>> Does Cygwin (or Win32) have a function to convert "raw" ASCII IPv6 addresses into *.ipv6-
>> literal.net per

Not hard to change ":" to "-" and append .ipv6-literal.net - in bash:

	${addrv6//:/-}.ipv6-literal.net

	$ getent ahosts -- --1.ipv6-literal.net
	::1             STREAM ::1
	::1             DGRAM  ::1

> If Windows API is documented to have such a function, you should be able find
> it in the w32api package in Cygwin.
> As for the "literal" representation, the only "standard" and documented IPv6 
> DNS notation is in the .ip6.arpa domain (the analog for IPv4's 
> "in-addr.arpa").
> Microsoft seems to have uniquely "enhanced" that convention to use a more
> compact notation... > Even though it says it resolves internally without DNS on Windows, this
> convention is not likely portable (and will cause an actual DNS hit on other
> platforms that do not specially recognize ".ipv6-literal.net" -- unlike the
> treatment of ".ip6.arpa").
> And a likely result of that is going to be "NXDOMAIN" (domain does not
> exist).
Just have to unstuff any "::" to enough ":0000...:" to make 8 groups, fill to 4 
hex digits each, strip the ":"s then reverse the (hex) digits or vice versa, add 
"."s after each, and add ip6.arpa e.g.

::1 ->
0000:0000:0000:0000:0000:0000:0000:0001 -> 
1000:0000:0000:0000:0000:0000:0000:0000 ->
10000000000000000000000000000000 ->
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

$ host -t ptr \
	1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa domain 
name pointer localhost.

but there may be few PTR records set up or recognized for IP V6 addresses.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXTERNAL] Re: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-27 22:35         ` Brian Inglis
@ 2023-09-27 23:56           ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  2023-09-28 17:48             ` Brian Inglis
  0 siblings, 1 reply; 7+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] @ 2023-09-27 23:56 UTC (permalink / raw)
  To: cygwin; +Cc: Brian Inglis

> $ host -t ptr

I was talking about resolving the .ipv6-literal.net names via DNS.

Such as "fe80--219-99ff-feae-73ce.ipv6-literal.net"

Anton Lavrentiev
Contractor NIH/NLM/NCBI


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [EXTERNAL] Re: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-27 23:56           ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
@ 2023-09-28 17:48             ` Brian Inglis
  2023-09-28 17:56               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Inglis @ 2023-09-28 17:48 UTC (permalink / raw)
  To: cygwin

On 2023-09-27 17:56, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
>> $ host -t ptr \
>>	1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
>> 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa domain name pointer localhost.

> I was talking about resolving the .ipv6-literal.net names via DNS.
> Such as "fe80--219-99ff-feae-73ce.ipv6-literal.net"

What do you think that output is - the PTR is resolved to "localhost."

I find *host* easier to use, script, and more tersely informative than the other 
bind DNS utilities: the bind-utils Cygwin package contains DNS utilities:

	delv
	dig
	host
	mdig
	named-rrchecker
	nslookup
	nsupdate

and the lookups support most of the same arguments and options, with different 
names and defaults: host defaults to -t A -t AAAA -t MX, but host and nslookup 
only accept a single type, while dig accepts -t ANY; delv and mdig will do deep 
dives for DNSSEC and DNS; while named-rrchecker validates DNS RR inputs.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXTERNAL] Re: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-28 17:48             ` Brian Inglis
@ 2023-09-28 17:56               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
  2023-09-28 18:53                 ` Jeffrey Altman
  0 siblings, 1 reply; 7+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] @ 2023-09-28 17:56 UTC (permalink / raw)
  To: cygwin; +Cc: Brian Inglis

> What do you think that output is - the PTR is resolved to "localhost."

You obviously did not get the point that I was making.  Using ip6.arpa *is* the standard
way to get around with "DNS-like" IPv6 addresses, as it would be "understood".  Using
the "ipv6-literal.net" domain is not portable and would result in NXDOMAIN anywhere
but Windows (where the resolver seems to intercept and convert them internally).

Anton Lavrentiev
Contractor NIH/NLM/NCBI


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ?
  2023-09-28 17:56               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
@ 2023-09-28 18:53                 ` Jeffrey Altman
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey Altman @ 2023-09-28 18:53 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2165 bytes --]

On 9/28/2023 1:56 PM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
>> What do you think that output is - the PTR is resolved to "localhost."
> You obviously did not get the point that I was making.  Using ip6.arpa *is* the standard
> way to get around with "DNS-like" IPv6 addresses, as it would be "understood".  Using
> the "ipv6-literal.net" domain is not portable and would result in NXDOMAIN anywhere
> but Windows (where the resolver seems to intercept and convert them internally).

The ip6.arpa names are used to lookup PTR records which contain hostnames.

The ipv6-literal.net names are used to simulate AAAA records and map the 
name to an IPv6 address (with an optional address scope).

For those that are unaware of the history[1][2][3], UNC names support 
the use of IPv4 addresses as an alternative to SMB server names or DNS 
host names. End users expect to be able to specify a UNC path such as \\2001:db8:85a3:8d3:1319:8a2e:370:7348\share

or

   \\[2001:db8:85a3:8d3:1319:8a2e:370:7348]\share

However, colons are illegal in UNC paths and therefore standard IPv6 
representations cannot be used. The <encoded-ipv6-addr>.ipv6-literal.net 
server name is a method of representing an IPv6 address as a UNC server 
name such that it can be locally translated by getaddrinfo() into an 
IPv6 address without querying DNS. \\2001-db8-85a3-8d3-1319-8a2e-370-7348.ipv6-literal.net\share

If the ipv6.arpa representation\\8.4.3.7.0.7.3.0.e.2.a.8.9.1.3.1.3.d.8.0.3.a.5.8.8.b.d.0.1.0.0.2.ip6.arpa\path

was used as a server name and treated as a DNS AAAA lookup that would be harder for
humans to construct and no more portable.   The ip6.arpa representation would also
be unable to represent IPv6 address scopes which are supported by ipv6-literal.net
names.

I am unaware of any Microsoft Windows APIs that can be called to translate from
an IPv6 address to an ipv6-literal.net string.

[1] 
https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_UNC_path_names 
[2] https://devblogs.microsoft.com/oldnewthing/20100915-00/?p=12863 [3] 
https://learn.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetaddconnection3a 



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4085 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-28 18:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <a0f1e420-ae48-49a3-9300-c56f1948ad9b.8d485f54-9f47-42b0-bdcb-9635fbf663c3.1953b09c-03d1-4289-80f4-778eacaeb398@emailsignatures365.codetwo.com>
     [not found] ` <a0f1e420-ae48-49a3-9300-c56f1948ad9b.93e247b8-206a-49dd-b71c-9240681180cb.af28cea3-9945-4ab0-bb94-5ee9947bdc30@emailsignatures365.codetwo.com>
     [not found]   ` <a0f1e420-ae48-49a3-9300-c56f1948ad9b.e52b7f5f-5a09-4346-99f8-a6591191169c.56a70ab3-2a48-435e-a1d6-57e7829aa764@emailsignatures365.codetwo.com>
2023-09-27 16:40     ` Cygwin/Win32 utility function to convert "raw" IPv6 address string into *.ipv6-literal.net string ? Mainz, Roland
2023-09-27 17:02       ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-09-27 22:35         ` Brian Inglis
2023-09-27 23:56           ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-09-28 17:48             ` Brian Inglis
2023-09-28 17:56               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-09-28 18:53                 ` Jeffrey Altman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).