FreeCalypso > hg > themwi-system-sw
changeset 263:1bf989f60aa3
smpp-trx-sa: log times of enquire_link packets
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 11 Oct 2023 21:22:32 -0800 |
parents | f1c024b2b835 |
children | cdc807117841 |
files | smpp-trx-sa/Makefile smpp-trx-sa/enq_link_stat.c smpp-trx-sa/main.c smpp-trx-sa/tcpconn.c |
diffstat | 4 files changed, 56 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- /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 <sys/types.h> +#include <sys/file.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <time.h> +#include <unistd.h> + +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); +}
--- 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);