amiws 2.2.1
|
AMI (Asterisk Management Interface) messages read/create functions interface. AMI packet is implemented as linked list of headers. More...
#include <stdio.h>
#include <syslog.h>
#include <yaml.h>
#include "amipack.h"
#include "config.h"
#include "frozen.h"
#include "mongoose.h"
Go to the source code of this file.
Classes | |
struct | amiws_config |
struct | amiws_conn |
Macros | |
#define | DEFAULT_CONF_FILE "/etc/amiws.yaml" |
#define | DEFAULT_WEB_ROOT "./web_root" |
#define | DEFAULT_LOG_LEVEL LOG_INFO |
#define | DEFAULT_LOG_FACILITY LOG_SYSLOG |
#define | DEFAULT_WEBSOCK_PORT 8000 |
#define | POLL_SLEEP 1000 |
#define | intval(val) |
#define | macro_init_conf(conf) |
#define | macro_init_conn(conn) |
Functions | |
void | amiws_init (struct amiws_config *conf) |
void | amiws_connect_ami_server (struct amiws_conn *conn) |
void | amiws_destroy () |
void | amiws_loop () |
void | ami_ev_handler (struct mg_connection *nc, int ev, void *ev_data) |
void | websock_ev_handler (struct mg_connection *nc, int ev, void *ev_data) |
void | websock_send (struct mg_connection *nc, const char *json) |
void | ami_login (struct mg_connection *nc, struct amiws_conn *conn) |
char * | amipack_to_json (const char *buf, int len, struct amiws_conn *conn) |
struct amiws_config * | read_conf (const char *filename) |
int | scan_amipack (const char *pack, size_t len) |
void | free_conf (struct amiws_config *conf) |
void | set_conf_param (struct amiws_config *conf, char *key, char *value) |
void | set_conn_param (struct amiws_conn *conn, char *key, char *value) |
AMI (Asterisk Management Interface) messages read/create functions interface. AMI packet is implemented as linked list of headers.
AMI (Asterisk Management Interface) connector and websocket remote interface functions.
amiws – Library with functions for read/create AMI packets Copyright (C) 2017, Stas Kobzar stask.nosp@m.obza.nosp@m.r@mod.nosp@m.ulis.nosp@m..ca
This file is part of amiws.
amiws is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
amiws is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with amiws. If not, see http://www.gnu.org/licenses/.
amiws – Library with functions for read/create AMI packets Copyright (C) 2017, Stas Kobzar stask.nosp@m.obza.nosp@m.r@mod.nosp@m.ulis.nosp@m..ca
This file is part of amiws.
amiws is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
amiws is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with amiws. If not, see http://www.gnu.org/licenses/.
#define DEFAULT_CONF_FILE "/etc/amiws.yaml" |
Default configuration path.
#define DEFAULT_LOG_FACILITY LOG_SYSLOG |
Default log facility as in syslog.h
#define DEFAULT_LOG_LEVEL LOG_INFO |
Default log level as in syslog.h
#define DEFAULT_WEB_ROOT "./web_root" |
Default path to web root with static HTML content.
#define DEFAULT_WEBSOCK_PORT 8000 |
Default WebSock and HTTP port.
#define intval | ( | val | ) |
Convert string to int
#define macro_init_conf | ( | conf | ) |
Macro to initilize configuration structure.
#define macro_init_conn | ( | conn | ) |
Macro to initilize AMI connection.
#define POLL_SLEEP 1000 |
Polling interval.
void ami_ev_handler | ( | struct mg_connection * | nc, |
int | ev, | ||
void * | ev_data ) |
Callback function for AMI connections.
nc | Connection structure. |
ev | Event ID |
ev_data | Additional data passed |
void ami_login | ( | struct mg_connection * | nc, |
struct amiws_conn * | conn ) |
Login to AMI server. Send loging Action.
nc | Connection structure. |
conn | AMI connection. |
char * amipack_to_json | ( | const char * | buf, |
int | len, | ||
struct amiws_conn * | conn ) |
Convert AMI packet to JSON string.
buf | AMI packet stream as received from connection |
len | Buffer size |
conn | AMI connection. |
void amiws_connect_ami_server | ( | struct amiws_conn * | conn | ) |
Connect to AMI server.
conn | Connection configuration structure. |
void amiws_destroy | ( | ) |
Destroy connections and free memory.
void amiws_init | ( | struct amiws_config * | conf | ) |
Initialize amiws with given configuration. Will start listening for HTTP and WebSocket and connects to AMI servers.
conf | Configuration structure. |
void amiws_loop | ( | ) |
Main amiws loop step.
void free_conf | ( | struct amiws_config * | conf | ) |
Destroy configuration structure.
conf | Configuration structure. |
struct amiws_config * read_conf | ( | const char * | filename | ) |
Read YAML configuration file.
filename | Path to file. |
int scan_amipack | ( | const char * | pack, |
size_t | len ) |
Scan stream and extract AMI packet separated with CRLF CRLF token. TCP connection is feeding packets as stream and this function will get complete packet.
pack | Char stream received from server. |
len | Stream length |
void websock_ev_handler | ( | struct mg_connection * | nc, |
int | ev, | ||
void * | ev_data ) |
Callback function for HTTP and WebSocket connections.
nc | Connection structure. |
ev | Event ID |
ev_data | Additional data passed |
void websock_send | ( | struct mg_connection * | nc, |
const char * | json ) |
Send JSON string to WebSocket.
nc | Connection structure. |
json | JSON string. |