42 #include <sys/types.h>
43 #include <sys/socket.h>
52 #include <arpa/inet.h>
64 #define AST_API_MODULE
67 #define DEFAULT_COPS_PORT "2126"
69 #define COPS_HEADER_SIZE 8
70 #define COPS_OBJECT_HEADER_SIZE 4
71 #define GATE_SET_OBJ_SIZE 144
72 #define GATEID_OBJ_SIZE 8
73 #define GATE_INFO_OBJ_SIZE 24
75 #define PKTCCOPS_SCOMMAND_GATE_ALLOC 1
76 #define PKTCCOPS_SCOMMAND_GATE_ALLOC_ACK 2
77 #define PKTCCOPS_SCOMMAND_GATE_ALLOC_ERR 3
78 #define PKTCCOPS_SCOMMAND_GATE_SET 4
79 #define PKTCCOPS_SCOMMAND_GATE_SET_ACK 5
80 #define PKTCCOPS_SCOMMAND_GATE_SET_ERR 6
81 #define PKTCCOPS_SCOMMAND_GATE_INFO 7
82 #define PKTCCOPS_SCOMMAND_GATE_INFO_ACK 8
83 #define PKTCCOPS_SCOMMAND_GATE_INFO_ERR 9
84 #define PKTCCOPS_SCOMMAND_GATE_DELETE 10
85 #define PKTCCOPS_SCOMMAND_GATE_DELETE_ACK 11
86 #define PKTCCOPS_SCOMMAND_GATE_DELETE_ERR 12
87 #define PKTCCOPS_SCOMMAND_GATE_OPEN 13
88 #define PKTCCOPS_SCOMMAND_GATE_CLOSE 14
159 static uint16_t t1 = 250;
160 static uint16_t t7 = 200;
161 static uint16_t t8 = 300;
162 static uint32_t keepalive = 60;
173 static struct cops_gate *
cops_gate_cmd(
int cmd, struct cops_cmts *cmts, uint16_t trid, uint32_t mta, uint32_t actcount,
float bitrate, uint32_t psize, uint32_t ssip, uint16_t ssport, struct cops_gate *gate);
192 *(res + 2) = (char) gs->
flags;
195 *((uint32_t *) (res + 4)) = gs->
srcip;
196 *((uint32_t *) (res + 8)) = gs->
dstip;
198 *((uint16_t *) (res + 12)) = gs->
srcp;
199 *((uint16_t *) (res + 14)) = gs->
dstp;
206 *((uint16_t *) (res + 20)) = gs->
t1;
210 *((uint16_t *) (res + 24)) = gs->
t7;
211 *((uint16_t *) (res + 26)) = gs->
t8;
213 *((uint32_t *) (res + 28)) = gs->
r;
214 *((uint32_t *) (res + 32)) = gs->
b;
215 *((uint32_t *) (res + 36)) = gs->
p;
216 *((uint32_t *) (res + 40)) = gs->
m;
217 *((uint32_t *) (res + 44)) = gs->
mm;
218 *((uint32_t *) (res + 48)) = gs->
rate;
219 *((uint32_t *) (res + 52)) = gs->
s;
224 uint32_t mtahost, uint32_t actcount,
float rate, uint32_t psizegateid,
225 uint32_t ssip, uint16_t ssport, uint32_t gateid,
struct cops_cmts *cmts)
237 *((uint16_t *) (p + offset)) = htons(trid);
247 *((uint32_t *) (p + offset)) = htonl(mtahost);
256 *((uint32_t *) (p + offset)) = htonl(gateid);
269 *((uint32_t *) (p + offset)) = htonl(actcount);
278 gs.
srcip = htonl(ssip);
279 gs.
dstip = htonl(mtahost);
280 gs.
srcp = htons(ssport);
284 gs.
t1 = htons(cmts->
t1);
285 gs.
t7 = htons(cmts->
t7);
286 gs.
t8 = htons(cmts->
t8);
290 gs.
m = htonl((uint32_t) psizegateid);
291 gs.
mm = htonl((uint32_t) psizegateid);
308 gs.
srcip = htonl(mtahost);
309 gs.
dstip = htonl(ssip);
311 gs.
dstp = htons(ssport);
329 struct pktcobj *pobject = NULL;
330 uint16_t *ubuf = (uint16_t *) buf;
338 recmsg->
opcode = *(buf + 1);
339 recmsg->
clienttype = ntohs(*((uint16_t *) (buf + 2)));
340 recmsg->
length = ntohl(*((uint32_t *) (buf + 4)));
353 while (len < recmsg->
length) {
364 pobject = pobject->
next;
366 pobject->
next = NULL;
369 ast_debug(3,
"Too short object header len: %i\n", lent);
373 pobject->
length = ntohs(*ubuf);
374 pobject->
cnum = *(buf + 2);
375 pobject->
ctype = *(buf + 3);
381 ast_debug(3,
"Too short object content len: %i\n", lent);
409 *(buf + 1) = sendmsg->
opcode;
410 *((uint16_t *)(buf + 2)) = htons(sendmsg->
clienttype);
411 *((uint32_t *)(buf + 4)) = htonl(sendmsg->
length);
413 if (sendmsg->
msg != NULL) {
415 }
else if (sendmsg->
object != NULL) {
417 pobject = sendmsg->
object;
418 while(pobject != NULL) {
425 *(uint16_t *) (buf + bufpos) = htons(pobject->
length);
426 *(buf + bufpos + 2) = pobject->
cnum;
427 *(buf + bufpos + 3) = pobject->
ctype;
433 memcpy((buf + bufpos + 4), pobject->
contents, pobject->
length - 4);
434 bufpos += pobject->
length;
435 pobject = pobject->
next;
440 #ifdef HAVE_MSG_NOSIGNAL
441 #define SENDFLAGS MSG_NOSIGNAL | MSG_DONTWAIT
443 #define SENDFLAGS MSG_DONTWAIT
460 while (p->
object != NULL) {
471 struct cops_gate *gate, uint32_t
mta, uint32_t actcount,
float bitrate,
472 uint32_t psize, uint32_t ssip, uint16_t ssport,
481 ast_debug(3,
"------- gate modify gateid 0x%x ssip: 0x%x\n", gate->
gateid, ssip);
486 if ((gate =
cops_gate_cmd(cmd, NULL, cops_trid++, mta, actcount, bitrate, psize, ssip, ssport, gate))) {
487 ast_debug(3,
"COPS: Allocating gate for mta: 0x%x\n", mta);
492 ast_debug(3,
"COPS: Couldn't allocate gate for mta: 0x%x\n", mta);
498 uint16_t
trid, uint32_t mta, uint32_t actcount,
float bitrate,
499 uint32_t psize, uint32_t ssip, uint16_t ssport,
struct cops_gate *gate)
503 struct cops_ippool *ippool;
516 if (mta >= ippool->
start && mta <= ippool->
stop) {
538 new->checked = time(NULL);
539 new->allocated = time(NULL);
541 new->got_dq_gi = NULL;
542 new->gate_remove = NULL;
543 new->gate_open = NULL;
544 new->tech_pvt = NULL;
637 cops_construct_gate(cmd, gateset->
object->
next->
next->
next->
contents, trid, mta, actcount, bitrate, psize, ssip, ssport, gate->
gateid, cmts);
640 cops_construct_gate(cmd, gateset->
object->
next->
next->
next->
contents, trid, mta, actcount, bitrate, psize, ssip, ssport, 0, cmts);
653 int s, sfd = -1, flags;
654 struct addrinfo hints;
656 struct addrinfo *result;
657 #ifdef HAVE_SO_NOSIGPIPE
661 memset(&hints, 0,
sizeof(
struct addrinfo));
663 hints.ai_family = AF_UNSPEC;
664 hints.ai_socktype = SOCK_STREAM;
666 hints.ai_protocol = 0;
668 s = getaddrinfo(host, port, &hints, &result);
674 for (rp = result; rp != NULL; rp = rp->ai_next) {
675 sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
679 flags = fcntl(sfd, F_GETFL);
680 fcntl(sfd, F_SETFL, flags | O_NONBLOCK);
681 #ifdef HAVE_SO_NOSIGPIPE
682 setsockopt(sfd, SOL_SOCKET, SO_NOSIGPIPE, &trueval,
sizeof(trueval));
684 connect(sfd, rp->ai_addr, rp->ai_addrlen);
689 freeaddrinfo(result);
691 ast_debug(3,
"Connecting to cmts: %s:%s\n", host, port);
695 #define PKTCCOPS_DESTROY_CURRENT_GATE \
696 AST_LIST_REMOVE_CURRENT(list); \
697 if (gate->gate_remove) { \
698 gate->gate_remove(gate); \
705 struct copsmsg *recmsg, *sendmsg;
706 struct copsmsg recmsgb, sendmsgb;
707 struct pollfd *pfds = NULL, *tmp;
712 uint16_t snst, sobjlen, scommand, recvtrid, actcount, reason, subreason;
713 uint32_t
gateid, subscrid, pktcerror;
714 time_t last_exec = 0;
727 if (last_exec != time(NULL)) {
737 if (!(tmp =
ast_realloc(pfds, (nfds + 1) *
sizeof(*pfds)))) {
741 pfds[nfds].fd = cmts->
sfd;
742 pfds[nfds].events = POLLIN;
743 pfds[nfds].revents = 0;
750 if (!(tmp =
ast_realloc(pfds, (nfds + 1) *
sizeof(*pfds)))) {
754 pfds[nfds].fd = cmts->
sfd;
755 pfds[nfds].events = POLLIN;
756 pfds[nfds].revents = 0;
764 if (last_exec != time(NULL)) {
765 last_exec = time(NULL);
771 gate->
trid = cops_trid++;
781 gate->
trid = cops_trid++;
795 if ((res =
ast_poll(pfds, nfds, 1000))) {
802 ast_debug(3,
"COPS: got from %s:\n Header: versflag=0x%.2x opcode=%i clienttype=0x%.4x msglength=%u\n",
805 if (recmsg->
object != NULL) {
807 while (pobject != NULL) {
809 if (recmsg->
opcode == 1 && pobject->
cnum == 1 && pobject->
ctype == 1 ) {
814 }
else if (pobject->
cnum == 9 && pobject->
ctype == 1) {
825 sobjlen = ntohs(*((uint16_t *) sobjp));
826 snst = ntohs(*((uint16_t *) (sobjp + 2)));
827 ast_debug(3,
" S-Num S-type: 0x%.4x len: %i\n", (
unsigned)snst, sobjlen);
828 if (snst == 0x0101 ) {
829 recvtrid = ntohs(*((uint16_t *) (sobjp + 4)));
830 scommand = ntohs(*((uint16_t *) (sobjp + 6)));
831 ast_debug(3,
" Transaction Identifier command: %i trid %i\n", scommand, recvtrid);
832 }
else if (snst == 0x0201) {
833 subscrid = ntohl(*((uint32_t *) (sobjp + 4)));
834 ast_debug(3,
" Subscriber ID: 0x%.8x\n", subscrid);
835 }
else if (snst == 0x0301) {
836 gateid = ntohl(*((uint32_t *) (sobjp + 4)));
837 ast_debug(3,
" Gate ID: 0x%x 0x%.8x\n", gateid, gateid);
838 }
else if (snst == 0x0401) {
839 actcount = ntohs(*((uint16_t *) (sobjp + 6)));
840 ast_debug(3,
" Activity Count: %i\n", actcount);
841 }
else if (snst == 0x0901) {
842 pktcerror = ntohl(*((uint32_t *) (sobjp + 4)));
843 ast_debug(3,
" PKTC Error: 0x%.8x\n", pktcerror);
844 }
else if (snst == 0x0d01) {
845 reason = ntohs(*((uint16_t *) (sobjp + 4)));
846 subreason = ntohs(*((uint16_t *) (sobjp + 6)));
847 ast_debug(3,
" Reason: %d Subreason: %d\n", reason, subreason);
856 if (gate->
cmts == cmts && gate->
gateid == gateid) {
858 ast_debug(3,
"COPS Gate Close Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
868 ast_debug(3,
"COPS Gate Open Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
871 ast_debug(3,
"Calling GATE-OPEN callback function\n");
884 if (gate->
cmts == cmts && gate->
trid == recvtrid) {
888 ast_debug(3,
"COPS Gate Set Ack Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
895 ast_debug(3,
"COPS Gate Set Error TrId: %i ErrorCode: 0x%.8x CMTS: %s\n ", recvtrid, pktcerror, cmts->
name);
903 ast_debug(3,
"COPS Gate Info Ack Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
905 ast_debug(3,
"COPS Gate Info Error Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
909 ast_debug(3,
"COPS Gate Deleted Gate ID: 0x%x TrId: %i CMTS: %s\n", gateid, recvtrid, cmts->
name);
921 pobject = pobject->
next;
941 }
else if (recmsg->
opcode == 9) {
942 ast_debug(3,
"COPS: Keepalive Request got echoing back %s\n", cmts->
name);
971 if (gate->
cmts == cmts) {
991 pthread_testcancel();
1005 if (pktccops_thread == pthread_self()) {
1012 pthread_kill(pktccops_thread, SIGURG);
1027 static char *cfg =
"res_pktccops.conf";
1031 struct cops_ippool *new_ippool;
1035 uint16_t t1_temp, t7_temp, t8_temp;
1036 uint32_t keepalive_temp;
1037 unsigned int a,b,c,d,e,
f,g,h;
1045 if (!strcmp(cat,
"general")) {
1047 if (!strcasecmp(v->
name,
"t1")) {
1048 t1 = atoi(v->
value);
1049 }
else if (!strcasecmp(v->
name,
"t7")) {
1050 t7 = atoi(v->
value);
1051 }
else if (!strcasecmp(v->
name,
"t8")) {
1052 t8 = atoi(v->
value);
1053 }
else if (!strcasecmp(v->
name,
"keepalive")) {
1054 keepalive = atoi(v->
value);
1055 }
else if (!strcasecmp(v->
name,
"gateinfoperiod")) {
1057 }
else if (!strcasecmp(v->
name,
"gatetimeout")) {
1073 if (!strcasecmp(v->
name,
"host")) {
1075 }
else if (!strcasecmp(v->
name,
"port")) {
1077 }
else if (!strcasecmp(v->
name,
"t1")) {
1078 t1_temp = atoi(v->
value);
1079 }
else if (!strcasecmp(v->
name,
"t7")) {
1080 t7_temp = atoi(v->
value);
1081 }
else if (!strcasecmp(v->
name,
"t8")) {
1082 t8_temp = atoi(v->
value);
1083 }
else if (!strcasecmp(v->
name,
"keepalive")) {
1084 keepalive_temp = atoi(v->
value);
1085 }
else if (!strcasecmp(v->
name,
"pool")) {
1094 if (!strcmp(cmts->
name, cat)) {
1131 if (!strcasecmp(v->
name,
"pool")) {
1132 if (sscanf(v->
value,
"%3u.%3u.%3u.%3u %3u.%3u.%3u.%3u", &a, &b, &c, &d, &e, &f, &g, &h) == 8) {
1133 new_ippool =
ast_calloc(1,
sizeof(*new_ippool));
1138 new_ippool->
start = a << 24 | b << 16 | c << 8 | d;
1139 new_ippool->
stop = e << 24 | f << 16 | g << 8 | h;
1140 new_ippool->
cmts = cmts;
1161 e->
command =
"pktccops show cmtses";
1163 "Usage: pktccops show cmtses\n"
1164 " List PacketCable COPS CMTSes.\n";
1171 ast_cli(a->
fd,
"%-16s %-24s %-12s %7s\n",
"Name ",
"Host ",
"Status ",
"KA timer ");
1172 ast_cli(a->
fd,
"%-16s %-24s %-12s %7s\n",
"------------",
"--------------------",
"----------",
"-----------");
1176 if (cmts->
state == 2) {
1178 katimer = (int) (time(NULL) - cmts->
katimer);
1179 }
else if (cmts->
state == 1) {
1184 ast_cli(a->
fd,
"%-16s %-15s:%-8s %-12s %-7d\n", cmts->
name, cmts->
host, cmts->
port, statedesc, katimer);
1193 char state_desc[16];
1197 e->
command =
"pktccops show gates";
1199 "Usage: pktccops show gates\n"
1200 " List PacketCable COPS GATEs.\n";
1207 ast_cli(a->
fd,
"%-16s %-12s %-12s %-10s %-10s %-10s\n" ,
"CMTS",
"Gate-Id",
"MTA",
"Status",
"AllocTime",
"CheckTime");
1208 ast_cli(a->
fd,
"%-16s %-12s %-12s %-10s %-10s %-10s\n" ,
"--------------" ,
"----------",
"----------",
"--------",
"--------",
"--------\n");
1240 struct cops_ippool *ippool;
1246 e->
command =
"pktccops show pools";
1248 "Usage: pktccops show pools\n"
1249 " List PacketCable COPS ip pools of MTAs.\n";
1256 ast_cli(a->
fd,
"%-16s %-18s %-7s\n",
"Start ",
"Stop ",
"CMTS ");
1257 ast_cli(a->
fd,
"%-16s %-18s %-7s\n",
"----------",
"----------",
"--------");
1260 snprintf(start,
sizeof(start),
"%3u.%3u.%3u.%3u", ippool->
start >> 24, (ippool->
start >> 16) & 0x000000ff, (ippool->
start >> 8) & 0x000000ff, ippool->
start & 0x000000ff);
1262 snprintf(stop,
sizeof(stop),
"%3u.%3u.%3u.%3u", ippool->
stop >> 24, (ippool->
stop >> 16) & 0x000000ff, (ippool->
stop >> 8) & 0x000000ff, ippool->
stop & 0x000000ff);
1279 e->
command =
"pktccops gatedel";
1281 "Usage: pktccops gatedel <cmts> <gateid>\n"
1282 " Send Gate-Del to cmts.\n";
1293 if (!strcmp(cmts->
name, a->
argv[2])) {
1305 if (!sscanf(a->
argv[3],
"%x", &gateid)) {
1306 ast_cli(a->
fd,
"bad gate specification (%s)\n", a->
argv[3]);
1313 if (gate->
gateid == gateid && gate->
cmts == cmts) {
1333 unsigned int an,bn,cn,dn;
1339 e->
command =
"pktccops gateset";
1341 "Usage: pktccops gateset <cmts> <mta> <acctcount> <bitrate> <packet size> <switch ip> <switch port>\n"
1342 " Send Gate-Set to cmts.\n";
1351 if (!strcmp(a->
argv[2],
"null")) {
1356 if (!strcmp(cmts->
name, a->
argv[2])) {
1370 if (sscanf(a->
argv[3],
"%3u.%3u.%3u.%3u", &an, &bn, &cn, &dn) != 4) {
1371 ast_cli(a->
fd,
"MTA specification (%s) does not look like an ipaddr\n", a->
argv[3]);
1374 mta = an << 24 | bn << 16 | cn << 8 | dn;
1376 if (sscanf(a->
argv[7],
"%3u.%3u.%3u.%3u", &an, &bn, &cn, &dn) != 4) {
1377 ast_cli(a->
fd,
"SSIP specification (%s) does not look like an ipaddr\n", a->
argv[7]);
1380 ssip = an << 24 | bn << 16 | cn << 8 | dn;
1390 e->
command =
"pktccops set debug {on|off}";
1392 "Usage: pktccops set debug {on|off}\n"
1393 " Turn on/off debuging\n";
1401 if (!strncasecmp(a->
argv[e->
args - 1],
"on", 2)) {
1403 ast_cli(a->
fd,
"PktcCOPS Debugging Enabled\n");
1404 }
else if (!strncasecmp(a->
argv[e->
args - 1],
"off", 2)) {
1406 ast_cli(a->
fd,
"PktcCOPS Debugging Disabled\n");
1442 if (cmts->
sfd > 0) {
1458 struct cops_ippool *ippool;
1484 pthread_cancel(pktccops_thread);
1485 pthread_kill(pktccops_thread, SIGURG);
1486 pthread_join(pktccops_thread, NULL);
#define AST_CLI_DEFINE(fn, txt,...)
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static const char config[]
static int pktccops_add_ippool(struct cops_ippool *ippool)
static int load_module(void)
static int cops_sendmsg(int sfd, struct copsmsg *sendmsg)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
int(* gate_remove)(struct cops_gate *gate)
struct cops_gate * ast_pktccops_gate_alloc(int cmd, struct cops_gate *gate, uint32_t mta, uint32_t actcount, float bitrate, uint32_t psize, uint32_t ssip, uint16_t ssport, int(*const got_dq_gi)(struct cops_gate *gate), int(*const gate_remove)(struct cops_gate *gate))
#define PKTCCOPS_SCOMMAND_GATE_SET_ERR
static int cops_connect(char *host, char *port)
#define PKTCCOPS_SCOMMAND_GATE_DELETE
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
static int gateinfoperiod
Time-related functions and macros.
static ast_mutex_t pktccops_lock
static pthread_t pktccops_thread
static void cops_freemsg(struct copsmsg *p)
descriptor for a cli entry.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
#define PKTCCOPS_DESTROY_CURRENT_GATE
Structure for variables, used for configurations and for channel variables.
Configuration File Parser.
int(* gate_open)(struct cops_gate *gate)
static struct ast_cli_entry cli_pktccops[]
static char * pktccops_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_mutex_lock(a)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static char * pktccops_gatedel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define PKTCCOPS_SCOMMAND_GATE_INFO_ACK
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
void ast_cli(int fd, const char *fmt,...)
struct cops_cmts::@344 list
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
static struct cops_gate * cops_gate_cmd(int cmd, struct cops_cmts *cmts, uint16_t trid, uint32_t mta, uint32_t actcount, float bitrate, uint32_t psize, uint32_t ssip, uint16_t ssport, struct cops_gate *gate)
int args
This gets set in ast_cli_register()
#define PKTCCOPS_SCOMMAND_GATE_INFO_ERR
#define PKTCCOPS_SCOMMAND_GATE_DELETE_ACK
#define ast_pthread_create_background(a, b, c, d)
#define PKTCCOPS_SCOMMAND_GATE_OPEN
#define ast_debug(level,...)
Log a DEBUG message.
static int unload_module(void)
#define GATE_SET_OBJ_SIZE
General Asterisk PBX channel definitions.
static uint32_t ftoieeef(float n)
#define ast_config_load(filename, flags)
Load a config file.
static uint16_t cops_constructgatespec(struct gatespec *gs, char *res)
#define AST_PTHREADT_NULL
#define ast_poll(a, b, c)
#define PKTCCOPS_SCOMMAND_GATE_SET
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define COPS_OBJECT_HEADER_SIZE
#define GATE_INFO_OBJ_SIZE
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Core PBX routines and definitions.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
static int load_pktccops_config(void)
#define PKTCCOPS_SCOMMAND_GATE_SET_ACK
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int ast_poll_fd_index(struct pollfd *haystack, int nfds, int needle)
Shortcut for conversion of FD_ISSET to poll(2)-based.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static uint16_t cops_trid
static void * do_pktccops(void *data)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Structure used to handle boolean flags.
#define PKTCCOPS_SCOMMAND_GATE_INFO
#define PKTCCOPS_SCOMMAND_GATE_CLOSE
Support for logging to various files, console and syslog Configuration in file logger.conf.
static char * pktccops_show_pools(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * pktccops_gateset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static char * pktccops_show_cmtses(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int(* got_dq_gi)(struct cops_gate *gate)
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
#define ast_realloc(a, b)
#define AST_PTHREADT_STOP
static int reload_module(void)
static void pktccops_unregister_cmtses(void)
Options provided by main asterisk program.
static void pktccops_unregister_ippools(void)
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_OPTIONAL_API_NAME(name)
struct ast_variable * next
#define DEFAULT_COPS_PORT
static int cops_getmsg(int sfd, struct copsmsg *recmsg)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_MUTEX_DEFINE_STATIC(mutex)
static int restart_pktc_thread(void)
static uint16_t cops_construct_gate(int cmd, char *p, uint16_t trid, uint32_t mtahost, uint32_t actcount, float rate, uint32_t psizegateid, uint32_t ssip, uint16_t ssport, uint32_t gateid, struct cops_cmts *cmts)
static char * pktccops_show_gates(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_mutex_unlock(a)