Wednesday, November 30, 2011

A Bug in jQuery Grid Plugin

I want to call this a bug because, as the name implies, editoptions is optional. (That being said, this is a small bug in an excellent jQuery plugin.)

But without editoptions, a column with edittype="select" will be created in a formedit dialog without an id attribute, which results a data element missing when the form is submitted. Of course, this is only a problem when one wants to customize the form initialization — Most people probably do not use jqgrid that way.

The bug should be in the area between line number 548 and 564 in grid.formedit.js as of jQuery Grid plugin version 4.2.0. But I haven't had much time to understand exactly how that code section works.

A workaround seems to be always have an editoptions parameter for a select type column, as the example below shows:

     array('name' => "actid", 'index' => "actid", 'width' => 50, 'align' => "center",
           'editable' => true, 'edittype' => "select", 'editoptions' => array('value' => ";"))


That is data for a column in PHP from the drupal-nm project, with the workaround colored in red.

Tuesday, November 1, 2011

Extending Home Wireless Network

My Internet service provider is Comcast, whose cable comes in the house on the side, enters the basement, then terminates on a cable modem, which is connected to a wireless router. I have a dual-band Netgear N600 (model WNDR3700).

The wireless signal traveling up from the basement works fine on the first floor and part of the second floor. I get fairly consistent 200Mbps link speeds on the 5GHz 802.11n connections on the first floor. But in the corner where I sit on the second floor, even with signal strength reading at -70dBm and above, my netbook with a 2.4GHz 802.11g radio rarely gets above 26Mbps and more often stays below 6Mbps, with high rate of packet loss.

I bought the first Netgear N600 refurbished at $58 plus change. At that price, it seems make sense to get another one to extend the reach of my wireless network to the entire second floor: I could use the 5GHz radio for backhaul down to the basement and 2.4GHz radio for connecting devices. That is a little geeky but should work.

The stock software in the WNDR3700 (v1, as it turns out) does not support client mode. I don't want to use WDS because it would mean I lose an entire radio band to the backhaul. I have had good experience with DD-WRT working in the way I want: Using one of them in client mode and as a router to bridge a network segment from the second floor to the main network in the basement.

Installing the latest version (2.4 pre-SP2) on the WNDR3700 is easy: Just like what one does to upgrade the router uploading it using the web GUI -- Just make sure you are using the factory image as that is for imaging a unit running factory software.

This should be an easy project. But so far it has kept me puzzled for a bit. I will have to spend some more time to get all my network segments, DHCP settings and routing right.

So, here is the configuration, which should work but does not.

On the base router, which is still running the stock Netgear code, I have IP address 172.16.4.4 reserved for the second router, which is running DD-WRT. I also have a static route configured there for the 192.168.2.0/24 subnet.

The routing table on the second router is:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.4.1      0.0.0.0         255.255.255.255 UH    0      0        0 ath1
172.16.4.0      0.0.0.0         255.255.255.0   U     0      0        0 ath1
192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 br0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         172.16.4.4      0.0.0.0         UG    0      0        0 ath1

On the second router, the interface ath1 (which connects to the base router on the 5GHz 802.11n/a radio) has IP address 172.16.4.4 and br0 has 192.168.2.1 -- The bridge interface br0 bridges together ath0, eth0 and eth1.

I can ssh to the second router from a PC wired to it. From there I can ping everything on the 172.16.4.0/24 subnet as well as the wired device -- But nothing outside my home network.

From a device on the 172.16.4.0/24 subnet, I can ping 192.168.2.1 but not the device wired to the second router -- as if the routing table does not work.
Strange!

[Edit]: Well, maybe not -- maybe just too many late nights clouding my thinking.
The Client Mode article in the DD-WRT wiki clearly (well, maybe not) states Also note that the device should be in GATEWAY MODE instead of ROUTER mode, otherwise Masquerade/NAT does not happen. Of course, the NATing that did not happen was on the way going out the ISP link.

So now, I do have it working. I still wonder what happened on the second network segment regarding routing. Also, I wonder if I could get it working with segmenting (subneting) one 24-bit subnet and still use router-mode rather than gateway mode. Or, maybe I should just use client-bridge mode instead to make things simpler.