diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2013-04-22 23:25:31 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2013-04-22 23:25:31 +0400 |
commit | 22ecfca77f927d753669e3a1d8247b7b8b790cdc (patch) | |
tree | 6ff450d43bd620f18153e60a1a320ccf2d5849a2 /accel-pppd/ctrl/ipoe/dhcpv4.c | |
parent | 37c752f496b8db30bb56d39b4b5525487790088e (diff) | |
download | accel-ppp-22ecfca77f927d753669e3a1d8247b7b8b790cdc.tar.gz accel-ppp-22ecfca77f927d753669e3a1d8247b7b8b790cdc.zip |
ipoe: add relay port to config (relay=addr[:port])
Diffstat (limited to 'accel-pppd/ctrl/ipoe/dhcpv4.c')
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 5885ac4..4f27a47 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -792,8 +792,10 @@ out_err: struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, const char *_giaddr, struct triton_context_t *ctx, triton_event_func recv) { + char str[17], *ptr; struct dhcpv4_relay *r; - in_addr_t addr = inet_addr(_addr); + in_addr_t addr;// = inet_addr(_addr); + int port = DHCP_SERV_PORT; in_addr_t giaddr = inet_addr(_giaddr); struct sockaddr_in raddr; struct sockaddr_in laddr; @@ -801,6 +803,15 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, const char *_giaddr, int f = 1; struct dhcpv4_relay_ctx *c; + ptr = strchr(_addr, ':'); + if (ptr) { + memcpy(str, _addr, ptr - _addr); + str[ptr - _addr] = 0; + addr = inet_addr(str); + port = atoi(ptr + 1); + } else + addr = inet_addr(_addr); + list_for_each_entry(r, &relay_list, entry) { if (r->addr == addr && r->giaddr == giaddr) goto found; @@ -815,7 +826,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, const char *_giaddr, memset(&raddr, 0, sizeof(raddr)); raddr.sin_family = AF_INET; raddr.sin_addr.s_addr = addr; - raddr.sin_port = htons(DHCP_SERV_PORT); + raddr.sin_port = htons(port); memset(&laddr, 0, sizeof(laddr)); laddr.sin_family = AF_INET; |