O'Reilly logo

iOS and OS X Network Programming Cookbook by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving local addresses with libnet

Within the libnet library, there are a number of instances where you will need the local addresses (hardware and/or IP addresses). If we were sending a packet, we will need to know the hardware address of the device at the Link layer. For the IP headers, we need to know the IP addresses (either IPv4 or IPv6) so that we can put it in the Source Address field.

In this recipe, we will show how to retrieve and display the hardware, IPv4, and IPv6 addresses using libnet.

Getting ready

Prior to running the examples in the chapter, we will need to download and install libnet (see the Installing libnet recipe of this chapter). You will also need to add libnet to your project (see the Adding libnet to your project recipe ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required