Esempio n. 1
0
void UpnpPresentationRequest(void* upnptoken, struct packetheader *packet)
{
	printf("Upnp Presentation Request: %s %s\r\n", packet->Directive,packet->DirectiveObj);
	
	/* TODO: Add Web Response Code Here... */
	printf("HOST: %x\r\n",UpnpGetLocalInterfaceToHost(upnptoken));
	
	UpnpPresentationResponse(upnptoken, "HTTP/1.0 200 OK\r\n\r\n" , 19 , 1);
}
void DB2CDS_OnBrowseSearch (struct MSL_CdsQuery *cdsQuery)
{
	struct DB2CDS_CdsQuery *front;

	front = DB2CDS_EnqueueCdsQuery
		(
		cdsQuery, 
		UpnpGetLocalInterfaceToHost(cdsQuery->UpnpToken),
		UpnpGetLocalPortNumber(cdsQuery->UpnpToken)
		);

	if (front == NULL)
	{
		sem_post(&DB2CDS_ProcessQueriesLock);
	}
}
void MSL_Helper_PopulateIpInfo(struct MSL_MediaServerObject *msl, struct MSL_CdsQuery *cdsQuery)
{
	int size, i, swapValue;

	/*
	 *	Obtain the IP address and port that received this request
	 */
	cdsQuery->RequestedOnAddress = UpnpGetLocalInterfaceToHost(cdsQuery->UpnpToken);
	cdsQuery->RequestedOnPort = UpnpGetLocalPortNumber(cdsQuery->UpnpToken);

	/*
	 *	Obtain the list of active IP addresses for this machine.
 	 *	Microstack allows us to assume that the port number
	 *	will be the same for all IP addresses.
	 */
	sem_wait(&(msl->Lock));
	cdsQuery->IpAddrListLen = msl->IpAddrListLen;
	size = (int) (sizeof(int) * cdsQuery->IpAddrListLen);
	cdsQuery->IpAddrList = (int*) malloc(size);
	memcpy(cdsQuery->IpAddrList, msl->IpAddrList, size);
	sem_post(&(msl->Lock));

	/*
	 *	Reorder the list of active IP addresses so that the
	 *	IP address for the interface that received the request
	 *	is listed first.
	 */
	if (cdsQuery->IpAddrList[0] != cdsQuery->RequestedOnAddress)
	{
		swapValue = cdsQuery->IpAddrList[0];
		cdsQuery->IpAddrList[0] = cdsQuery->RequestedOnAddress;
		for (i=1; i < cdsQuery->IpAddrListLen; i++)
		{
			if (cdsQuery->IpAddrList[i] == cdsQuery->RequestedOnAddress)
			{
				cdsQuery->IpAddrList[i] = swapValue;
				break;
			}
		}
	}
}