Menu

#8 HeartBeat (BigPond) support broken

v1.0_(example)
open
9
2004-02-17
2004-02-17
Rod Whitby
No

There is a problem in the official Linksys firmware with
regard to the Australian Bigpond HeartBeat (bpalogin)
support. I'm hoping it can be fixed in the WiFi firmware.

The issue can be seen in the official Linksys 2.02 source
code in file .../release/src/router/rc/heartbeat.c on line
200 (hb_disconnect_main) which is called from
file .../release/src/router/bpalogin/bpalogin.c on line 96
(inside mainloop, when the bigpond heartbeat does not
come within the timeout interval, and bpalogin sleeps for
a minute before trying to log in again).

The problem is that s->ondisconnected is called at this
spot with an argument of "1" which means it's a
temporary error, rather than a permanent error.
Unfortunately, the code in heartbeat.c does not take
the argument into account, and shuts down the wan
interface for both temporary and a permanent error.

So the hb_disconnect_main code in heartbeat.c should
only shut down the wan interface when the argument
is "0", and should do nothing apart from log the
temporary error when the argumentis "1".

Discussion

  • TCBBS

    TCBBS - 2004-02-17
    • labels: --> Interface (example)
    • milestone: --> v1.0_(example)
    • priority: 5 --> 9
    • assigned_to: nobody --> wifi-box
     
  • Augustin VU

    Augustin VU - 2004-02-19

    Logged In: YES
    user_id=948364

    Thanks, You can submit a patch or i'll fix it for my next
    release.

     
  • Rod Whitby

    Rod Whitby - 2004-03-04

    Logged In: YES
    user_id=11146

    Here are my changes to start_heartbeat() in heartbeat.c:

    MY_LOG(LOG_DEBUG, "heartbeat: Start heartbeat
    daemon\n");
    MY_LOG(LOG_DEBUG, "heartbeat: hb_server_ip[%s]
    wan_get_domain[%s]\n", nvram_safe_get("hb_server_ip"),
    nvram_safe_get("wan_get_domain"));

    /* We must find out HB auth server from domain that
    get by dhcp if user don't input HB sever. */
    if(nvram_invmatch("hb_server_ip", "") &&
    nvram_invmatch("hb_server_ip", "0.0.0.0")){
    snprintf(authserver, sizeof(authserver), "%s",
    nvram_safe_get("hb_server_ip"));
    snprintf(authdomain, sizeof(authdomain), "%s", "");
    }
    else if((nvram_match
    ("wan_get_domain", "nsw.bigpond.net.au")) || // NSW
    (nvram_match
    ("wan_get_domain", "vic.bigpond.net.au")) || //
    Victoria
    (nvram_match
    ("wan_get_domain", "qld.bigpond.net.au")) || //
    Queensland
    (nvram_match
    ("wan_get_domain", "sa.bigpond.net.au")) || //
    South Australia
    (nvram_match
    ("wan_get_domain", "wa.bigpond.net.au"))) { //
    Western Australia
    snprintf(authserver, sizeof(authserver), "%s", "sm-
    server");
    snprintf(authdomain, sizeof(authdomain), "%s",
    nvram_safe_get("wan_get_domain"));
    }
    else{
    MY_LOG(LOG_ERR, "heartbeat: Cann't find HB
    server from domain! Use gateway.\n");
    snprintf(authserver, sizeof(authserver), "%s",
    nvram_safe_get("wan_gateway"));
    snprintf(authdomain, sizeof(authdomain), "%s", "");
    //return 1;
    }

    MY_LOG(LOG_DEBUG, "heartbeat: authserver[%s]
    authdomain[%s]\n", authserver, authdomain);

    snprintf(buf, sizeof(buf), "%s%c%s", authserver, !strcmp
    (authdomain,"") ? '\0' : '.', authdomain);
    nvram_set("hb_server_name", buf);

    MY_LOG(LOG_DEBUG, "heartbeat: Connect to HB server
    [%s]\n", buf);

    //syslog(LOG_DEBUG, "heartbeat: authserver[%s]
    authdomain[%s]\n", authserver, authdomain);
    if (!(fp = fopen("/tmp/bpalogin.conf", "w"))) {
    MY_LOG(LOG_ERR, "heartbeat: Cann't write %
    s\n", "/tmp/bpalogin.conf");
    perror("/tmp/bpalogin.conf");
    return errno;
    }
    fprintf(fp, "username %s\n", nvram_safe_get
    ("ppp_username"));
    fprintf(fp, "password %s\n", nvram_safe_get
    ("ppp_passwd"));
    fprintf(fp, "authserver %s\n", authserver);
    if (strcmp(authdomain,""))
    fprintf(fp, "authdomain %s\n", authdomain);
    fprintf(fp, "localport 5050\n");
    fprintf(fp, "logging syslog\n");
    fprintf(fp, "debuglevel 2\n");
    fprintf(fp, "minheartbeatinterval 60\n");
    fprintf(fp, "maxheartbeatinterval 420\n");
    fprintf(fp, "connectedprog hb_connect\n");
    fprintf(fp, "disconnectedprog hb_disconnect\n");

    fclose(fp);

    and here is the new hb_disconnect_main:

    int
    hb_disconnect_main(int argc, char **argv)
    {
    openlog("heartbeat" ,LOG_PID, LOG_DAEMON);

    MY_LOG(LOG_INFO, "The user have logged out: %s\n",
    argv[1]);

    if (strcmp(argv[1], "1"))
    stop_wan();

    return unlink("/tmp/ppp/link");
    }

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.