OpenVAS Scanner 23.23.1
ipc.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6#ifndef MISC_IPC_H
7#define MISC_IPC_H
8
9#include <sys/types.h>
10
15
21
32{
35 unsigned int closed;
36 pid_t pid;
37 void *context;
38};
39
41{
42 int len;
43 int cap;
45};
46
47typedef void (*ipc_process_func) (struct ipc_context *, void *);
48
50{
51 // function to be executed before func is executed
53 // function to be executed
55 // function to be executed after func is executed
57 void *pre_arg; // argument for pre_func
58 void *func_arg; // argument for func
59 void *post_arg; // argument for post_func
60 void *shared_context; // context to be included in ipc_context
61};
62
63// ipc_process_func is a type for the function to be executed.
64
65int
66ipc_send (struct ipc_context *context, enum ipc_relation to, const char *msg,
67 size_t len);
68
69char *
70ipc_retrieve (struct ipc_context *context, enum ipc_relation from);
71
72int
73ipc_destroy (struct ipc_context *context);
74
75int
76ipc_close (struct ipc_context *context);
77
78struct ipc_context *
80 struct ipc_exec_context exec_context);
81
82struct ipc_context *
84
85struct ipc_contexts *
87
88struct ipc_contexts *
89ipc_add_context (struct ipc_contexts *ctxs, struct ipc_context *ctx);
90
91int
93
94#endif
int ipc_close(struct ipc_context *context)
closes given context
Definition ipc.c:116
int ipc_send(struct ipc_context *context, enum ipc_relation to, const char *msg, size_t len)
sends given msg to the target based on the given context
Definition ipc.c:46
int ipc_destroy(struct ipc_context *context)
destroys given context
Definition ipc.c:68
struct ipc_contexts * ipc_add_context(struct ipc_contexts *ctxs, struct ipc_context *ctx)
adds a given context to contexts
Definition ipc.c:274
char * ipc_retrieve(struct ipc_context *context, enum ipc_relation from)
retrieves data for the relation based on the context
Definition ipc.c:95
void(* ipc_process_func)(struct ipc_context *, void *)
Definition ipc.h:47
int ipc_destroy_contexts(struct ipc_contexts *ctxs)
destroys given contexts
Definition ipc.c:305
struct ipc_context * ipc_init(enum ipc_protocol protocol, enum ipc_relation relation)
initializes a new context.
Definition ipc.c:140
struct ipc_context * ipc_exec_as_process(enum ipc_protocol type, struct ipc_exec_context exec_context)
runs given functions with the given protocol type.
Definition ipc.c:175
struct ipc_contexts * ipc_contexts_init(int len)
initializes ipc_contexts with a given preallocated capacity.
Definition ipc.c:248
ipc_protocol
Definition ipc.h:12
@ IPC_PIPE
Definition ipc.h:13
ipc_relation
Definition ipc.h:17
@ IPC_CHILD
Definition ipc.h:19
@ IPC_MAIN
Definition ipc.h:18
u_char protocol
Definition nasl_packet_forgery.c:3
uint8_t len
Definition nasl_packet_forgery.c:1
Definition ipc.h:32
void * context
Definition ipc.h:37
enum ipc_protocol type
Definition ipc.h:33
unsigned int closed
Definition ipc.h:35
enum ipc_relation relation
Definition ipc.h:34
pid_t pid
Definition ipc.h:36
Definition ipc.h:41
struct ipc_context * ctxs
Definition ipc.h:44
int cap
Definition ipc.h:43
int len
Definition ipc.h:42
Definition ipc.h:50
ipc_process_func pre_func
Definition ipc.h:52
void * pre_arg
Definition ipc.h:57
void * post_arg
Definition ipc.h:59
void * func_arg
Definition ipc.h:58
void * shared_context
Definition ipc.h:60
ipc_process_func post_func
Definition ipc.h:56
ipc_process_func func
Definition ipc.h:54