view smpp-send/sock_send.c @ 270:6f28a4377a99

doc/Local-short-numbers: first draft written
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 26 Nov 2023 17:08:10 -0800
parents 243ed87880a1
children
line wrap: on
line source

/*
 * This module implements local datagram socket transmission of the constructed
 * submit_sm PDU to our smpp-trx-sa daemon process.
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern char *trx_socket;

void
send_pdu_via_socket(pdu, pdulen)
	u_char *pdu;
	unsigned pdulen;
{
	struct sockaddr_un sa;
	unsigned sa_len;
	int lsock, rc;

	lsock = socket(AF_UNIX, SOCK_DGRAM, 0);
	if (lsock < 0) {
		perror("socket(AF_UNIX, SOCK_DGRAM, 0)");
		exit(1);
	}
	fill_sockaddr_un(trx_socket, &sa, &sa_len);
	rc = sendto(lsock, pdu, pdulen, 0, (struct sockaddr *) &sa, sa_len);
	if (rc != pdulen) {
		perror("send via local socket");
		exit(1);
	}
	close(lsock);
}