API to fetch dhcpv6 information

I am trying to fetch DHCP server identifiers of the current network. For IPv4 I am able to get this information using SCDynamicStoreCopyDHCPInfo and then using DHCPInfoGetOptionData fetching option 54. I am trying to do the same thing for IPv6, in my scutil I do see DHCPv6 present. Is there any API present which fetches this information for v6 DHCP servers, or do I have to get this direct from scutil?

Answered by DTS Engineer in 805640022
Is there any API present which fetches this information for v6 DHCP servers, or do I have to get this direct from scutil?

Those are not your only two options!

SCDynamicStoreCopyDHCPInfo is a thin wrapper around the SC dynamic store API [1]. If the data you need is in the dynamic store, you don’t have to run scutil to get it. You can get arbitrary data from the dynamic store using its API.

I recommend that you read System Configuration Programming Guidelines, which has a good introduction to the SC architecture. With that in hand, you should be able to make progress with the API reference.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] If you want to see how thin that wrapper is, here’s the macOS 14-ish code in Darwin.

Is there any API present which fetches this information for v6 DHCP servers, or do I have to get this direct from scutil?

Those are not your only two options!

SCDynamicStoreCopyDHCPInfo is a thin wrapper around the SC dynamic store API [1]. If the data you need is in the dynamic store, you don’t have to run scutil to get it. You can get arbitrary data from the dynamic store using its API.

I recommend that you read System Configuration Programming Guidelines, which has a good introduction to the SC architecture. With that in hand, you should be able to make progress with the API reference.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] If you want to see how thin that wrapper is, here’s the macOS 14-ish code in Darwin.

What dynamic store does SCDynamicStoreCopyDHCPInfo uses to fetch the dat? DHCP and DHCPv6 are two different dynamic stores. Also on that note is it even possible to get DHCP v6 server IP address?

Thank you for providing this info. Researching more on DHCPv6, I saw that based on RFC-8415, we do not get v6 DHCP server IP addresses. Is there any way that we can get this information from either dynamic store or is there any Apple API that provides the said information?

Any help would be much appreciated.

What dynamic store does SCDynamicStoreCopyDHCPInfo uses to fetch the dat?

Say what?

There is only a single dynamic store on the system. I think you’re mixing up dynamic stores with properties in the dynamic store. For example, this shows you the entire dynamic store:

% scutil 
> list
  subKey [0] = Plugin:IPConfiguration
  subKey [1] = Plugin:InterfaceNamer
  subKey [2] = Plugin:KernelEventMonitor
  subKey [3] = Setup:
  …

While this shows you a specific property in it:

> show State:/Network/Service/490E7FA5-E884-4B44-A104-5F1FD7F9B1A1/DHCP
<dictionary> {
  LeaseExpirationTime : 09/26/2024 10:57:53
  LeaseStartTime : 09/26/2024 10:42:53
  Option_1 : <data> 0xfffffc00
  …
}

If you’re confused about this, I recommend that you go back to the SC architecture doc I referenced previously.

Is there any way that we can get this information from either dynamic store or is there any Apple API that provides the said information?

Honestly, I’m not up to speed on DHCPv6. I started this thread on the assumption that the info you were looking for was available via scutil. If that’s the case, it’s also available via the dynamic store API. You just need to know the key.

When you look in scutil, do you see the info you want?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for providing this info. Yes it seems I typed it wrong, I meant properties. I checked the DHCPv6 property, and it turns out it indeed does not have IP of DHCP server. Is there any Apple API which provides said information?

Any help would be much appreciated.

API to fetch dhcpv6 information
 
 
Q