Announcement

Collapse
No announcement yet.

Engine Code: DSL Modem Workaround

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Engine Code: DSL Modem Workaround

    This is an easy to implement and solid improvement that will resolve a LARGE percentage of Quake connectivity difficulties for DSL users that aren't using a router. And it's automatic!

    This isn't as good as the method DarkPlaces or Quakeworld use to establish connections, but it is very easy to implement.

    This doesn't resolve trouble that dialup users with a LAN have or situations where someone has 2 network cards and so forth. But dialup users are rare and most people don't have a complicated setup. And this won't resolve issues where someone has setup DSL in a very strange way involving a router.

    But this does fix 1 of the 4 situations requiring the -ip parameter with NQ, which is probably at least half of the situations where someone should be able to connect to a server, but can't.

    Instructions:

    1. Open net_wins.c

    2. Find void WINS_GetLocalAddress()

    Old way, to be replaced

    void WINS_GetLocalAddress()
    {
    struct hostent *local = NULL;
    char buff[MAXHOSTNAMELEN];
    unsigned long addr;

    if (myAddr != INADDR_ANY)
    return;

    if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
    return;

    blocktime = Sys_FloatTime();
    WSASetBlockingHook(BlockingHook);
    local = pgethostbyname(buff);
    WSAUnhookBlockingHook();
    if (local == NULL)
    return;

    myAddr = *(int *)local->h_addr_list[0];

    addr = ntohl(myAddr);
    sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16 ) & 0xff, (addr >> 8 ) & 0xff, addr & 0xff);
    }
    3. Replace the above with this.

    New way, replaces the above code entirely with this

    void WINS_GetLocalAddress()
    {
    struct hostent *local = NULL;
    char buff[MAXHOSTNAMELEN];
    unsigned long addr;

    if (myAddr != INADDR_ANY)
    return;

    if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR)
    return;

    blocktime = Sys_FloatTime();
    WSASetBlockingHook(BlockingHook);
    local = pgethostbyname(buff);
    WSAUnhookBlockingHook();
    if (local == NULL)
    return;

    // Baker: Here is our DSL workaround. It works like this:
    // ip addresses that begin 169.254.x.x are always invalid
    // these are self-assigned APIPA addresses for DHCP
    // for devices that fail.
    //
    // There are 2 reasons for failure:
    // #1. plain DSL modem (with no router built-in)
    // #2. DHCP failure of some sort
    //
    // If we find ip address #0 is 169.254.x.x then
    // we will assume it is a DSL modem and check to see if
    // there is a 2nd ip address available.
    //
    // Even if ip address #0 is 169.254.x.x and not a
    // DSL modem, which can happen with situations like
    // a defective router or improperly configured
    // network adapter, it still isn't going to work
    // so checking ip address #1 and using that if available
    // is still desireable.

    // Baker: get ip address #0

    myAddr = *(int *)local->h_addr_list[0];
    addr = ntohl(myAddr);
    sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8 ) & 0xff, addr & 0xff);

    // Baker: is ip address #0 = 169.254.x.x ?
    if (((addr >> 24 ) & 0xff) == 169 && ((addr >> 16 ) & 0xff) == 254) {
    // Ok, can't use ip address #0.
    Con_DPrintf ("WINS_GetLocalAddress: ip address #0 (%s) is invalid, checking next ...\n", my_tcpip_address);

    if (local->h_addr_list[1]) {
    // ip address #1 is valid, use it.
    myAddr = *(int *)local->h_addr_list[1];
    addr = ntohl(myAddr);
    sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16 ) & 0xff, (addr >> 8 ) & 0xff, addr & 0xff);
    Con_DPrintf ("WINS_GetLocalAddress: ip address #1 (%s) found. Using.\n", my_tcpip_address);
    } else {
    Con_DPrintf("WINS_GetLocalAddress: ip address #1 does not exist\n");
    Con_DPrintf("WINS_GetLocalAddress: Warning continuing with #0\n");
    Con_Printf("Invalid IP (%s): Is internet/network connected?\n", my_tcpip_address);
    }
    }

    }
    This change simply ignores ip #0 if the address is 169.254.x.x and checks to see if a 2nd ip address exists (ip #1) and if so, uses it.

    You can read the comments I put into the code to understand it.

    /quote blocks don't show tabs. The code be taken out of the ProQuake 3.99a source:
    http://www.quakeone.com/proquake/pro...80116_2226.zip

    (Thanks to tryno, looking at his idea he coded was very helpful in coming up with this idea. This can continue to be evolved further as well).
    Last edited by Baker; 01-17-2008, 01:38 AM.
    Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

    So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

  • #2
    Hey Baker, just a problem I think.

    //It works like this:
    // ip addresses that begin 169.254.x.x are always invalid
    // these are self-assigned APIPA addresses for DHCP
    // for devices that fail.
    These self-assigned addresses vary (?) from location to location. For instance, in my DSL modem the basic address is 192.168.x.x, so everyone would have to check their basic addresses before coding their engines.
    That's somekind of a problem, since not everybody is a coder and no builted engine would work to everyone.

    Hope you can understand what I mean.
    Thanks,
    Tryno

    Comment


    • #3
      Originally posted by tryno View Post
      Hey Baker, just a problem I think.



      These self-assigned addresses vary (?) from location to location. For instance, in my DSL modem the basic address is 192.168.x.x, so everyone would have to check their basic addresses before coding their engines.
      That's somekind of a problem, since not everybody is a coder and no builted engine would work to everyone.

      Hope you can understand what I mean.
      No, they don't vary from location, actually.

      Your DSL modem has 192.168.x.x ip address because it has a built-in single-port router. They do this especially for customers that have an XBox, Playstation or what not so that the router can be programmed with the PPPOE username and password.

      A DSL modem with a single-port router built-in isn't going to have the problem this fix addresses.

      (But you'd have a different problem if you weren't using ProQuake, JoeQuake, Qrack or DarkPlaces. But since ProQuake has an NAT router fix, you aren't affected by it. ProQuake 3.40 added an NAT fix, this was ported to JoeQuake in 2003 and Qrack is based off JoeQuake.)
      Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

      So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

      Comment


      • #4
        Tryno, I've been thinking about this some more and I can adjust this to solve 95% of the situations where -ip is required automatically.

        Here is how this works:

        169.254.x.x = PPPOE DSL Modem with no router built-in or defective hardware
        192.168.x.x = Router
        10.x.x.x = Router (Usually a high end one, used by businesses mostly)
        x.x.x.x = DHCP connection or PPPOE connection or dialup connection

        All this needs to do is check the first 3 ip addresses and use x.x.x.x if available, otherwise fallback to a 192.168.x.x address if available, then to 10.x.x.x if available.

        This would resolve every situation except the odd setup with 2 routers. It would fix dial-up, a standalone DSL modem with no router capabilities and a situation with a DSL modem WITH router capabilities where someone is using software to connect PPPOE.

        I'll make it sometime tonight and post it here.
        Quakeone.com - Being exactly one-half good and one-half evil has advantages. When a portal opens to the antimatter universe, my opposite is just me with a goatee.

        So while you guys all have to fight your anti-matter counterparts, me and my evil twin will be drinking a beer laughing at you guys ...

        Comment

        Working...
        X