# HG changeset patch # User Mychaela Falconia # Date 1697088152 28800 # Node ID 1bf989f60aa34093bd2c1ba7e152f194311fdb98 # Parent f1c024b2b835bb0fad336cce2388c9218f0a075d smpp-trx-sa: log times of enquire_link packets diff -r f1c024b2b835 -r 1bf989f60aa3 smpp-trx-sa/Makefile --- a/smpp-trx-sa/Makefile Wed Oct 11 21:21:34 2023 -0800 +++ b/smpp-trx-sa/Makefile Wed Oct 11 21:22:32 2023 -0800 @@ -1,7 +1,7 @@ CC= gcc CFLAGS= -O2 PROG= smpp-trx-sa -OBJS= localsock.o log.o main.o pdu_out.o tcpconn.o +OBJS= enq_link_stat.o localsock.o log.o main.o pdu_out.o tcpconn.o LIBS= ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r f1c024b2b835 -r 1bf989f60aa3 smpp-trx-sa/enq_link_stat.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/smpp-trx-sa/enq_link_stat.c Wed Oct 11 21:22:32 2023 -0800 @@ -0,0 +1,50 @@ +/* + * This module tracks and logs the times of enquire_link packets + * from the SMPP server. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern char fmt_time[32]; + +static int status_fd, status_enable; +static char last_enq_time[32]; + +void +log_enquire_link_open(filename) + char *filename; +{ + status_fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (status_fd < 0) { + perror(filename); + exit(1); + } + status_enable = 1; +} + +static void +write_enq_link_times() +{ + char buf[128]; + + sprintf(buf, "%s\n%s\n", last_enq_time, fmt_time); + lseek(status_fd, 0, SEEK_SET); + write(status_fd, buf, strlen(buf)); +} + +void +log_enquire_link_item() +{ + if (!status_enable) + return; + if (last_enq_time[0]) + write_enq_link_times(); + strcpy(last_enq_time, fmt_time); +} diff -r f1c024b2b835 -r 1bf989f60aa3 smpp-trx-sa/main.c --- a/smpp-trx-sa/main.c Wed Oct 11 21:21:34 2023 -0800 +++ b/smpp-trx-sa/main.c Wed Oct 11 21:22:32 2023 -0800 @@ -42,9 +42,9 @@ fd_set fds; int max_fd, rc; - if (argc != 6) { + if (argc < 6 || argc > 7) { fprintf(stderr, - "usage: %s server-ip system-id password log-file socket-pathname\n", +"usage: %s server-ip system-id password log-file socket-pathname [enq-link]\n", argv[0]); exit(1); } @@ -69,6 +69,8 @@ perror(argv[4]); exit(1); } + if (argv[6]) + log_enquire_link_open(argv[6]); create_local_socket(argv[5]); max_fd = localsock; open_tcp_conn(&server_sin); diff -r f1c024b2b835 -r 1bf989f60aa3 smpp-trx-sa/tcpconn.c --- a/smpp-trx-sa/tcpconn.c Wed Oct 11 21:21:34 2023 -0800 +++ b/smpp-trx-sa/tcpconn.c Wed Oct 11 21:22:32 2023 -0800 @@ -53,6 +53,7 @@ rx_buf[7]; if (command_id == 0x15 && rx_pdu_len == 16) { send_enq_link_resp(rx_buf); + log_enquire_link_item(); return; } log_rx_pdu(rx_buf, rx_pdu_len);