-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcomm.h
82 lines (70 loc) · 2.42 KB
/
comm.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Copyright (c) 2015 Open Networking Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OFC_COMM_H_
#define OFC_COMM_H_
#include <libnetconf.h>
#ifndef DISABLE_DBUS
# include "comm_dbus.h"
#else
# include "comm_socket.h"
#endif
/**
* @brief Connect to D-Bus
* @param[in] side Caller's type to distinguish server and agents
* @param[in] crashed 0 if the server finished correctly, otherwise if it crashed
* @return Connection handler
*/
comm_t *comm_init(int crashed);
/**
* @brief Destroy all communication structures
* @param[in] conn Connection handler
* @return NULL on success, NETCONF error structure in case of failure
*/
void comm_destroy(comm_t *c);
/**
* @brief Communication loop
* @param[in] conn Connection handler
* @param[in] timeout Timeout in milliseconds
* @return EXIT_FAILURE on fatal error (communication is broken), EXIT_SUCCESS
* otherwise
*/
int comm_loop(comm_t *c, int timeout);
/*
* internal function for comm_session_info(), only comm_session_info_send()
* is supposed to be implemented by specific communication implementation
*/
int comm_session_info_send(comm_t *c, const char *username, const char *sid,
struct nc_cpblts *cpblts);
/**
* @brief Get list of NETCONF capabilities from the server
* @param[in] conn Connection handler
* @return List of strings with the server capabilities
*/
char **comm_get_srv_cpblts(comm_t *c);
/**
* @brief Perform Netopeer operation
* @param[in] c Communication handler
* @param[in] rpc NETCONF RPC request
* @return NETCONF rpc-reply message with the result.
*/
nc_reply *comm_operation(comm_t *c, const nc_rpc *rpc);
/**
* @brief Request termination of the specified NETCONF session
* @param[in] conn Connection handler
* @param[in] sid NETCONF session identifier
* @return NETCONF rpc-reply message with the result.
*/
nc_reply *comm_kill_session(comm_t *c, const char *sid);
#endif /* OFC_COMM_H_ */