Bonjour,
je continue a mettre a jour ce post ça pourras toujours servir
Donc je pense presque toucher au but donc voici mon code:
Code:
/*****************************************************************************/
/*** client-socket-Asterisk.c ***/
/*** ***/
/*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <resolv.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#define PORT_TIME 13 /* "time" (not available on RedHat) */
#define PORT_FTP 5038 /* FTP connection port */
#define SERVER_ADDR "192.168.112.238" /* localhost */
#define MAXBUF "1024" /* DEF Buffer*/
#define LOGINASTERISK "username: testA" /*login connexion asterisk*/
#define PASSASTERISK "secret: MDPtestA" /*MDP connexion asterisk*/
#define ACTION "Action: login" /*Action Serv Asterisk*/
#define EVENT "Events: on" /*Action Serv Asterisk*/
int main()
{ int sockfd;
int errno;
struct sockaddr_in dest;
char buffer[1024];
int taille;
char login;
int retour;
/*---Open socket for streaming---*/
if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
{
printf("Socket open fail");
return 0;
}
/*---Initialize server address/port struct---*/
bzero(&dest, sizeof(dest));
dest.sin_family = AF_INET;
dest.sin_port = htons(PORT_FTP);
if ( inet_aton(SERVER_ADDR, &dest.sin_addr.s_addr) == 0 )
{
printf(SERVER_ADDR);
return 0;
}
/*---Connect to server---*/
if ( connect(sockfd, (struct sockaddr*)&dest, sizeof(dest)) != 0 )
{
printf("Connect fail ");
return 0;
}
/*--login-to-asterisk--*/
login = send(sockfd,ACTION,sizeof(buffer),0 );
if (retour == SOCK_STREAM){
return 0;
}
login = send(sockfd,LOGINASTERISK,sizeof(buffer),0 );
if (retour == SOCK_STREAM){
return 0;
}
login = send(sockfd,PASSASTERISK,sizeof(buffer),0 );
if (retour == SOCK_STREAM){
return 0;
}
login = send(sockfd,EVENT,sizeof(buffer),0 );
if (retour == SOCK_STREAM){
return 0;
}
/* login = send(sockfd,LOGINASTERISK,sizeof(buffer),0 );
if (retour == SOCK_STREAM){
return 0;
}*/
/*---Get "Hello?"---*/
while(1)
{
taille=recv(sockfd,& buffer,sizeof(buffer),0);
buffer[taille]='\0';
printf("%s",buffer);
}
printf("\n");
/*---Clean up---*/
printf("close connexion\n");
close(sockfd);
return 0;
}
Alors maintenant quand je lance mon application il me met un nouveau message d’erreur:
Asterisk Call Manager/1.1
Response: Error
Message: Authentication failed
Response: Error
Message: Authentication failed
ce qui me viens a l’esprit dans un premier temps est un problème de login mot de passe, mais je suis parti vérifier dans mon serv asterisk mes identifiants le chemin d’accès pour les identifiants est le suivant :
/etc/asterisk/manager.conf
voici un extrait de mon manager.conf avec mes identifiants
[testA]
secret = MDPtestA
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
permit=192.168.112.0/255.255.255.0
read = system,call,log,verbose,agent,user,config,dtmf,rep orting,cdr,dialplan
write = system,call,agent,user,config,command,reporting,or iginate
displayconnects = yes
Donc je suis toujours en pleine quête si quelqu'un i voit plus clair je suis prêt a écouter
Bonne journée.