[OpenWrt-Devel] [PATCH 2/2]odhpc6c: status code support in reply

2013-10-23 Thread Hans Dedecker
The patch implements support for status code handling in
reply messages as described in RFC3313 paragraph 18.1.8.
The client will
*log the status codes returned by the client
*send a request if no binding status code is returned for 
a given IA
*send further renew/rebind if the IA was not present in
the reply
*terminate message exchange when no prefix/no address
status code is returned in reponse to a request
*terminate message exchange when unspec fail status code
is returned
*calculate t1/t2/t3 when all IA's have been processed and
based on recorded t1/t2/valid timer values per IA

Without this patch I have seen issues with request messages
send without any IA_PD/IA_NA and t1/t2/t3 timer values which
were not correct. These changes have been tested intensive
against an ISC DHCPv6 server

Signed-off-by: Hans Dedecker hans.dedec...@gmail.com
---
 src/dhcpv6.c  |  276 +++---
 src/odhcp6c.c |   34 +--
 src/odhcp6c.h |9 +
 src/ra.c  |2 
 4 files changed, 258 insertions(+), 63 deletions(-)

--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -46,7 +46,17 @@
 static bool dhcpv6_response_is_valid(const void *buf, ssize_t len,
const uint8_t transaction[3], enum dhcpv6_msg type);
 
-static uint32_t dhcpv6_parse_ia(void *opt, void *end);
+static int dhcpv6_parse_ia(void *opt, void *end);
+
+static int dhcpv6_calc_refresh_timers(void);
+static void dhcpv6_handle_status_code(_unused const enum dhcpv6_msg orig,
+   const uint16_t code, const void *status_msg, const int len,
+   int *ret);
+static void dhcpv6_handle_ia_status_code(const enum dhcpv6_msg orig,
+   const struct dhcpv6_ia_hdr *ia_hdr, const uint16_t code,
+   const void *status_msg, const int len,
+   bool handled_status_codes[_DHCPV6_Status_Max],
+   int *ret);
 
 static reply_handler dhcpv6_handle_reply;
 static reply_handler dhcpv6_handle_advert;
@@ -588,7 +598,7 @@ static int dhcpv6_handle_advert(enum dhc
(otype == DHCPV6_OPT_IA_PD || otype == 
DHCPV6_OPT_IA_NA) 
olen  sizeof(struct dhcpv6_ia_hdr)) {
struct dhcpv6_ia_hdr *ia_hdr = (void*)(odata[-4]);
-   dhcpv6_parse_ia(ia_hdr[1], odata + olen);
+   dhcpv6_parse_ia(ia_hdr, odata + olen + sizeof(*ia_hdr));
}
 
