Rizin
unix-like reverse engineering framework and cli tools
transport.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2017 LemonBoy <thatlemon@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef _TRANSPORT_H_
5 #define _TRANSPORT_H_
6 
7 #include <rz_types.h>
8 #include <stdint.h>
9 
10 #ifndef HAVE_EPRINTF
11 #include <stdio.h>
12 #define eprintf(...) \
13  { fprintf(stderr, ##__VA_ARGS__); }
14 #define HAVE_EPRINTF 1
15 #endif
16 
17 #define KD_IO_PIPE 0
18 #define KD_IO_NET 1
19 
20 enum {
21  E_OK = 0,
22  E_TIMEOUT = -1,
23  E_ERROR = -2,
24  E_NOIF = -3,
25 };
26 
27 typedef struct io_backend_t {
28  const char *name;
29  int type;
30  int (*init)(void);
31  int (*deinit)(void);
32  void *(*open)(const char *path);
33  bool (*close)(void *);
34  int (*config)(void *, void *);
35  int (*read)(void *, uint8_t *buf, const uint64_t count, const int timeout);
36  int (*write)(void *, const uint8_t *buf, const uint64_t count, const int timeout);
38 
39 typedef struct io_desc_t {
40  void *fp;
43 
44 io_desc_t *io_desc_new(io_backend_t *iob, void *fp);
45 int iob_write(io_desc_t *desc, const uint8_t *buf, const uint32_t buf_len);
47 
48 extern io_backend_t iob_pipe;
49 extern io_backend_t iob_net;
50 
51 #endif
static int buf_len
Definition: asm_arc.c:22
const char * desc
Definition: bin_vsf.c:19
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
voidpf void * buf
Definition: ioapi.h:138
static int
Definition: sfsocketcall.h:114
unsigned int uint32_t
Definition: sftypes.h:29
unsigned long uint64_t
Definition: sftypes.h:28
unsigned char uint8_t
Definition: sftypes.h:31
const char * name
Definition: transport.h:28
int(* deinit)(void)
Definition: transport.h:31
int(* write)(void *, const uint8_t *buf, const uint64_t count, const int timeout)
Definition: transport.h:36
bool(* close)(void *)
Definition: transport.h:33
int(* init)(void)
Definition: transport.h:30
int(* read)(void *, uint8_t *buf, const uint64_t count, const int timeout)
Definition: transport.h:35
void * fp
Definition: transport.h:40
io_backend_t * iob
Definition: transport.h:41
uv_timer_t timeout
Definition: main.c:9
#define bool
Definition: sysdefs.h:146
io_backend_t iob_net
Definition: iob_net.c:564
int iob_read(io_desc_t *desc, uint8_t *buf, const uint32_t buf_len)
Definition: transport.c:37
struct io_desc_t io_desc_t
struct io_backend_t io_backend_t
int iob_write(io_desc_t *desc, const uint8_t *buf, const uint32_t buf_len)
Definition: transport.c:16
@ E_TIMEOUT
Definition: transport.h:22
@ E_NOIF
Definition: transport.h:24
@ E_ERROR
Definition: transport.h:23
@ E_OK
Definition: transport.h:21
io_backend_t iob_pipe
Definition: iob_pipe.c:130
io_desc_t * io_desc_new(io_backend_t *iob, void *fp)
Definition: transport.c:7