up

RG-1000 or Apple AirPort Dialup/Hangup Modem

Here are two ultra-simple c programs that send a UDP packet to an RG-1000 or AirPort to tell the device to hangup or dialup the internet connection via the builtin modem. The TCP/IP address of the device is compiled in and the code is a copy and paste from an example found out on the web with a few simple changes (our UDP packet payload). For the next version, it would be nice to roll everything into one program with TCP/IP address of device as a command line option and be able to poll the device for connection status. These should work just fine on most platforms (Linux, FreeBSD, etc).

dialup.c:

#include 
#include 
#include 
#include 

int main()
{   int sd;
    struct sockaddr_in addr;
    int addr_len = sizeof(addr);
    char hangup[] = { 0x07 };

    sd = socket(PF_INET, SOCK_DGRAM, 0);
    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(192);
    inet_aton("10.0.1.1", &addr.sin_addr);
    if ( connect(sd, (struct sockaddr*)&addr, sizeof(addr)) != 0 )
        perror("connect 1");
    send(sd, hangup, sizeof(hangup), 0);
    close(sd);
}

hangup.c:

#include 
#include 
#include 
#include 

int main()
{   int sd;
    struct sockaddr_in addr;
    int addr_len = sizeof(addr);
    char hangup[] = { 0x06 };

    sd = socket(PF_INET, SOCK_DGRAM, 0);
    bzero(&addr, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(192);
    inet_aton("10.0.1.1", &addr.sin_addr);
    if ( connect(sd, (struct sockaddr*)&addr, sizeof(addr)) != 0 )
        perror("connect 1");
    send(sd, hangup, sizeof(hangup), 0);
    close(sd);
}

To compile: "Save As" on the filenames above and then do "cc dialup.c -o dialup" and the same for hangup.c.

The information for what to put in the UDP packet and what port to send it to on the device came from here:

http://edge.mcs.drexel.edu/GICL/people/sevy/airport/#Hangup

raw-io.com