I can't recall where now, but I had found that method on some page or project source code.

After some more research, it looks like there's a less hacky method available with sockaddr_ll.