#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include "../../dprint.h"
#include "../../ut.h"
#include "../../mi/mi.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "mi_fifo.h"
#include "fifo_fnc.h"
#include "mi_parser.h"
#include "mi_writer.h"

Go to the source code of this file.
Defines | |
| #define | mi_do_consume() |
| #define | mi_open_reply(_name, _file, _err) |
Functions | |
| static struct mi_handler * | build_async_handler (char *name, int len) |
| static void | fifo_close_async (struct mi_root *mi_rpl, struct mi_handler *hdl, int done) |
| Open reply fifo, write message and close it. | |
| static void | free_async_handler (struct mi_handler *hdl) |
| static char * | get_reply_filename (char *file, int len) |
| Parse out reply file name from MI request. | |
| static int | mi_fifo_check (int fd, char *fname) |
| reply fifo security checks: | |
| void | mi_fifo_server (FILE *fifo_stream) |
| The actual MI Fifo Server. | |
| FILE * | mi_init_fifo_server (char *fifo_name, int mi_fifo_mode, int mi_fifo_uid, int mi_fifo_gid, char *fifo_reply_dir) |
| Initialize MI Fifo server. | |
| static FILE * | mi_open_reply_pipe (char *pipe_name) |
| Open reply pipe (filename given in MI command). | |
| int | mi_read_line (char *b, int max, FILE *stream, int *read) |
| Read input on fifo. | |
Variables | |
| static char * | mi_buf = 0 |
| static int | mi_fifo_read = 0 |
| static int | mi_fifo_write = 0 |
| static int | reply_fifo_len = 0 |
| static char * | reply_fifo_s = 0 |
Definition in file fifo_fnc.c.
| #define mi_do_consume | ( | ) |
| #define mi_open_reply | ( | _name, | |||
| _file, | |||||
| _err | ) |
| static struct mi_handler* build_async_handler | ( | char * | name, | |
| int | len | |||
| ) | [static, read] |
Definition at line 357 of file fifo_fnc.c.
References fifo_close_async(), mi_handler::handler_f, LM_ERR, mi_handler::param, and shm_malloc().
Referenced by default_method(), mi_datagram_server(), and mi_fifo_server().
| static void fifo_close_async | ( | struct mi_root * | mi_rpl, | |
| struct mi_handler * | hdl, | |||
| int | done | |||
| ) | [static] |
Open reply fifo, write message and close it.
Definition at line 326 of file fifo_fnc.c.
References free_async_handler(), free_mi_tree(), LM_ERR, mi_fifo_reply(), mi_open_reply_pipe(), mi_write_tree(), NULL, and mi_handler::param.
Referenced by build_async_handler().
| static void free_async_handler | ( | struct mi_handler * | hdl | ) | [inline, static] |
Definition at line 318 of file fifo_fnc.c.
References shm_free.
Referenced by datagram_close_async(), default_method(), fifo_close_async(), mi_datagram_server(), mi_fifo_server(), wait_async_reply(), and xmlrpc_close_async().
| static char* get_reply_filename | ( | char * | file, | |
| int | len | |||
| ) | [inline, static] |
Parse out reply file name from MI request.
Definition at line 299 of file fifo_fnc.c.
References LM_ERR, MAX_MI_FILENAME, reply_fifo_len, and reply_fifo_s.
Referenced by mi_fifo_server().
| static int mi_fifo_check | ( | int | fd, | |
| char * | fname | |||
| ) | [static] |
reply fifo security checks:
checks if fd is a fifo, is not hardlinked and it's not a softlink opened file descriptor + file name (for soft link check)
Definition at line 144 of file fifo_fnc.c.
References LM_ERR.
Referenced by mi_open_reply_pipe().
| void mi_fifo_server | ( | FILE * | fifo_stream | ) |
The actual MI Fifo Server.
Definition at line 401 of file fifo_fnc.c.
References mi_root::async_hdl, build_async_handler(), mi_cmd::f, file, mi_cmd::flags, free_async_handler(), free_mi_tree(), get_reply_filename(), LM_DBG, LM_ERR, lookup_mi_cmd(), MAX_MI_FIFO_BUFFER, MI_ASYNC_RPL_FLAG, mi_buf, MI_CMD_SEPARATOR, mi_do_consume, mi_fifo_reply(), MI_NO_INPUT_FLAG, mi_open_reply, mi_parse_tree(), mi_read_line(), MI_ROOT_ASYNC_RPL, mi_write_tree(), NULL, and run_mi_cmd().
Referenced by fifo_process().
| FILE* mi_init_fifo_server | ( | char * | fifo_name, | |
| int | mi_fifo_mode, | |||
| int | mi_fifo_uid, | |||
| int | mi_fifo_gid, | |||
| char * | fifo_reply_dir | |||
| ) |
Initialize MI Fifo server.
Definition at line 63 of file fifo_fnc.c.
References LM_DBG, LM_ERR, MAX_MI_FIFO_BUFFER, MAX_MI_FILENAME, mi_buf, mi_fifo_read, mi_fifo_write, NULL, pkg_malloc, reply_fifo_len, and reply_fifo_s.
Referenced by fifo_process().
| static FILE* mi_open_reply_pipe | ( | char * | pipe_name | ) | [static] |
Open reply pipe (filename given in MI command).
Definition at line 188 of file fifo_fnc.c.
References FIFO_REPLY_RETRIES, FIFO_REPLY_WAIT, LM_DBG, LM_ERR, mi_fifo_check(), NULL, and sleep_us().
Referenced by fifo_close_async().
| int mi_read_line | ( | char * | b, | |
| int | max, | |||
| FILE * | stream, | |||
| int * | read | |||
| ) |
Read input on fifo.
Definition at line 259 of file fifo_fnc.c.
References len, LM_ERR, and NULL.
Referenced by mi_fifo_server(), mi_parse_node(), and mi_parse_tree().
char* mi_buf = 0 [static] |
Definition at line 57 of file fifo_fnc.c.
Referenced by mi_datagram_server(), mi_fifo_server(), mi_init_datagram_buffer(), and mi_init_fifo_server().
int mi_fifo_read = 0 [static] |
int mi_fifo_write = 0 [static] |
int reply_fifo_len = 0 [static] |
Definition at line 59 of file fifo_fnc.c.
Referenced by get_reply_filename(), and mi_init_fifo_server().
char* reply_fifo_s = 0 [static] |
Definition at line 58 of file fifo_fnc.c.
Referenced by get_reply_filename(), and mi_init_fifo_server().
1.5.6