unable to discover the linksys router wag54g thru SSDP fro..

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

I am unable to discover the linksys router wag54g thru SSDP from win2k;
It is hanging for ever at: 'recvfrom (skt, buff, len, 0, (struct
sockaddr *)&c, &slen);' in the code snippet shown below.

Apparently, this seems to be happpening after I applied firmware
upgrade to the linksys router. Before applying the upgrade it was
detectable. The firmawre upgrade has made the router TR-069 complaint.
However, by any chance, would it have also made non TR-064 complaint,
thereby preventing devices with devicetype
'urn:dslforum-org:service:InternetGatewayDevice:1' from responding ?
Any help here is greatly appreciated.


#include "ssdp.h"

void initializeWinSock () {
WSADATA jnk;

WSAStartup(WINSOCK_VERSION, &jnk);
//Hopefully we are ready to start now.

}

void cleanWinSock() {
WSACleanup();
}

int skt;

char * geterrormsg() {
LPVOID lpMsgBuf;
static char buff[1024];
int error = WSAGetLastError();
if (error == WSAENOPROTOOPT) printf("Winsock doesnt support this
option");
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
0,//MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0,NULL );


sprintf(buff,"%d-%s",error,lpMsgBuf);


return (char *)buff;


}

int sendRequest() {
int status;
struct sockaddr_in a, b, c;
unsigned char ttl = 1; //Only hop at the moment in LAN :)
int slen = sizeof (c);
char buff [4096];
int len;

memset (buff,0,4096);
strcat(buff,"M-SEARCH * HTTP/1.1\r\n");
strcat(buff,"HOST: 239.255.255.250:1900\r\n");
strcat(buff,"MAN: \"ssdp:discover\"\r\n");
strcat(buff,"ST:
urn:dslforum-org:service:InternetGatewayDevice:1\r\n");
strcat(buff,"MX: 10\r\n\r\n");

len = strlen(buff);
skt = socket (AF_INET, SOCK_DGRAM, 0);
if (skt == -1) {perror ("socket");return -1;}

a.sin_family = AF_INET;
a.sin_port = htons(PORT);
a.sin_addr.s_addr = htonl(INADDR_ANY);
int one = 1;
setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
status = bind (skt,(const struct sockaddr*)&a,sizeof (a));
if (status == -1 ) {closesocket(skt); perror("bind"); return -1;}

b.sin_family = AF_INET;
b.sin_port = htons(PORT);
b.sin_addr.s_addr = htonl(0xEFFFFFFA);
status = setsockopt (skt,SOL_SOCKET,SO_BROADCAST,(char
*)&one,sizeof(one));
if (status == 0) {
status = sendto (skt,buff, len, 0, (const struct sockaddr *)&b,
sizeof(b));
printf("Sending %s\n", buff);
}

struct ip_mreq mreq;
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
mreq.imr_multiaddr.s_addr = htonl(0xEFFFFFFA);

ttl = 1;
status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_LOOP,(const char
*)&ttl,sizeof(ttl));
ttl =1;
status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_TTL,(const char
*)&ttl,sizeof(ttl));
status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_IF,(const char
*)&mreq.imr_interface.s_addr,sizeof(struct sockaddr_in));
status = setsockopt(skt,IPPROTO_IP,IP_ADD_MEMBERSHIP,(const char
*)&mreq,sizeof(mreq));
if (status == -1) {printf("The error msg = %s" , geterrormsg());
return -1;}

len = 4096;
while(1) {
slen = sizeof (c);
memset (buff,0,4096);
recvfrom (skt, buff, len, 0, (struct sockaddr *)&c, &slen);
printf("The received IP is %s\n",inet_ntoa(c.sin_addr));printf("The
message is %s\r\n", buff);
memset (buff,0,4096);
}

return 0;
}

int main() {
initializeWinSock();
sendRequest();
cleanWinSock();
return 0;
}
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

Thanks for a good suggestion. The same thought crossed my mind as well.
Yes, I'll check with the linksys Tech Support and post the response if
anything good turns up.
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

After the "upgrade" was the router reset? If yes,have you checked in
with Linksys tech support?

venkatu662000@yahoo.com wrote:

> I am unable to discover the linksys router wag54g thru SSDP from win2k;
> It is hanging for ever at: 'recvfrom (skt, buff, len, 0, (struct
> sockaddr *)&c, &slen);' in the code snippet shown below.
>
> Apparently, this seems to be happpening after I applied firmware
> upgrade to the linksys router. Before applying the upgrade it was
> detectable. The firmawre upgrade has made the router TR-069 complaint.
> However, by any chance, would it have also made non TR-064 complaint,
> thereby preventing devices with devicetype
> 'urn:dslforum-org:service:InternetGatewayDevice:1' from responding ?
> Any help here is greatly appreciated.
>
>
> #include "ssdp.h"
>
> void initializeWinSock () {
> WSADATA jnk;
>
> WSAStartup(WINSOCK_VERSION, &jnk);
> //Hopefully we are ready to start now.
>
> }
>
> void cleanWinSock() {
> WSACleanup();
> }
>
> int skt;
>
> char * geterrormsg() {
> LPVOID lpMsgBuf;
> static char buff[1024];
> int error = WSAGetLastError();
> if (error == WSAENOPROTOOPT) printf("Winsock doesnt support this
> option");
> FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
> FORMAT_MESSAGE_FROM_SYSTEM |
> FORMAT_MESSAGE_IGNORE_INSERTS,
> NULL,
> error,
> 0,//MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
> (LPTSTR) &lpMsgBuf, 0,NULL );
>
>
> sprintf(buff,"%d-%s",error,lpMsgBuf);
>
>
> return (char *)buff;
>
>
> }
>
> int sendRequest() {
> int status;
> struct sockaddr_in a, b, c;
> unsigned char ttl = 1; //Only hop at the moment in LAN :)
> int slen = sizeof (c);
> char buff [4096];
> int len;
>
> memset (buff,0,4096);
> strcat(buff,"M-SEARCH * HTTP/1.1\r\n");
> strcat(buff,"HOST: 239.255.255.250:1900\r\n");
> strcat(buff,"MAN: \"ssdp:discover\"\r\n");
> strcat(buff,"ST:
> urn:dslforum-org:service:InternetGatewayDevice:1\r\n");
> strcat(buff,"MX: 10\r\n\r\n");
>
> len = strlen(buff);
> skt = socket (AF_INET, SOCK_DGRAM, 0);
> if (skt == -1) {perror ("socket");return -1;}
>
> a.sin_family = AF_INET;
> a.sin_port = htons(PORT);
> a.sin_addr.s_addr = htonl(INADDR_ANY);
> int one = 1;
> setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one));
> status = bind (skt,(const struct sockaddr*)&a,sizeof (a));
> if (status == -1 ) {closesocket(skt); perror("bind"); return -1;}
>
> b.sin_family = AF_INET;
> b.sin_port = htons(PORT);
> b.sin_addr.s_addr = htonl(0xEFFFFFFA);
> status = setsockopt (skt,SOL_SOCKET,SO_BROADCAST,(char
> *)&one,sizeof(one));
> if (status == 0) {
> status = sendto (skt,buff, len, 0, (const struct sockaddr *)&b,
> sizeof(b));
> printf("Sending %s\n", buff);
> }
>
> struct ip_mreq mreq;
> mreq.imr_interface.s_addr = htonl(INADDR_ANY);
> mreq.imr_multiaddr.s_addr = htonl(0xEFFFFFFA);
>
> ttl = 1;
> status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_LOOP,(const char
> *)&ttl,sizeof(ttl));
> ttl =1;
> status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_TTL,(const char
> *)&ttl,sizeof(ttl));
> status = setsockopt(skt,IPPROTO_IP,IP_MULTICAST_IF,(const char
> *)&mreq.imr_interface.s_addr,sizeof(struct sockaddr_in));
> status = setsockopt(skt,IPPROTO_IP,IP_ADD_MEMBERSHIP,(const char
> *)&mreq,sizeof(mreq));
> if (status == -1) {printf("The error msg = %s" , geterrormsg());
> return -1;}
>
> len = 4096;
> while(1) {
> slen = sizeof (c);
> memset (buff,0,4096);
> recvfrom (skt, buff, len, 0, (struct sockaddr *)&c, &slen);
> printf("The received IP is %s\n",inet_ntoa(c.sin_addr));printf("The
> message is %s\r\n", buff);
> memset (buff,0,4096);
> }
>
> return 0;
> }
>
> int main() {
> initializeWinSock();
> sendRequest();
> cleanWinSock();
> return 0;
> }
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

Providing the sample response I got from wag54g without the firmware
upgrade:

The received IP is 192.168.1.1
The message is NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=86400
LOCATION: http://192.168.1.1:51679/devicedesc.xml
NT: uuid:739f75f0-a90c-4e42-ac21-001217BC390E
NTS: ssdp:alive
SERVER: Linux/2.4.17_mvl21-malta-mips_fp_le UPnP/1.0 Server/1.0
USN: uuid:739f75f0-a90c-4e42-ac21-001217BC390E


The received IP is 192.168.1.1
The message is NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=86400
LOCATION: http://192.168.1.1:51679/devicedesc.xml
NT: urn:dslforum-org:service:WANDSLLinkConfig:1
NTS: ssdp:alive
SERVER: Linux/2.4.17_mvl21-malta-mips_fp_le UPnP/1.0 Server/1.0
USN:
uuid:739f75f0-a90c-4e42-ac21-001217BC390E::urn:dslforum-org:service:WANDSLLinkConfig:1


The received IP is 192.168.1.1
The message is NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=86400
LOCATION: http://192.168.1.1:51679/devicedesc.xml
NT: urn:dslforum-org:service:WANPPPConnection:1
NTS: ssdp:alive
SERVER: Linux/2.4.17_mvl21-malta-mips_fp_le UPnP/1.0 Server/1.0
USN:
uuid:739f75f0-a90c-4e42-ac21-001217BC390E::urn:dslforum-org:service:WANPPPConnection:1