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;
}
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;
}