1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Tools_Sysinfo page and correct WAN LAN show

Discussion in 'Asuswrt-Merlin' started by AndreyPopov, Jul 29, 2014.

  1. AndreyPopov

    AndreyPopov Senior Member

    Joined:
    Jun 28, 2014
    Messages:
    287
    Location:
    Ukraine
    1. AC87 have 7 port for CPU - in Tools page logic only port 8 and 5 sutiable to CPU

    2. others routers have different formulas of cpu/WAN/LANs


    case MODEL_RTAC87U:
    WAN L1 L2 L3 L4 CPU */
    0, 5, 3, 2, 1, 7 };
    case MODEL_RTN66U:
    case MODEL_RTAC66U:
    WAN L1 L2 L3 L4 CPU */
    { 0, 1, 2, 3, 4, 8 }; }
    case MODEL_RTN16:
    WAN L1 L2 L3 L4 CPU */
    { 0, 4, 3, 2, 1, 8 };
    case MODEL_RTN15U:
    WAN L1 L2 L3 L4 CPU */
    { 4, 3, 2, 1, 0, 8 };
    case MODEL_RTN10U:
    WAN L1 L2 L3 L4 CPU */
    0, 4, 3, 2, 1, 5 };
    case MODEL_RTAC56U:
    case MODEL_RTN14UHP:
    WAN L1 L2 L3 L4 CPU */
    4, 0, 1, 2, 3, 5 };
    case MODEL_RTAC68U:
    case MODEL_RTAC3200:
    case MODEL_RTN18U:
    case MODEL_RTAC53U:
    WAN L1 L2 L3 L4 CPU */
    0, 1, 2, 3, 4, 5 };
    case MODEL_RTN53:
    case MODEL_RTN12:
    case MODEL_RTN12B1:
    case MODEL_RTN12C1:
    case MODEL_RTN12D1:
    case MODEL_RTN12VP:
    case MODEL_RTN12HP:
    case MODEL_RTN12HP_B1:
    case MODEL_RTN10P:
    case MODEL_RTN10D1:
    case MODEL_RTN10PV2:
    WAN L1 L2 L3 L4 CPU */
    4, 3, 2, 1, 0, 5 };


    RMerlin please help correct code in Tools page for correct show WAN and LANs

    P.S. for ac87U now code already corrected.
     
  2. AndreyPopov

    AndreyPopov Senior Member

    Joined:
    Jun 28, 2014
    Messages:
    287
    Location:
    Ukraine
    Code:
    switch (based_modelid) :
    {
    		case RT-AC87U :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-AC66U :
    		case RT-N66U :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-N16 :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-N15U :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-N10U :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-AC56U :
    		case RT-N14UHP :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-AC68U :
    		case RT-N18U :
    		case RT-AC3200 :
    		case RT-AC53U :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    
    		case RT-N53 :
    		case RT-N12 :
    		case RT-N12A1 :
    		case RT-N12B1 :
    		case RT-N12C1 :
    		case RT-N12D1 :
    		case RT-N12HP :
    		case RT-N12HP_V1 :
    		case RT-N12VP :
    		case RT-N10P :
    		case RT-N10P_V2 :
    		case RT-N10D1 :
    		{
    			tmpPort = ???
    			port = ???
    			entry = ????
    			code_ports = ???
    		break;
    		}
    }
    
     
  3. AndreyPopov

    AndreyPopov Senior Member

    Joined:
    Jun 28, 2014
    Messages:
    287
    Location:
    Ukraine
    may be code:
    Code:
    			if (tmpPort == "8") {		// CPU Port
    				continue;
    			} else if (based_modelid == "RT-AC56U") {
    				tmpPort++;		// Port starts at 0
    				if (tmpPort == "5") tmpPort = 0;	// Last port is WAN
    			} else if (based_modelid == "RT-AC87U") {
    				if (tmpPort == "4")
    					continue;	// This is the internal LAN port
    				if (tmpPort == "5") {
    					tmpPort = "4";	// This is the LAN 4 port from QTN
    					devicename = "<unknown>";
    				}
    			}
    			if (tmpPort == "0") {
    				port = "WAN";
    			} else {
    				if ((based_modelid == "RT-N16") || (based_modelid == "RT-AC87U"))  tmpPort = 5 - tmpPort;
    				port = "LAN "+tmpPort;
    			}
    

    with this
    Code:
    switch (based_modelid) :
    {
    		case RT-AC87U :
    		{
    		  switch (tmpPort) :
    			{
    			  case 0 : port = "WAN";
    			  case 1 : port = "LAN 4";
    			  case 2 : port = "LAN 3";
    			  case 3 : port = "LAN 2";
    			  case 5 : port = "LAN 1";
    			  case 4 :
    			  case 6 :
    			  case 7 :
    			  case 8 :
    			break;
    			{
    		break;
    		}
    
    		case RT-AC66U :
    		case RT-N66U :
    		case RT-AC68U :
    		case RT-N18U :
    		case RT-AC3200 :
    		case RT-AC53U :
    		{
    		  switch (tmpPort) :
    			{
    			  case 0 : port = "WAN";
    			  case 1 : port = "LAN 1";
    			  case 2 : port = "LAN 2";
    			  case 3 : port = "LAN 3";
    			  case 4 : port = "LAN 4";
    			  case 5 :
    			  case 6 :
    			  case 7 :
    			  case 8 :
    			break;
    			{
    		break;
    		}
    
    		case RT-N16 :
    		case RT-N10U :
    		{
    		  switch (tmpPort) :
    			{
    			  case 0 : port = "WAN";
    			  case 1 : port = "LAN 4";
    			  case 2 : port = "LAN 3";
    			  case 3 : port = "LAN 2";
    			  case 4 : port = "LAN 1";
    			  case 5 :
    			  case 6 :
    			  case 7 :
    			  case 8 :
    			break;
    			{
    		break;
    		}
    
    		case RT-N15U :
    		case RT-N53 :
    		case RT-N12 :
    		case RT-N12A1 :
    		case RT-N12B1 :
    		case RT-N12C1 :
    		case RT-N12D1 :
    		case RT-N12HP :
    		case RT-N12HP_V1 :
    		case RT-N12VP :
    		case RT-N10P :
    		case RT-N10P_V2 :
    		case RT-N10D1 :
    		{
    		  switch (tmpPort) :
    			{
    			  case 4 : port = "WAN";
    			  case 0 : port = "LAN 4";
    			  case 1 : port = "LAN 3";
    			  case 2 : port = "LAN 2";
    			  case 3 : port = "LAN 1";
    			  case 5 :
    			  case 6 :
    			  case 7 :
    			  case 8 :
    			break;
    			{
    		break;
    		}
    
    		case RT-AC56U :
    		case RT-N14UHP :
    		{
    		  switch (tmpPort) :
    			{
    			  case 4 : port = "WAN";
    			  case 0 : port = "LAN 1";
    			  case 1 : port = "LAN 2";
    			  case 2 : port = "LAN 2";
    			  case 3 : port = "LAN 4";
    			  case 5 :
    			  case 6 :
    			  case 7 :
    			  case 8 :
    			break;
    			{
    		break;
    		}
    }
    
     
  4. RMerlin

    RMerlin Super Moderator

    Joined:
    Apr 14, 2012
    Messages:
    31,304
    Location:
    Canada
    You're replacing 19 lines of code with 110 lines. With an interpreted language such as Javascript, this isn't very efficient.
     
  5. AndreyPopov

    AndreyPopov Senior Member

    Joined:
    Jun 28, 2014
    Messages:
    287
    Location:
    Ukraine
    more lines of code - I agree

    but this code for 5 port models and more than 10 router models

    your code have 8 if's to find what port wan or lan.
    I think {switch ... case} may be faster in this situation, imho

    I only ask your opinion.

    thanks
     
  6. AndreyPopov

    AndreyPopov Senior Member

    Joined:
    Jun 28, 2014
    Messages:
    287
    Location:
    Ukraine
    like for me - work perfect:
    Code:
    //Andrey begin
    switch (based_modelid)
    {
    		case "RT-AC87U":
    		{
    		  switch (tmpPort) 
    			{
    			  case "0":
    				port = "WAN";
    				break;
    			  case "1":
    				port = "LAN 4";
    				break;
    			  case "2":
    				port = "LAN 3";
    				break;
    			  case "3":
    				port = "LAN 2";
    				break;
    			  case "5":
    				port = "LAN 1";
    				break;
    			  default:
    				port = "CPU";
    			}
    		break;
    		}
    
    		case "RT-AC66U":
    		case "RT-N66U":
    		case "RT-AC68U":
    		case "RT-N18U":
    		case "RT-AC3200":
    		case "RT-AC53U":
    		{
    		  switch (tmpPort) 
    			{
    			  case "0":
    				port = "WAN";
    				break;
    			  case "1":
    				port = "LAN 1";
    				break;
    			  case "2":
    				port = "LAN 2";
    				break;
    			  case "3":
    				port = "LAN 3";
    				break;
    			  case "4":
    				port = "LAN 4";
    				break;
    			  default:
    				port = "CPU";
    			}
    		break;
    		}
    
    		case "RT-N16":
    		case "RT-N10U":
    		{
    		  switch (tmpPort) 
    			{
    			  case "0":
    				port = "WAN";
    				break;
    			  case "1":
    				port = "LAN 4";
    				break;
    			  case "2":
    				port = "LAN 3";
    				break;
    			  case "3":
    				port = "LAN 2";
    				break;
    			  case "4":
    				port = "LAN 1";
    				break;
    			  default:
    				port = "CPU";
    			}
    		break;
    		}
    
    		case "RT-N15U":
    		case "RT-N53":
    		case "RT-N12":
    		case "RT-N12A1":
    		case "RT-N12B1":
    		case "RT-N12C1":
    		case "RT-N12D1":
    		case "RT-N12HP":
    		case "RT-N12HP_V1":
    		case "RT-N12VP":
    		case "RT-N10P":
    		case "RT-N10P_V2":
    		case "RT-N10D1":
    		{
    		  switch (tmpPort) 
    			{
    			  case "4":
    				port = "WAN";
    				break;
    			  case "0":
    				port = "LAN 4";
    				break;
    			  case "1":
    				port = "LAN 3";
    				break;
    			  case "2":
    				port = "LAN 2";
    				break;
    			  case "3":
    				port = "LAN 1";
    				break;
    			  default:
    				port = "CPU";
    			}
    		break;
    		}
    
    		case "RT-AC56U":
    		case "RT-N14UHP":
    		{
    		  switch (tmpPort) 
    			{
    			  case "4":
    				port = "WAN";
    				break;
    			  case "0":
    				port = "LAN 1";
    				break;
    			  case "1":
    				port = "LAN 2";
    				break;
    			  case "2":
    				port = "LAN 3";
    				break;
    			  case "3":
    				port = "LAN 4";
    				break;
    			  default:
    				port = "CPU";
    			}
    		break;
    		}
    }
    //Andrey end
    			if ( port !== "CPU") {			
    			entry = '<tr><td>' + port + '</td><td>' + (line[7] & 0xFFF) + '</td><td><span>' + state2 + '</span></td>';
    			entry += '<td>'+ devicename +'</td></tr>';}
    			else break;
    
    tested on RT-N15U. now try on others RT-N10U and RT-N10P


    P.S. and this code ready for future router models and switch ports models. ;)

    P.S.P.S. I don't understand for what this code?
    Code:
    			if (based_modelid == "RT-N16")
    				code_ports = entry + code_ports;
    			else
    				code_ports += entry;
    
    for what you add space (" ") for entry var if RT-N16?
     
    Last edited: Jul 30, 2014