heredago's blog

January 3, 2012

WOL supplement info TOMATO WRT54GL DD-WRT LINKSYS – attached files from http://www.wolcenter.com/faq.php

Filed under: Uncategorized — Tags: , , — heredago @ 22:08

Suite de: WOL TOMATO WRT54GL – WHAT I (heredago) PERSONALY DID

 

  • UDP forward to a broadcast address within the LAN:

In this case, we would like the router to act as a UDP proxy. More specifically, it should be able to broadcast an UDP packet received on a LAN port.

By default, DD-WRT (24SP2) and Tomato (1.25) won’t support this feature, but it can be implemented as small executable called “UDP-Proxy”:
UDP-Proxy v.0.50 build for Tomato v1.25 (see at the end of the post if link is broken)
UDP-Proxy v.0.50 build for DD-WRT v24SP2 (see at the end of the post if link is broken)
UDP-Proxy v.0.50 source code (see at the end of the post if link is broken)

To survive a reboot, UDP-Proxy must be copied into the /jffs diretory.

To start automatically add the following launch command to the init script of the router:

/jffs/udp-proxy 7 192.168.1.255 8 &

where parameter 1 is the input port, parameter 2 is the destination broadcast address, parameter 3 the destination port.

For Wake on Wan driven by wolcenter.com:

  • Solution 1:
    – Install a Netgear WGR614L or Linksys WRT54GL box as a ROUTER with Tomato or DD-WRT. By “ROUTER”, I mean the WAN port connected to the ADSL modem and the LAN ports to the LAN.
    – Install the init script “ip neigh …”
    – Add a port forward rule, to redirect incoming UDP packet to the IP address specified in the init script
    – Configure your wolcenter.com devices to send magic packets to your public IP address with the port specified in the port forward rule.
  • Solution2:
    – If you prefer to keep your existing router (called “gateway” below), you may install a Netgear WGR614L or Linksys WRT54GL box as a simple LAN device with Tomato or DD-WRT. By “LAN device” I mean to connect a LAN port of the router to the network, and leave the WAN port unconnected. The LAN gateway role is handled by another device.
    – Install UDP-Proxy on the router
    – Add a port forward rule to the LAN gateway (not the WGR614L or WRT54GL) to redirect incoming UDP packet to the IP address of the router (LAN device) with the input port of UDP-Proxy.
    – Configure your wolcenter.com devices to send magic packets to your public IP address with the port specified in the port forward rule.

 

 

UDP-Proxy v.0.50 source code Source code de udp-proxy.c:

#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <syslog.h>

#define version “0.50”

void main(int argc, char *argv[])
{
struct sockaddr_in saSRC, saDST, saRCV;
char cBuf[1<<16];
int sSRC, sDST;
struct hostent *ph;
int nLen;
int bDebug = 0;
int on = 1;
pid_t pid;
int nAS;
unsigned long aRCV, aDST;
int i;

char *pszApp = *argv++;

if (argc > 1 && (!strcmp(*argv, “–debug”) || !strcmp(*argv, “-d”)))
{
bDebug = 1;
argc–;
argv++;
}

printf(“UDPProxy v%s – Phil Ten – phil@philten.com\n”,version);
if (argc != 4)
{
printf(“Usage: %s [–debug] port-in ip-address port-out\n”, pszApp);
exit(1);
}

printf(“UDP Forward from port %s to %s port %s\n”,
argv[0],
argv[1],
argv[2]);

if (bDebug==1)
printf(“Debug enabled\n”);

ph = gethostbyname(argv[1]);
if (ph == NULL)
{
printf(“Invalid address %s\n”,argv[1]);
exit(1);
}

saDST.sin_family = AF_INET;
saDST.sin_port = htons(atoi(argv[2]));
saDST.sin_addr.s_addr = *((unsigned long *)ph->h_addr);

saSRC.sin_family = AF_INET;
saSRC.sin_port = htons(atoi(argv[0]));
saSRC.sin_addr.s_addr = 0;

sSRC = socket(AF_INET, SOCK_DGRAM, 0);
sDST = socket(AF_INET, SOCK_DGRAM, 0);

if (bind(sSRC, (struct sockaddr *)&saSRC, sizeof(saSRC)))
{
printf(“Unable to bind to socket\n”);
exit(1);
}

setsockopt(sDST, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));

aDST = htonl(saDST.sin_addr.s_addr);

while (1)
{
nAS = sizeof(saRCV);

nLen = recvfrom(sSRC, cBuf, sizeof(cBuf), 0, (struct sockaddr *)&saRCV, &nAS);

if (bDebug)
printf(“UDP Forward %d.%d.%d.%d->%s:%s (length=%d)\n”,
((unsigned char *)&saRCV.sin_addr.s_addr)[0],
((unsigned char *)&saRCV.sin_addr.s_addr)[1],
((unsigned char *)&saRCV.sin_addr.s_addr)[2],
((unsigned char *)&saRCV.sin_addr.s_addr)[3],
argv[1],
argv[2],
nLen);

sendto(sDST, cBuf, nLen, 0, (struct sockaddr *)&saDST, sizeof(saDST));

}
}

 

FOR THE 2 FILES BELOW, DOWNLOAD THE FILE AND REMOVE THE .ODT EXTENSION, THESE FILES HAVE NO EXTENSION; I HAD TO PUT A FAKE ONE JUST TO BE ABLE TO UPLOAD THEM TO THIS BLOG POST

– UDP-Proxy v.0.50 build for Tomato v1.25

https://heredago.files.wordpress.com/2012/01/udp-proxy-tomato-v1-25.odt
– UDP-Proxy v.0.50 build for DD-WRT v24SP2
https://heredago.files.wordpress.com/2012/01/udp-proxy-ddwrt-v24.odt

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: