annotate smpp-send/sock_send.c @ 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 243ed87880a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements local datagram socket transmission of the constructed
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * submit_sm PDU to our smpp-trx-sa daemon process.
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/socket.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/un.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <unistd.h>
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern char *trx_socket;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 void
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 send_pdu_via_socket(pdu, pdulen)
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 u_char *pdu;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 unsigned pdulen;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 struct sockaddr_un sa;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned sa_len;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 int lsock, rc;
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 lsock = socket(AF_UNIX, SOCK_DGRAM, 0);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (lsock < 0) {
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 exit(1);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 fill_sockaddr_un(trx_socket, &sa, &sa_len);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 rc = sendto(lsock, pdu, pdulen, 0, (struct sockaddr *) &sa, sa_len);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (rc != pdulen) {
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 perror("send via local socket");
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(1);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 close(lsock);
243ed87880a1 smpp-send: implement sending via local socket
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }