sipwitch-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sipwitch-devel] Call initiation issue


From: Aymen Malik
Subject: [Sipwitch-devel] Call initiation issue
Date: Thu, 9 Aug 2012 02:42:10 -0700 (PDT)

Hi
   I am a novice in programming and networking and at a beginning stage of using exosip .I am using exosip  and sip in my project and want to generate a peer to peer session between 2 computers.I have installed sip,osip and exosip packages. I am using exosip user manual guide but when i hav run the code of call initiation from there it is resolving ip, as in wireshark i can only see packets of DNS but it is not indicating an out going packets from the caller to the callee .The code with  little bit amendments isgiven below... if  anyone can sort out whats the issue......Thanks in advance.



#include <eXosip2/eXosip.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

eXosip_event_t *je;
unsigned short Port;

void *reference(void *arg)
{
    printf("\nReferece function called"); fflush(stdout);
    for(;;) sleep(10);
}

int exoSIP_Init()
{
    int i;
    TRACE_INITIALIZE (6, stdout);
    i=eXosip_init();
    if (i!=0)
    return -1;
    i = eXosip_listen_addr (IPPROTO_UDP, NULL, Port, AF_INET, 0);
    if (i!=0)
    {
    eXosip_quit();
    fprintf (stderr, "could not initialize transport layer\n");
    return -1;
    }
    return 0;
}

int main(void)
{
    Port = 3030;
    int t=0;

    int i;
    i = exoSIP_Init();

    printf("\n------------%d",t++); fflush(stdout);
    if(i!=0) {
        printf("exoSIP_Init() returned non-zero value:");
        exit(-1);
    }
    printf("\n------------%d",t++); fflush(stdout);

    for (;;)
    {

/*        je = eXosip_event_wait (0, 50);
        eXosip_lock();
        eXosip_automatic_action ();
        eXosip_unlock();
    printf("\n------------%d",t++); fflush(stdout);
        if (je == NULL) {
            printf("\neXosip_event_wait() returned NULL\n");fflush(stdout);
            break;
        }
*/
//        if (je->type == EXOSIP_CALL_INVITE)
        {

        osip_message_t *invite;
        int i;

        char temp_ip[1000];
        char temp_str[1000];
            eXosip_guess_localip (AF_INET, temp_ip, 128);
        strcpy(temp_str,"sip:");
        strcat(temp_str,temp_ip);
        i = eXosip_call_build_initial_invite (&invite,
        "<sip:address@hidden>",
//        "sip:172.16.0.76",
//        "<sip:address@hidden>",
//        "sip:172.16.0.100",
        temp_str,
        NULL, // optionnal route header
        "This is a call for a conversation");
        if (i != 0)
        {
           
            return -1;
        }

    printf("\n------------%d",t++); fflush(stdout);
        osip_message_set_supported (invite, "100rel");
        {
            char tmp[4096];
            char localip[128];
            eXosip_guess_localip (AF_INET, localip, 128);
           
//            snprintf (tmp, 4096,
            sprintf (tmp,
            "v=0\r\n"
            "o=josua 0 0 IN IP4 %s\r\n"
            "s=conversation\r\n"
            "c=IN IP4 %s\r\n"
            "t=0 0\r\n"
            "m=audio %u RTP/AVP 0 8 101\r\n"
            "a=rtpmap:0 PCMU/8000\r\n"
            "a=rtpmap:8 PCMA/8000\r\n"
            "a=rtpmap:101 telephone-event/8000\r\n"
            "a=fmtp:101 0-11\r\n", localip, localip, Port);
            osip_message_set_body (invite, tmp, strlen (tmp));
            osip_message_set_content_type (invite, "application/sdp");
        }
//    sleep(5);
   
        eXosip_lock ();
        i = eXosip_call_send_initial_invite (invite);
    
        if (i > 0)
        {
//        eXosip_call_set_reference (i,reference);
        eXosip_call_set_reference (i,(void *)NULL);
        }
        eXosip_unlock ();
        return i;
        }
    }
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]