zhangmeng
2021-12-10 5990bac28af438a914165441b3c33a370b320d16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
 
#ifndef CORE_PIPE_H
#define CORE_PIPE_H
 
// NB: This structure is supplied here for use by the CORE. Use of this
// OUSIDE of the core is STRICTLY VERBOTEN.  NO DIRECT ACCESS BY PROTOCOLS OR
// TRANSPORTS.
 
#include "core/defs.h"
#include "core/thread.h"
#include "sp/transport.h"
 
extern int  nni_pipe_sys_init(void);
extern void nni_pipe_sys_fini(void);
 
// AIO
extern void nni_pipe_recv(nni_pipe *, nni_aio *);
extern void nni_pipe_send(nni_pipe *, nni_aio *);
 
// Pipe operations that protocols use.
extern uint32_t nni_pipe_id(nni_pipe *);
 
// nni_pipe_close closes the underlying transport for the pipe.  Further
// operations against will return NNG_ECLOSED.  This is idempotent.  The
// actual pipe will be reaped asynchronously.
extern void nni_pipe_close(nni_pipe *);
 
extern uint16_t nni_pipe_proto(nni_pipe *);
extern uint16_t nni_pipe_peer(nni_pipe *);
 
// nni_pipe_getopt looks up the option.  The last argument is the type,
// which.  If the type is NNI_TYPE_OPAQUE, then no format check is performed.
extern int nni_pipe_getopt(
    nni_pipe *, const char *, void *, size_t *, nni_opt_type);
 
// nni_pipe_find finds a pipe given its ID.  It places a hold on the
// pipe, which must be released by the caller when it is done.
extern int nni_pipe_find(nni_pipe **, uint32_t);
 
// nni_pipe_sock_id returns the socket id for the pipe (used by public API).
extern uint32_t nni_pipe_sock_id(nni_pipe *);
 
// nni_pipe_listener_id returns the listener id for the pipe (or 0 if none).
extern uint32_t nni_pipe_listener_id(nni_pipe *);
 
// nni_pipe_dialer_id returns the dialer id for the pipe (or 0 if none).
extern uint32_t nni_pipe_dialer_id(nni_pipe *);
 
// nni_pipe_rele releases the hold on the pipe placed by nni_pipe_find.
extern void nni_pipe_rele(nni_pipe *);
 
// nni_pipe_add_stat adds a statistic to the pipe
extern void nni_pipe_add_stat(nni_pipe *, nni_stat_item *);
 
extern void nni_pipe_bump_rx(nni_pipe *, size_t);
extern void nni_pipe_bump_tx(nni_pipe *, size_t);
extern void nni_pipe_bump_error(nni_pipe *, int);
 
#endif // CORE_PIPE_H