annotate smpp-trx-sa/enq_link_stat.c @ 267:81958b35f74d

NANP validation: allow made-up area codes of N9X form
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 Nov 2023 15:28:09 -0800
parents 1bf989f60aa3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
263
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module tracks and logs the times of enquire_link packets
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * from the SMPP server.
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/file.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <time.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <unistd.h>
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern char fmt_time[32];
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static int status_fd, status_enable;
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static char last_enq_time[32];
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 void
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 log_enquire_link_open(filename)
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char *filename;
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 status_fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (status_fd < 0) {
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 perror(filename);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 exit(1);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 status_enable = 1;
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 static void
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 write_enq_link_times()
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 char buf[128];
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 sprintf(buf, "%s\n%s\n", last_enq_time, fmt_time);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 lseek(status_fd, 0, SEEK_SET);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 write(status_fd, buf, strlen(buf));
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 void
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 log_enquire_link_item()
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 {
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (!status_enable)
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return;
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (last_enq_time[0])
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 write_enq_link_times();
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 strcpy(last_enq_time, fmt_time);
1bf989f60aa3 smpp-trx-sa: log times of enquire_link packets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }