Parsing the result of SIOCGIFCONF

Does anyone know the mojo to parse the result of a SIOCGIFCONF ioctl on a socket? Specifically, I’m trying to do this on a 6.3 system using the “fully featured” TCP/IP stack.

I get what appears to be good data back and I can sort of manually parse through it and find what appear to be appropriate values (e.g., the controller name string, the IP address, the flags), but I can’t figure out the convention for determining where one controller’s info ends and the next one begins. I’ve tried using the sizeof the ifreq struct (and augmenting that with seemingly arbitrary increments hinted at in some free versions of ipconfig) but that doesn’t seem to work. Is there a length field embedded in each element that I’m overlooking?