[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [patch #6683] Customizable AUTOIP "seed" address
From: |
Luca Ceresoli |
Subject: |
[lwip-devel] [patch #6683] Customizable AUTOIP "seed" address |
Date: |
Tue, 09 Dec 2008 13:57:50 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4 |
Follow-up Comment #4, patch #6683 (project lwip):
You are 100% right.
I sketched out a tentative improvement:
// 169.254.0.0
#define AUTOIP_NET 0xA9FE0000
...
static void
autoip_create_addr(struct netif *netif, struct ip_addr *IPAddr)
{
/* Here we create an IP-Address out of range 169.254.1.0 to
169.254.254.255
* compliant to RFC 3927 Section 2.1
* We have 254 * 256 possibilities
*/
u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif));
addr += netif->autoip->tried_llipaddr;
addr = AUTOIP_NET | (addr & 0xffff);
/* Now, 169.254.0.0 <= addr <= 169.254.255.255 */
if (addr < AUTOIP_RANGE_START) {
addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
}
if (addr > AUTOIP_RANGE_END) {
addr -= AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
}
IPAddr->addr = htonl(addr);
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
("autoip_create_addr(): tried_llipaddr=%"U16_F", 0x%08"X32_F"n",
(u16_t)(netif->autoip->tried_llipaddr), (u32_t)(IPAddr->addr)));
}
Pros:
* The seed is a complete IP address (in ip_addr byte order).
* It is safe (no risk to go out of range).
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/patch/?6683>
_______________________________________________
Messaggio inviato con/da Savannah
http://savannah.nongnu.org/