Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.4.pdf
Скачиваний:
31
Добавлен:
23.08.2013
Размер:
2.79 Mб
Скачать

TCP/IP Porting

2.5Specifying IP addresses

Before you can test your stack, you must set up some basic IP addressing information. The ARM stack offers the latest protocols for setting up IP addresses, but it still requires additional information from both the porting programmer and the end user.

2.5.1Porting programmer IP issues

You must first assign a valid IP address to each interface. Fill in the n_ipaddr member of the net structure for each interface. (The net structure is discussed in detail in Network interfaces on page 4-15.) This should be done before or during the network interfaces n_init() call. You must also set the fields for n_defgw (default router) and snmask (subnet mask). These three values are collectively referred to as the IP addressing information.

The three IP addressing values are currently 32-bit numbers. However, the next generation of IP, IPv6, defines a larger field. These addresses should be stored and handled as strings.

Caution

You must assign these addresses as part of the port. If you do not do this, all your IP addressing fields will be 0, the IP startup code will print warnings and then fail. If you do not know what values to use, ask your network administrator or refer to Internetworking with TCP/IP, by Douglas E. Comer, on IP addressing.

If the IP address values are not correctly set, your stack may not work and you may even disable other users on the net.

Note

In little-endian systems, these addresses are stored in network byte order (big-endian format) rather than little-endian. Refer to the n_ipaddr setup code in \inet\macloop.c for a portable example that works on both big-endian and little-endian architectures.

2-14

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B

TCP/IP Porting

2.5.2End user IP issues

A product issue you will encounter is how the end user will assign the IP addresses. Traditionally, the end user was required to sit down at a console attached to the device, usually a serial terminal attached through an RS-232, and key in an IP address, subnet mask, default router, and possibly other information. The IP address information was stored in permanent storage (NVRAM or disk) and read each time the machine was booted.

Although it is still a good idea to support manual IP address assignment, more recent IP technology has developed several easier ways to do this, most notably DHCP. For a description of all DHCP client functions, see Chapter 7 DHCP Client Functions.

ARM DUI 0079B

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

2-15