Embedded Systems September 2000 Vol13_10

Issue link:

Contents of this Issue


Page 101 of 229

Encapsulating an 1Pv6 packet inside an 1Pv4 packet 1Pv4 Payload 1Pv4 Header ' some new IPv6 data structures, which are described in the next section. Note that this applies o nly if you are using a sockets API, which may not be the case in an embedded system. Similarly, the applicati on code changes I'm about to describe will only make sense if you ' re using a sock- ets o r sockets-like networking API. If you are using such an API, you may be able to take advan tage of a "socket scrubber" developed at Su n ( www. sun.corn/ software/ solaris/ ipv6). Address data structures A protocol-specific data structure is defined fo r each protocol that the socket functions support. You normal- ly cast the protocol-specific data struc- ture to sockaddr when calling the core socket functions. For example, in IPv4, the protocol-specific data structure is sockaddr _; n which you cast to sockad- dr when calling connectO. The proto- col-specific data structure for IPv6 is sockaddr _; n6. IPv6 also has a new address family, AF_INET6, a new protocol family, PF _INET6, and a new structure fo r hold ing a single IPv6 address, in6_addr. These are used in a way that is similar to IPv4's AF_INET, PF_INET, and i fl.._addr. TEL: (617) 661 -1510 FAX: (617) 876-2972 Name-to-address translation functions The most common function for trans- lating names to addresses in IPv4 is gethostbynameO. It's sti ll retained for backwards compatibility, but is inade- quate fo r IPv6. A common complaint has been that gethostbynameO is not thread-safe, but a bigger problem is that there's no way to specify anything about the types of addresses desired (IPv4, IPv6, and so on ). Ado pted from POSIX l003.lg, getaddrinfoO solves these problems. There's also a function to perform Phar Lap Software, Inc. 60 Aberdeen Ave. Cambridge, MA 02138 © 2000 Phar lap Software and TNT Embedded ToolSulte are registered trademarks of Phar Lap Software, Inc. Win32 is a registered trademark of Microsoft Corporation the reverse. Given a node name, get- nameinfoO looks up an IP address. Address conversion functions Typically, the functions i net_addrO and inet_ntoaO are used to convert 100 SEPTEMBER 2000 Embedded Systems Programming

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10