diff options
| author | David Troy <dave@popvox.com> | 2006-04-01 16:56:25 +0000 |
|---|---|---|
| committer | David Troy <dave@popvox.com> | 2006-04-01 16:56:25 +0000 |
| commit | ad2c8750819f7e236c0baaf7edf2affd50c9d0a0 (patch) | |
| tree | df3dc712677fb503d17b94591d8ab374d9167686 /src/include | |
| parent | 93b557bf0a56e24cd4fb3f1452c90e3e6c253e97 (diff) | |
| download | astmanproxy-ad2c8750819f7e236c0baaf7edf2affd50c9d0a0.tar.gz astmanproxy-ad2c8750819f7e236c0baaf7edf2affd50c9d0a0.tar.xz astmanproxy-ad2c8750819f7e236c0baaf7edf2affd50c9d0a0.zip | |
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@34 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/astmanproxy.h | 125 | ||||
| -rw-r--r-- | src/include/dlfcn-compat.h | 83 | ||||
| -rw-r--r-- | src/include/poll-compat.h | 101 |
3 files changed, 309 insertions, 0 deletions
diff --git a/src/include/astmanproxy.h b/src/include/astmanproxy.h new file mode 100644 index 0000000..f5718aa --- /dev/null +++ b/src/include/astmanproxy.h @@ -0,0 +1,125 @@ +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include <sys/time.h> +#include <sys/types.h> +#include <netdb.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <arpa/inet.h> +#include <signal.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdarg.h> +#include <dirent.h> +#include <errno.h> +#ifdef __APPLE__ + #include "dlfcn-compat.h" + #include "poll-compat.h" +#else + #include <dlfcn.h> + #include <sys/poll.h> +#endif + +#define BUFSIZE 150 +#define MAX_HEADERS 256 +#define MAX_LEN 150 + +#define PROXY_BANNER "Asterisk Call Manager Proxy" +#define PROXY_SHUTDOWN "ProxyMessage: Proxy Shutting Down" +#define ACTION_ID "ActionID" + +struct ast_server { + char nickname[80]; + char ast_host[40]; + char ast_port[10]; + char ast_user[80]; + char ast_pass[80]; + char ast_events[10]; + int status; /* TODO: have this mean something */ + struct ast_server *next; +}; + +struct proxy_user { + char username[80]; + char secret[80]; + char channel[80]; + char icontext[80]; + char ocontext[80]; + struct proxy_user *next; +}; + +struct proxyconfig { + struct ast_server *serverlist; + struct proxy_user *userlist; + char listen_addr[INET_ADDRSTRLEN]; + int listen_port; + char inputformat[80]; + char outputformat[80]; + int autofilter; + char key[80]; + char proc_user[30]; + char proc_group[30]; + char logfile[80]; + int retryinterval; + int maxretries; +}; + +struct iohandler { + int (*read) (); + int (*write) (); + int (*onconnect) (); + int *(*autodisconnect)(void); + char formatname[80]; + void *dlhandle; + struct iohandler *next; +}; + +struct mansession { + pthread_t t; + pthread_mutex_t lock; + struct sockaddr_in sin; + int fd; + char inbuf[MAX_LEN]; + int inlen; + struct iohandler *input; + struct iohandler *output; + int autofilter; + int inputcomplete; + int authenticated; + int connected; + struct ast_server *server; + struct proxy_user user; + char actionid[MAX_LEN]; + struct mansession *next; +}; + +struct message { + int hdrcount; + char headers[MAX_HEADERS][MAX_LEN]; + int in_command; + struct mansession *session; +}; + +struct proxyconfig pc; +extern int debug; + +/* Common Function Prototypes */ +void debugmsg (const char *, ...); +const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia); +int AddHeader(struct message *m, const char *fmt, ...); +void debugmsg (const char *fmt, ...); +void logmsg (const char *fmt, ...); + +int StartServer(struct ast_server *srv); +int WriteAsterisk(struct message *m); +char *astman_get_header(struct message *m, char *var); +int proxyerror_do(struct mansession *s, char *err); +int get_input(struct mansession *s, char *output); +int SetIOHandlers(struct mansession *s, char *ifmt, char *ofmt); +void destroy_session(struct mansession *s); +int connect_nonb(int sockfd, const struct sockaddr *saptr, socklen_t salen, int nsec); diff --git a/src/include/dlfcn-compat.h b/src/include/dlfcn-compat.h new file mode 100644 index 0000000..7c5e87f --- /dev/null +++ b/src/include/dlfcn-compat.h @@ -0,0 +1,83 @@ +/* +Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> & + Peter O'Gorman <ogorman@users.sourceforge.net> + +Portions may be copyright others, see the AUTHORS file included with this +distribution. + +Maintained by Peter O'Gorman <ogorman@users.sourceforge.net> + +Bug Reports and other queries should go to <ogorman@users.sourceforge.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +#ifndef _DLFCN_H_ +#define _DLFCN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (__GNUC__) && __GNUC__ > 3 +#define dl_restrict __restrict +#else +#define dl_restrict +#endif + +#ifndef _POSIX_SOURCE +/* + * Structure filled in by dladdr(). + */ +typedef struct dl_info { + const char *dli_fname; /* Pathname of shared object */ + void *dli_fbase; /* Base address of shared object */ + const char *dli_sname; /* Name of nearest symbol */ + void *dli_saddr; /* Address of nearest symbol */ +} Dl_info; + +extern int dladdr(const void * dl_restrict, Dl_info * dl_restrict); +#endif /* ! _POSIX_SOURCE */ + +extern int dlclose(void * handle); +extern char * dlerror(void); +extern void * dlopen(const char *path, int mode); +extern void * dlsym(void * dl_restrict handle, const char * dl_restrict symbol); + +#define RTLD_LAZY 0x1 +#define RTLD_NOW 0x2 +#define RTLD_LOCAL 0x4 +#define RTLD_GLOBAL 0x8 + +#ifndef _POSIX_SOURCE +#define RTLD_NOLOAD 0x10 +#define RTLD_NODELETE 0x80 + +/* + * Special handle arguments for dlsym(). + */ +#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ +#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ +#endif /* ! _POSIX_SOURCE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DLFCN_H_ */ diff --git a/src/include/poll-compat.h b/src/include/poll-compat.h new file mode 100644 index 0000000..79eab15 --- /dev/null +++ b/src/include/poll-compat.h @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------------*\ + $Id: poll-compat.h,v 1.1 2003/10/26 18:50:49 markster Exp $ + + NAME + + poll - select(2)-based poll() emulation function for BSD systems. + + SYNOPSIS + #include "poll.h" + + struct pollfd + { + int fd; + short events; + short revents; + } + + int poll (struct pollfd *pArray, unsigned long n_fds, int timeout) + + DESCRIPTION + + This file, and the accompanying "poll.c", implement the System V + poll(2) system call for BSD systems (which typically do not provide + poll()). Poll() provides a method for multiplexing input and output + on multiple open file descriptors; in traditional BSD systems, that + capability is provided by select(). While the semantics of select() + differ from those of poll(), poll() can be readily emulated in terms + of select() -- which is how this function is implemented. + + REFERENCES + Stevens, W. Richard. Unix Network Programming. Prentice-Hall, 1990. + + NOTES + 1. This software requires an ANSI C compiler. + + LICENSE + + This software is released under the following license: + + Copyright (c) 1995-2002 Brian M. Clapper + All rights reserved. + + Redistribution and use in source and binary forms are + permitted provided that: (1) source distributions retain + this entire copyright notice and comment; (2) modifications + made to the software are prominently mentioned, and a copy + of the original software (or a pointer to its location) are + included; and (3) distributions including binaries display + the following acknowledgement: "This product includes + software developed by Brian M. Clapper <bmc@clapper.org>" + in the documentation or other materials provided with the + distribution. The name of the author may not be used to + endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE. + + Effectively, this means you can do what you want with the software + except remove this notice or take advantage of the author's name. + If you modify the software and redistribute your modified version, + you must indicate that your version is a modification of the + original, and you must provide either a pointer to or a copy of the + original. +\*---------------------------------------------------------------------------*/ + +#ifndef _POLL_EMUL_H_ +#define _POLL_EMUL_H_ + +#define POLLIN 0x01 +#define POLLPRI 0x02 +#define POLLOUT 0x04 +#define POLLERR 0x08 +#define POLLHUP 0x10 +#define POLLNVAL 0x20 + +struct pollfd +{ + int fd; + short events; + short revents; +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if (__STDC__ > 0) || defined(__cplusplus) +extern int poll (struct pollfd *pArray, unsigned long n_fds, int timeout); +#else +extern int poll(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _POLL_EMUL_H_ */ |
