1

I am getting response from hue when I send the following packet from my PC.

sprintf(wrbuf,"%s","M-SEARCH* HTTP/1.0\r\n HOST: 239.255.255.250:1900\r\n MAN: \"ssdp:discover\"\r\n MX: 4\r\n ST: libhue:idl\r\n\r\n");

sendto(sd,&wrbuf,sizeof(wrbuf),0,(struct sockaddr *)&serv,(socklen_t)len);

the response is as below.

recived: HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
EXT:
LOCATION: "ipofhue:80/description.xml"
SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1
ST: upnp:rootdevice
USN: uuid:2f402f80-da50-11e1-9b23-0017880a6643::upnp:rootdevice

though if send the same packet from my openWRT router, I am not getting any response from hue.

my PC IP is 10.10.10.130, hue IP is 10.10.10.109 & my router br-lan IP is 10.10.10.254. I don't think I need to run miniupnpd from my router, because if I run it starts responding from router, I just need reply from upnp server which is running on hue hub which is I am not getting.

openwrt tool chain donot allow the M-SEARCH packet to reach wan port.it just ignore the the packet .kernel log says The IGMP message was from myself. Ignoring. Feb 4 06:18:55 user.info sysinit: The source address 172.22.xx.xx for group 239.255.255.250, is not in any valid net for upstream VIF. –

dlamblin
  • 43,965
  • 20
  • 101
  • 140
  • Does the device actually send the packet? If there's no packet sent, it's logical that the Hue doesn't respond, and you'd get the behavior you now see. – MSalters Sep 15 '14 at 14:35
  • yes the Device is actually sending packet ,the sendto is returning success.@MSalters – prallav sharma Sep 16 '14 at 04:29
  • have you verified it on the network? When things don't behave as they should, you should be more suspicious than usual. Also, does the packet on the network look different in any way when it's sent by the OpenWRT? – MSalters Sep 16 '14 at 07:05
  • @MSalters is right: fire up wireshark and make sure what you think is happening is really happening. Also, the M-SEARCH seems malformed to me: there should be a space between "M-SEARCH" and "*", and there should not be whitespace in the beginning of a line. The search target you use is not valid for UPnP. – Jussi Kukkonen Sep 16 '14 at 14:14
  • i am not find the packet containing the M-search command at Wireshark and the changes suggested by you are implemented. @jku – prallav sharma Sep 17 '14 at 10:42
  • openwrt tool chain donot allow the M-SEARCH packet to reach wan port.it just ignore the the packet .kernel log says The IGMP message was from myself. Ignoring. Feb 4 06:18:55 user.info sysinit: The source address 172.22.xx.xx for group 239.255.255.250, is not in any valid net for upstream VIF. – prallav sharma Feb 04 '15 at 06:46

1 Answers1

0

It sounds like to me that the packet is being over the Internet instead of the local LAN. I think you need to specifically bind to the BR-LAN IP before calling sendto(). For example:

int sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in sin = {};
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr("10.10.10.254");
sin.sin_port = 0;
bind(sd, (struct sockaddr *)&sin, sizeof(sin));