Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

manager.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * External call management support 
00005  * 
00006  * Copyright (C) 1999, Mark Spencer
00007  *
00008  * Mark Spencer <markster@linux-support.net>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License.
00012  *
00013  * Includes code and algorithms from the Zapata library.
00014  *
00015  */
00016 
00017 #ifndef _ASTERISK_MANAGER_H
00018 #define _ASTERISK_MANAGER_H
00019 
00020 #include <stdarg.h>
00021 #include <sys/types.h>
00022 #include <sys/socket.h>
00023 #include <netinet/in.h>
00024 #include <arpa/inet.h>
00025 
00026 #include <asterisk/lock.h>
00027 
00028 /* 
00029  * Call management packages are text fields of the form a: b.  There is
00030  * always exactly one space after the colon.
00031  *
00032  * The first header type is the "Event" header.  Other headers vary from
00033  * event to event.  Headers end with standard \r\n termination.
00034  *
00035  * Some standard headers:
00036  *
00037  * Action: <action>        -- request or notification of a particular action
00038  * Response: <response>    -- response code, like "200 OK"
00039  *
00040  */
00041  
00042 #define DEFAULT_MANAGER_PORT 5038   /* Default port for Asterisk management via TCP */
00043 
00044 #define EVENT_FLAG_SYSTEM     (1 << 0) /* System events such as module load/unload */
00045 #define EVENT_FLAG_CALL       (1 << 1) /* Call event, such as state change, etc */
00046 #define EVENT_FLAG_LOG        (1 << 2) /* Log events */
00047 #define EVENT_FLAG_VERBOSE    (1 << 3) /* Verbose messages */
00048 #define EVENT_FLAG_COMMAND    (1 << 4) /* Ability to read/set commands */
00049 #define EVENT_FLAG_AGENT      (1 << 5) /* Ability to read/set agent info */
00050 #define EVENT_FLAG_USER                 (1 << 6) /* Ability to read/set user info */
00051 
00052 /* JDG: export manager structures */
00053 #define MAX_HEADERS 80
00054 #define MAX_LEN 256
00055 
00056 struct mansession {
00057    pthread_t t;
00058    ast_mutex_t lock;
00059    struct sockaddr_in sin;
00060    int fd;
00061    int blocking;
00062    char username[80];
00063    char challenge[10];
00064    int authenticated;
00065    int readperm;
00066    int writeperm;
00067    char inbuf[MAX_LEN];
00068    int inlen;
00069    
00070    struct mansession *next;
00071 };
00072 
00073 
00074 struct message {
00075    int hdrcount;
00076    char headers[MAX_HEADERS][MAX_LEN];
00077 };
00078 
00079 struct manager_action {
00080    char action[256];
00081    char *synopsis;
00082    int authority;
00083    int (*func)(struct mansession *s, struct message *m);
00084    struct manager_action *next;
00085 };
00086 
00087 /* External routines may register/unregister manager callbacks this way */
00088 int ast_manager_register( char *action, int authority, 
00089                 int (*func)(struct mansession *s, struct message *m), char *synopsis);
00090 int ast_manager_unregister( char *action );
00091 /* /JDG */
00092 
00093 /* External routines may send asterisk manager events this way */
00094 extern int manager_event(int category, char *event, char *contents, ...)
00095    __attribute__ ((format (printf, 3,4)));
00096 
00097 extern char *astman_get_header(struct message *m, char *var);
00098 extern void astman_send_error(struct mansession *s, struct message *m, char *error);
00099 extern void astman_send_response(struct mansession *s, struct message *m, char *resp, char *msg);
00100 extern void astman_send_ack(struct mansession *s, struct message *m, char *msg);
00101 
00102 /* Called by Asterisk initialization */
00103 extern int init_manager(void);
00104 extern int reload_manager(void);
00105 #endif

Generated on Fri Oct 31 07:05:06 2003 for Asterisk by doxygen 1.3.4