if (otype == DHCPV6_OPT_SERVERID  olen = 130) {
@@ -735,6 +745,9 @@ static int dhcpv6_handle_reply(enum dhcp
 {
uint8_t *odata;
uint16_t otype, olen;
+   uint32_t refresh = UINT32_MAX;
+   int ret = 1;
+   bool handled_status_codes[_DHCPV6_Status_Max] = { false, };
 
odhcp6c_expire();
 
@@ -757,11 +770,9 @@ static int dhcpv6_handle_reply(enum dhcp
 
if (t3  0)
t3 = 0;
-   } else {
-   t1 = t2 = t3 = UINT32_MAX;
}
 
-   if (orig == DHCPV6_MSG_REQUEST) {
+   if (orig == DHCPV6_MSG_REQUEST  !odhcp6c_is_bound()) {
// Delete NA and PD we have in the state from the Advert
odhcp6c_clear_state(STATE_IA_NA);
odhcp6c_clear_state(STATE_IA_PD);
@@ -782,48 +793,48 @@ static int dhcpv6_handle_reply(enum dhcp
if ((otype == DHCPV6_OPT_IA_PD || otype == DHCPV6_OPT_IA_NA)
 olen  sizeof(struct dhcpv6_ia_hdr)) {
struct dhcpv6_ia_hdr *ia_hdr = (void*)(odata[-4]);
-   uint32_t l_t1 = ntohl(ia_hdr-t1);
-   uint32_t l_t2 = ntohl(ia_hdr-t2);
 
-   // Test ID and T1-T2 validity
-   if (ia_hdr-iaid != 1 || l_t2  l_t1)
+   // Test ID
+   if (ia_hdr-iaid != 1)
continue;
 
-   int error = 0;
+   uint16_t code = DHCPV6_Success;
uint16_t stype, slen;
uint8_t *sdata;
-   // Test status and bail if error
+   // Get and handle status code
dhcpv6_for_each_option(ia_hdr[1], odata + olen,
-   stype, slen, sdata)
-   if (stype == DHCPV6_OPT_STATUS  slen = 2)
-   error = ((int)sdata[0])  8 | 
((int)sdata[1]);
+   stype, slen, sdata) {
+   if (stype == DHCPV6_OPT_STATUS  slen = 2) {
+   uint8_t *mdata = (slen  2) ? sdata[2] 
: NULL;
+   uint16_t mlen = (slen  2) ? slen - 2 : 
0;
 
-   if (error) {
-   syslog(LOG_WARNING, Server returned IAID 
status %i!, error);
-   if (error != 2)
-

[OpenWrt-Devel] [PATCH 1/2]odhcp6c: preference and status code support in advertise

2013-10-23 Thread Hans Dedecker
The patch implements handling of advertise messages
as described in RFC3315 paragraph 17.1.2. Client will
stop collecting advertise messages if preference option
is equal to 255 or if the first RT has elapsed. Status
codes are handled in the advertise message depending on
the startup parameters

Signed-off-by: Hans Dedecker hans.dedec...@gmail.com
---
 src/dhcpv6.c |   39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -574,11 +574,11 @@ static int dhcpv6_handle_reconfigure(_un
 
 
 // Collect all advertised servers
-static int dhcpv6_handle_advert(enum dhcpv6_msg orig, _unused const int rc,
+static int dhcpv6_handle_advert(enum dhcpv6_msg orig, const int rc,
const void *opt, const void *end)
 {
uint16_t olen, otype;
-   uint8_t *odata;
+   uint8_t *odata, pref = 0;
struct dhcpv6_server_cand cand = {false, false, 0, 0, {0}, NULL, NULL, 
0, 0};
bool have_na = false;
int have_pd = 0;
@@ -594,12 +594,29 @@ static int dhcpv6_handle_advert(enum dhc
if (otype == DHCPV6_OPT_SERVERID  olen = 130) {
memcpy(cand.duid, odata, olen);
cand.duid_len = olen;
-   } else if (otype == DHCPV6_OPT_STATUS  olen = 2  !odata[0]
-odata[1] == DHCPV6_NoPrefixAvail) {
-   cand.preference -= 2000;
+   } else if (otype == DHCPV6_OPT_STATUS  olen = 2) {
+   int error = ((int)odata[0]  8 | (int)odata[1]);
+
+   switch (error) {
+   case DHCPV6_NoPrefixAvail:
+   // Status code on global level
+   if (pd_mode == IA_MODE_FORCE)
+   return -1;
+   cand.preference -= 2000;
+   break;
+
+   case DHCPV6_NoAddrsAvail:
+   // Status code on global level
+   if (na_mode == IA_MODE_FORCE)
+   return -1;
+   break;
+
+   default :
+   break;
+   }
} else if (otype == DHCPV6_OPT_PREF  olen = 1 
cand.preference = 0) {
-   cand.preference = odata[0];
+   cand.preference = pref = odata[0];
} else if (otype == DHCPV6_OPT_RECONF_ACCEPT) {
cand.wants_reconfigure = true;
} else if (otype == DHCPV6_OPT_IA_PD  request_prefix) {
@@ -648,7 +665,7 @@ static int dhcpv6_handle_advert(enum dhc
odhcp6c_clear_state(STATE_IA_PD);
}
 
-   return -1;
+   return (rc  1 || (pref == 255  cand.preference  0)) ? 1 : -1;
 }
 
 
@@ -679,8 +696,10 @@ static int dhcpv6_commit_advert(void)
odhcp6c_add_state(STATE_SERVER_ID, hdr, sizeof(hdr));
odhcp6c_add_state(STATE_SERVER_ID, c-duid, c-duid_len);
accept_reconfig = c-wants_reconfigure;
-   odhcp6c_add_state(STATE_IA_NA, c-ia_na, c-ia_na_len);
-   odhcp6c_add_state(STATE_IA_PD, c-ia_pd, c-ia_pd_len);
+   if (c-ia_na_len)
+   odhcp6c_add_state(STATE_IA_NA, c-ia_na, c-ia_na_len);
+   if (c-ia_pd_len)
+   odhcp6c_add_state(STATE_IA_PD, c-ia_pd, c-ia_pd_len);
}
 
for (size_t i = 0; i  cand_len / sizeof(*c); ++i) {
@@ -691,7 +710,7 @@ static int dhcpv6_commit_advert(void)
 
if (!c)
return -1;
-   else if (request_prefix || na_mode != IA_MODE_NONE)
+   else if ((request_prefix  c-ia_pd_len) || (na_mode != IA_MODE_NONE 
 c-ia_na_len))
return DHCPV6_STATEFUL;
else
return DHCPV6_STATELESS;
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] WD MyNet N750: ar9344 + ar8327 switch, unclear on phy/mdio/mac wiring

2013-10-23 Thread Jacek Kikiewicz

Hi,

There is a topic in openwrt forum: 
https://forum.openwrt.org/viewtopic.php?id=46864 about porting to this 
router.

Would you mind to update it a bit with your progress, please?
It would be easier to track for interested parties.

Thanks!
On 22.10.2013 18:04, Jay Carlson wrote:

Since Newegg has dropped the price on the 3T3R Western Digital N750 Atheros 
wasp/S17 entry to $30, I expect some more interest in this standard-looking  
ar9344 + ar8327 platform. I've got a couple of n750s lying around, but I 
haven't made any progress on getting the gigabit switch connected up to the 
on-chip Ethernet.

There's GPL source code for these Project Seattle platforms, and N600 support 
is in trunk. This helps, but the N600 uses the ar934x internal switch which is rather 
different from the gigabit NAT switch in these. There's GPL source for the N600 and N750 
from WD, and it's in fairly good shape, but unfortunately the switch configuration is 
performed in scripts and/or a binary ag71xx driver.

I think I should be able to imitate other ar934x+ar8327 devices, but I think 
I'm missing some concept, or I need to read some device state out of a stock 
device in order to replicate it. In the bootloader the ar8327 switch works, but 
I don't have bootloader source, and one of the last things the bootloader seems 
to do before boot is shut down the switch. (Perhaps this is to keep Linux from 
seeing anything from the net until the firewall is up.) And the interaction of 
MACs, PHYs and mdio buses makes my head hurt.

One thing I do see is a bunch of phy_id garbage on mdio0:10-17 and six phy_ids 
of the ar8327 on mdio1:00-05. My *guess* is that ag71xx.0 is connected directly 
to port 0 of the ar8327 like the other wasp/s17 devices, but mdio1 is used 
instead of mdio0. I've made it as far as ag71xx.0 coming up in multi mode, but 
I seem to get the generic PHY instead of ar8327 despite the phy_ids matching up 
(and with what I think is a correct boardinfo.)

(Also, something seems messed up with the openwrt firstboot squashfs split 
code: on the next reboot, the bootloader looks at the seama partition info and 
declares the kernel to not only be corrupt, but to have a non-ASCII md5sum. 
That kind of thing I feel competent to solve but there is little point if I 
can't get the wired ethernet up.)

Does the switch setup problem sound familiar? I can back out all my printk 
garbage and post my (clueless) board setup code if it would help. I can mail a 
box to somebody who's worked with ar934x, although I've never mailed hardware 
outside this country (US) except for work.

Jay Carlson
n...@nop.com
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] OpenWRT on Ubicom Chipsets

2013-10-23 Thread valent.turko...@gmail.com
I'll be aquiring few DIR-657 devices, so if you need testers I'm your man!
I also have a friend with flash programmer so if anything we can do to help
just let us know.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] OpenWRT on Ubicom Chipsets

2013-10-23 Thread James Hilliard
I'll see where i'm at this weekend in the way of progress. I'll try and
compile a stock build with dropbear so that its possible to at least start
poking around. Can you try and get a serial log from this router? Might be
helpful to see the actual boot process if possible. Also see if you can get
the uboot command line working. I may need to recompile uboot or the main
OS to get usable output but probably a good idea to try it with stock and
see what happens.


On Wed, Oct 23, 2013 at 8:43 AM, valent.turko...@gmail.com 
valent.turko...@gmail.com wrote:

 I'll be aquiring few DIR-657 devices, so if you need testers I'm your man!
 I also have a friend with flash programmer so if anything we can do to help
 just let us know.

 ___
 openwrt-devel mailing list
 openwrt-devel@lists.openwrt.org
 https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] usb-modeswitch and hotplug2 removed

2013-10-23 Thread Liverpool Bitlas
in r35380 usb-modeswitch is removed and in r36987 hotplug2 is removed. I
updated my openwrt from version older than r35380 to last one. Before i
used usb-modeswitch and hotplug for mwan3 and 3g failover. Now this
functionality doesn't work. How to fix the problem
Thanks
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Has antenna diversity been dropped from Atheros9k driver?

2013-10-23 Thread Francisco Cuesta
Hello,

I have noticed through some simple experiments that the capability to
select the antennas on the router is not working properky, or at least
not in the version of OpenWRT that I have. I mean, I used to have
tplink WDR1043ND, where I could select the antenna to use through
issuing configuring the uci as below

uci set wireless.radio1.txantenna=0x3
uci set wireless.radio1.rxantenna=0x3
uci commit
wifi

However, now with my tplink wdr4300 I cannot do such a thing. That's
to say, if I  issue that command on the openwrt, attitude adjustment
trunk version, I always get the same behaviour, whether the three
antennas are enabled or just only one may be disabled, for any
combination of the value given to .txantenna or .rxantenna...

May anyone tell me if this behaviour is normal or if that might be
re-enabled by pathching iw package??

Thanks in advance,

regards!
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] OpenWRT on Ubicom Chipsets

2013-10-23 Thread valent.turko...@gmail.com
I'm not in possestion of these routers, I just got some offer for firesale
of these devices  (really cheap) so I'm in process of ordering them...
Hopefully in few days I'll have them.

Is DIR-652 sharing same architecture?

I just came upon this article:
http://tumbetoene.tuxfamily.org/index.php?entry=entry110503-202525
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] OpenWRT on Ubicom Chipsets

2013-10-23 Thread James Hilliard
Yeah, both should be ubicom based. Are there any left in the fire sale?
On Oct 23, 2013 9:19 AM, valent.turko...@gmail.com 
valent.turko...@gmail.com wrote:

 I'm not in possestion of these routers, I just got some offer for firesale
 of these devices  (really cheap) so I'm in process of ordering them...
 Hopefully in few days I'll have them.

 Is DIR-652 sharing same architecture?

 I just came upon this article:
 http://tumbetoene.tuxfamily.org/index.php?entry=entry110503-202525

 ___
 openwrt-devel mailing list
 openwrt-devel@lists.openwrt.org
 https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/2]odhcp6c: message retransmission count support

2013-10-23 Thread Steven Barth
Hello Hans,

Thank you very much for your patches. I've commited them to the github repo and 
will do some testing probably next week. If all works out i will get them live 
afterwards.

Cheers,
Steven___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] 6relayd: verify fd is valid before use

2013-10-23 Thread Steven Barth
Hello Nathan,

Thanks for your patches. I already had a quick look at them and found that i 
already addressed some of this in odhcpd which will replace 6relayd in the near 
future. I will go through the others later again.

Cheers,
Steven___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] [packages] net/mdnsresponder: fix compile

2013-10-23 Thread Dirk Neukirchen
- refresh patch, 
- adapt patch from Jonathan Perkin (jperkin)
from: 
http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/net/mDNSResponder/patches/patch-mDNSShared_dnsextd__parser.y

Fix for bison-3 syntax.


Signed-off-by: Dirk Neukirchen dirkneukirc...@web.de
---
 net/mdnsresponder/patches/002-uclibc.patch |  7 ++--
 .../patches/010-mDNSShared_dnsextd__parser.patch   | 38 ++
 2 files changed, 41 insertions(+), 4 deletions(-)
 create mode 100644 
net/mdnsresponder/patches/010-mDNSShared_dnsextd__parser.patch

diff --git a/net/mdnsresponder/patches/002-uclibc.patch 
b/net/mdnsresponder/patches/002-uclibc.patch
index bfb0289..c2ef462 100644
--- a/net/mdnsresponder/patches/002-uclibc.patch
+++ b/net/mdnsresponder/patches/002-uclibc.patch
@@ -1,7 +1,6 @@
-diff -u --recursive mDNSResponder-214.3.2-vanilla/mDNSPosix/Makefile 
mDNSResponder-214.3.2/mDNSPosix/Makefile
 mDNSResponder-214.3.2-vanilla/mDNSPosix/Makefile   2010-10-15 
08:38:44.798283212 -0500
-+++ mDNSResponder-214.3.2/mDNSPosix/Makefile   2010-10-15 08:48:27.334503432 
-0500
-@@ -361,12 +361,16 @@
+--- a/mDNSPosix/Makefile
 b/mDNSPosix/Makefile
+@@ -362,12 +362,16 @@ STRIP = strip
  endif
  else
  
diff --git a/net/mdnsresponder/patches/010-mDNSShared_dnsextd__parser.patch 
b/net/mdnsresponder/patches/010-mDNSShared_dnsextd__parser.patch
new file mode 100644
index 000..42c7304
--- /dev/null
+++ b/net/mdnsresponder/patches/010-mDNSShared_dnsextd__parser.patch
@@ -0,0 +1,38 @@
+--- a/mDNSShared/dnsextd_parser.y
 b/mDNSShared/dnsextd_parser.y
+@@ -56,7 +56,7 @@ Revision 1.1  2006/07/06 00:09:05  chesh
+ #include DebugServices.h
+ #include dnsextd.h
+ 
+-void yyerror( const char* error );
++void yyerror( void *context, const char* error );
+ int  yylex(void);
+ 
+ 
+@@ -114,8 +114,6 @@ static ZoneSpec*   g_zones;
+ static ZoneSpec   g_zoneSpec;
+ static const char *   g_filename;
+ 
+-#define YYPARSE_PARAM  context
+-
+ void
+ SetupOptions
+   (
+@@ -125,6 +123,8 @@ SetupOptions
+ 
+ %}
+ 
++%parse-param { void *context }
++
+ %union
+ {
+   int number;
+@@ -411,7 +411,7 @@ int yywrap(void);
+ 
+ extern int yylineno;
+ 
+-void yyerror( const char *str )
++void yyerror( void *context, const char *str )
+ {
+ fprintf( stderr,%s:%d: error: %s\n, g_filename, yylineno, str );
+ }
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel