Sort of Callback Project

Hello, I would like to create a C code application that allows me to call two numbers and to put them into communication.
Is it possible with Asterisk?
Can I make a dialplan that calls the first number, transfers it into a meeting room, calls the second numbers and transfers it into the same meeting room.
Then the two numbers should be in communication. Isn’t it?

It would be very nice if someone could help me.

Thanks in advance,

Edouard

You could do the same thing with a call file or the Originate manager command.

Here is my C code :

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

#define MAX_MSG_SIZE 512
#define ASTERISK_ADDRESS “134.206.68.9 http://134.206.68.9
#define PROGRAM_ADDRESS “192.168.68.22 http://192.168.68.22
#define ASTERISK_PORT 5038
#define PROGRAM_PORT 0

int main()
{

int s;
struct sockaddr_in asteriskaddr, programaddr;
char msg[MAX_MSG_SIZE]; 

bzero((char *) &asteriskaddr, sizeof(asteriskaddr));
asteriskaddr.sin_family = AF_INET;
asteriskaddr.sin_addr.s_addr = inet_addr(ASTERISK_ADDRESS);
asteriskaddr.sin_port = htons(ASTERISK_PORT); 

bzero((char *) &programaddr, sizeof(programaddr));
programaddr.sin_family = AF_INET;
programaddr.sin_addr.s_addr = inet_addr(PROGRAM_ADDRESS);
programaddr.sin_port = htons(PROGRAM_PORT);

s = socket(AF_INET, SOCK_STREAM, 0);

bind(s,(struct sockaddr *) &programaddr, sizeof(programaddr));

connect(s,(struct sockaddr *) &asteriskaddr, sizeof(asteriskaddr));


char *message1 = "Action: Login\r\nUsername: mark\r\nSecret: mysecret\r\nActionID: 1\r\n\r\n";
send(s,message1,strlen(message1),0);

char *message2 = "Action: Command\r\nCommand: dial 1000@phones\r\nActionID: 2\r\n\r\n";
send(s,message2,strlen(message2),0);

char *message3 = "Action: Redirect\r\nChannel: SIP/1000\r\nContext: rooms\Exten: 600\r\nPriority: 1\r\nActionID: 3\r\n\r\n";
send(s,message3,strlen(message3),0)

char *message4 = "Action: Command\r\nCommand: dial 2000@phones\r\nActionID: 4\r\n\r\n";
send(s,message4,strlen(message4),0);

char *message5 = "Action: Redirect\r\nChannel: SIP/2000\r\nContext: rooms\Exten: 3000\r\nPriority: 1\r\nActionID: 5\r\n\r\n";
send(s,message5,strlen(message5),0);


close(s); 

return 0; 

}

With my configuration files :

[color=blue]meetme.conf :[/color]
[rooms]
conf => 600

[color=blue]extension.conf[/color]
[phones]
include => rooms
exten => 1000,1,Dial(SIP/1000)
exten => 1000,n,Hangup()

exten => 2000,1,Dial(SIP/2000)
exten => 2000,n,Hangup()

[rooms]
include => rooms
exten => 600,1,MeetMe(600)

The problem comes from the MeetMe() in the redirection.

How would you do ?

Why do you even need a meeting room? It is a call between 2 parties. Look at sample.call in your asterisk source directory. Also read here:
voip-info.org/wiki-Asterisk+auto-dial+out

just create a .call file and move it into the asterisk outgoing spool folder and you are done. it can be done in just a few lines of script.

Thank you very much ! Merci beaucoup !
I have done the “Originate solution”, it was easier for what I wanted to do.
Here is the solution (a few lines script !) :

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

#define MAX_MSG_SIZE 512
#define ASTERISK_ADDRESS “134.206.68.9 http://134.206.68.9
#define PROGRAM_ADDRESS “192.168.68.22 http://192.168.68.22
#define ASTERISK_PORT 5038
#define PROGRAM_PORT 0

int main()
{

int s;
struct sockaddr_in asteriskaddr, programaddr;
char msg[MAX_MSG_SIZE]; 

bzero((char *) &asteriskaddr, sizeof(asteriskaddr));
asteriskaddr.sin_family = AF_INET;
asteriskaddr.sin_addr.s_addr = inet_addr(ASTERISK_ADDRESS);
asteriskaddr.sin_port = htons(ASTERISK_PORT); 

bzero((char *) &programaddr, sizeof(programaddr));
programaddr.sin_family = AF_INET;
programaddr.sin_addr.s_addr = inet_addr(PROGRAM_ADDRESS);
programaddr.sin_port = htons(PROGRAM_PORT);

s = socket(AF_INET, SOCK_STREAM, 0);

bind(s,(struct sockaddr *) &programaddr, sizeof(programaddr));

connect(s,(struct sockaddr *) &asteriskaddr, sizeof(asteriskaddr));


char *message1 = "Action: Login\r\nUsername: mark\r\nSecret: mysecret\r\nActionID: 1\r\n\r\n";
send(s,message1,strlen(message1),0);
		
char *message2 = "Action: Originate\r\nChannel: SIP/1000\r\nContext: phones\r\nExten: 2000\r\nPriority: 1\r\nActionID: 2\r\n\r\n";
send(s,message2,strlen(message2),0);


close(s); 

return 0; 

}

With extensions.conf :

[phones]
exten => 1000,1,dial(SIP/1000)
exten => 2000,1,dial(SIP/2000)