[ Team LiB ] Previous Section Next Section

Exercises

17.1

In Section 17.7, we said that the broadcast address returned by the SIOCGIFBRDADDR request is returned in the ifr_broadaddr member. But on p. 173 of TCPv2, notice that it is returned in the ifr_dstaddr member. Does this matter?

17.2

Modify the get_ifi_info program to issue its first SIOCGIFCONF request for one ifreq structure and then increment the length each time around the loop by the size of one of these structures. Next, put some statements in the loop to print the buffer size each time the request is issued, whether or not ioctl returns an error, and upon success print the returned buffer length. Run the prifinfo program and see how your system handles this request when the buffer size is too small. Also print the address family for any returned structures whose address family is not the desired value to see what other structures are returned by your system.

17.3

Modify the get_ifi_info function to return information about an alias address if the additional address is on a different subnet from the previous address for this interface. That is, our version in Section 17.6 ignored the aliases 206.62.226.44 through 206.62.226.46, which is acceptable since they are on the same subnet as the primary address for the interface, 206.62.226.33. But if, in this example, an alias is on a different subnet, say 192.3.4.5, return an ifi_info structure with the information about the additional address.

17.4

If your system supports the SIOCGIFNUM ioctl, then modify Figure 17.7 to issue this request and use the return value as the initial buffer size guess.


    [ Team LiB ] Previous Section Next Section