Example #1
0
static mUpnpDevice *mupnp_controlpoint_createdevicefromssdkpacket(mUpnpSSDPPacket *ssdpPkt)
{
	const char *location;
	mUpnpNetURL *url;
	mUpnpDevice *dev;
	bool parseSuccess;
	
	mupnp_log_debug_l4("Entering...\n");

	location = mupnp_ssdp_packet_getlocation(ssdpPkt);
	if (mupnp_strlen(location) <= 0)
		return NULL;
			
	dev = mupnp_device_new();
	
	url = mupnp_net_url_new();
	mupnp_net_url_set(url, location);
	parseSuccess =  mupnp_device_parsedescriptionurl(dev, url);
    if (parseSuccess) {
        mupnp_device_sethttpport(dev, mupnp_net_url_getport(url));
    }
	mupnp_net_url_delete(url);
	
	if (parseSuccess == false) {
		mupnp_device_delete(dev);
		return NULL;
	}

	mupnp_device_setssdppacket(dev, ssdpPkt);

#ifndef MUPNP_OPTIMIZED_CP_MODE
	if (mupnp_controlpoint_parseservicesfordevice(dev, ssdpPkt) == false)
	{
		mupnp_device_delete(dev);
		return NULL;
	}
#endif
	
	mupnp_log_debug_l4("Leaving...\n");

	return dev;
}
Example #2
0
/**
 * Create a new event subscriber
 */
mUpnpSubscriber* mupnp_subscriber_new()
{
  mUpnpSubscriber* sub;

  mupnp_log_debug_l4("Entering...\n");

  sub = (mUpnpSubscriber*)malloc(sizeof(mUpnpSubscriber));

  if (NULL != sub) {
    mupnp_list_node_init((mUpnpList*)sub);

    sub->sid = mupnp_string_new();
    sub->ifAddr = mupnp_string_new();
    sub->deliveryURL = mupnp_net_url_new();

    mupnp_subscriber_settimeout(sub, 0);
    mupnp_subscriber_renew(sub);
    mupnp_subscriber_setnotifycount(sub, 0);
  }

  mupnp_log_debug_l4("Leaving...\n");

  return sub;
}