예제 #1
0
파일: sip.c 프로젝트: maxgrind/sipmore
void SipProcess(osip_t* osip, char* pBuf, int size, SOCKET sock)
{
	osip_event_t *evt = osip_parse(pBuf, size); // doesn't need to be free
	int rc;

	if (evt == NULL)
	{
		OutputDebugString(TEXT("unknown message received\r\n"));
		return;
	}

	rc = osip_find_transaction_and_add_event(osip, evt);
	if (0 != rc)
	{
		OutputDebugString(TEXT("this event has no transaction, create a new one\r\n"));
		if(evt->type == RCV_REQINVITE)
		{
			ProcessNewReqIst(osip, evt, sock);
		}
		else
		{
			ProcessNewReqNist(osip, evt, sock);
		};
	}
}
예제 #2
0
void processSipMsg()
{
	int port;
	char host[256];
	char msg[MESSAGE_MAX_LENGTH];
	int msgLen;
	osip_event_t *sipevent;
	osip_transaction_t *transaction = NULL;
	struct sockaddr_in sa;
	int status;

	if((msgLen = networkMsgRecv(sipSock,msg,MESSAGE_MAX_LENGTH,&sa)) > 0){
		printf("processSipMsg: RECEIVED MSG\n");
		printf("%s\n",msg);
		sipevent = osip_parse(msg,msgLen);
		if((sipevent==NULL)||(sipevent->sip==NULL)){
			printf("Could not parse SIP message\n");
			osip_event_free(sipevent);
			return;
		}
	}
	osip_message_fix_last_via_header(sipevent->sip,(char *)inet_ntoa(sa.sin_addr),ntohs(sa.sin_port));
	if((status = osip_find_transaction_and_add_event(osip,sipevent)) != 0){
		printf("New transaction!\n");
		if(MSG_IS_REQUEST(sipevent->sip)){
			printf("Got New Request\n");;
		}else if(MSG_IS_RESPONSE(sipevent->sip)){
			printf("Bad Message:%s\n",msg);
			osip_event_free(sipevent);
		}else{
			printf("Unsupported message:%s\n",msg);
			osip_event_free(sipevent);
		}
	}
}