summaryrefslogtreecommitdiff
path: root/vpn/udp_extivr.c
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2012-11-28 18:40:32 +0000
committerComment <tim@gray.(none)>2012-11-28 18:40:32 +0000
commita0ab2cd35d91ba0080f9fb870d82aa90a51a0d6c (patch)
tree0e0fd44d0f07ccf1ea4a5f1e30a03e0203300321 /vpn/udp_extivr.c
parent75c277c10f206f5bf3799caa03a52f40c1c8b6cf (diff)
nearly finished except latency
Diffstat (limited to 'vpn/udp_extivr.c')
-rwxr-xr-xvpn/udp_extivr.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/vpn/udp_extivr.c b/vpn/udp_extivr.c
new file mode 100755
index 0000000..8bf706b
--- /dev/null
+++ b/vpn/udp_extivr.c
@@ -0,0 +1,109 @@
+//
+// Filename: mfe.c
+//
+#define Version "000"
+//
+// Edit date: 2010-03-30
+//
+// Facility: Asterisk
+//
+// Abstract: My First Externalivr
+//
+// Environment: Asterisk
+//
+// Author: Steven L. Edwards
+//
+// Modified by
+//
+// 000 2010-03-30 SLE Create.
+
+#include <syslog.h>
+
+#define PORT 5000
+#define IP "10.10.10.2"
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+void die(char *s)
+{
+ perror(s);
+ exit(1);
+}
+
+void signal_handler(int signum)
+{
+ switch (signum) {
+ case SIGINT:
+ printf("\nReceived interrupt signal. Exiting.\n");
+ close(sock);
+ exit(0);
+
+ default:
+ printf("\nUnknown signal received. Ignoring.\n");
+ }
+}
+
+
+int main(int argc, char **argv)
+{
+ auto char event[256];
+ auto int idx;
+
+ // Set the syslog ident
+ openlog("udp-extivr", LOG_PID, LOG_USER);
+
+ // announce ourselves
+ syslog(LOG_ERR, "Starting.");
+
+ // show how we were executed
+ idx = 0;
+ syslog(LOG_ERR, "argc = %d", argc);
+ while (idx < argc)
+ {
+ syslog(LOG_ERR
+ , "arg[%d] = \"%s\""
+ , idx
+ , argv[idx]
+ );
+ ++idx;
+ }
+
+ // this is how to send a command to asterisk
+ //printf("S,demo-congrats\n");
+ //fflush(stdout);
+
+ //create socket
+ int sock;
+ sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+ if (sock < 0) {
+ printf("Unable to create a socket: %s\n",
+ strerror(errno));
+ return 1;
+ }
+
+
+
+ // read events and transmit
+ while (NULL != fgets(in, 1, stdin))
+ {
+ if (in[0]>0) {
+ syslog(LOG_ERR, in);
+ if (sendto(fd, in, 1, 0, &si_other, slen)==-1) die("sendto()");
+ in[0]=0;
+ }
+ usleep(10000);
+ }
+
+ // Function exit
+ return(EXIT_SUCCESS); // return function status
+
+}
+// end of main()
+// (end of mfe.c) \ No newline at end of file