napa-baselibs / tests / nvtest2 / nvtest2.h @ 507372bb
History | View | Annotate | Download (4.09 KB)
1 |
//#ifndef _PEER_H
|
---|---|
2 |
//#define _PEER_H
|
3 |
|
4 |
/** @file peer.h
|
5 |
*
|
6 |
* Local header file defining nuts 'n bolts for the peer implementation.
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
//#define _GNU_SOURCE
|
11 |
|
12 |
#include <stdio.h> |
13 |
#include <stdlib.h> |
14 |
#include <string.h> |
15 |
#include <math.h> |
16 |
|
17 |
#include <event2/event.h> |
18 |
#include <event2/buffer.h> |
19 |
#include <event2/http.h> |
20 |
#include <event2/http_struct.h> |
21 |
#include <confuse.h> |
22 |
|
23 |
#include <napa.h> |
24 |
#include <napa_log.h> |
25 |
#include <ml.h> |
26 |
#include <mon.h> |
27 |
#include <repoclient.h> |
28 |
#include <neighborlist.h> |
29 |
#include <chunkbuffer.h> |
30 |
#include <chunk.h> |
31 |
|
32 |
/** Struct maintainging data for this Peer instance */
|
33 |
typedef struct _peer { |
34 |
/** Local PeerID (string), obtained from ML (address) */
|
35 |
char LocalID[64]; |
36 |
/** Local PeerID (socketID), obtained from ML (address) */
|
37 |
socketID_handle LocalSocketID; |
38 |
/** Local PeerID integer value, obtained from config file */
|
39 |
int PeerIDvalue;
|
40 |
/** Repository handle */
|
41 |
HANDLE repository; |
42 |
/** Neighborlist handle */
|
43 |
HANDLE neighborlist; |
44 |
/** Neighborhood size */
|
45 |
int neighborlist_size;
|
46 |
/** Neighborlist array */
|
47 |
NeighborListEntry *neighbors; |
48 |
/** No. of neighbors in the list */
|
49 |
int num_neighbors;
|
50 |
/** Desired number of neighbors in the list */
|
51 |
int nblist_desired_size;
|
52 |
/** Update frequency of neighbor list */
|
53 |
int nblist_update_period;
|
54 |
/** ChannelID (string) to separate ourselves from others in the Repository */
|
55 |
char *channel;
|
56 |
/* ChunkBuffer */
|
57 |
struct chunk_buffer *cb;
|
58 |
} Peer; |
59 |
|
60 |
/** Global peer structure */
|
61 |
extern Peer *peer;
|
62 |
|
63 |
/** Read config file and initialize the local peer instance accordingly
|
64 |
|
65 |
@param[in] configfile name of configuration file
|
66 |
@return pointer to an initialized Peer structure
|
67 |
**/
|
68 |
Peer *peer_init(const char *configfile); |
69 |
|
70 |
/** Tell whether client mode is active
|
71 |
*
|
72 |
* @return boolean value indicating client mode
|
73 |
*/
|
74 |
//bool client_mode();
|
75 |
|
76 |
/** Tell whether source mode is active
|
77 |
*
|
78 |
* @return boolean value indicating source mode
|
79 |
*/
|
80 |
//bool source_mode();
|
81 |
|
82 |
/** Notifier callback for new Peers in the NeighborList
|
83 |
|
84 |
@param h Handle to the NeighborList instance generating the notification.
|
85 |
@param cbarg arbitrary user-provided parameter for the callback
|
86 |
*/
|
87 |
//void newPeers_cb(HANDLE rep, void *cbarg);
|
88 |
|
89 |
/**
|
90 |
* The peer receives data per callback from the messaging layer.
|
91 |
* @param *buffer A pointer to the buffer
|
92 |
* @param buflen The length of the buffer
|
93 |
* @param msgtype The message type
|
94 |
* @param *arg An argument that receives metadata about the received data
|
95 |
*/
|
96 |
//void recv_data_from_peer_cb(char *buffer,int buflen,unsigned char msgtype,void *arg);
|
97 |
|
98 |
/**
|
99 |
* The peer receives a chunk per callback from the messaging layer.
|
100 |
* @param *buffer A pointer to the buffer
|
101 |
* @param buflen The length of the buffer
|
102 |
* @param msgtype The message type
|
103 |
* @param *arg An argument that receives metadata about the received data
|
104 |
*/
|
105 |
//void recv_chunk_from_peer_cb(char *buffer,int buflen,unsigned char msgtype,void *arg);
|
106 |
|
107 |
/**
|
108 |
* A callback function that tells a connection has been established.
|
109 |
* @param connectionID The connection ID
|
110 |
* @param *arg An argument for data about the connection
|
111 |
*/
|
112 |
//void receive_conn_cb (int connectionID, void *arg);
|
113 |
|
114 |
/**
|
115 |
* A funtion that prints a connection establishment has failed
|
116 |
* @param connectionID The connection ID
|
117 |
* @param *arg An argument for data about the connection
|
118 |
*/
|
119 |
//void conn_fail_cb(int connectionID,void *arg);
|
120 |
|
121 |
//struct chunk;
|
122 |
//void chunk_transmit_callback(struct chunk *chunk, void *arg);
|
123 |
|
124 |
/**
|
125 |
* A callback function that tells a connection has been established.
|
126 |
* @param connectionID The connection ID
|
127 |
* @param *arg An argument for data about the connection
|
128 |
*/
|
129 |
//void receive_outconn_cb (int connectionID, void *arg);
|
130 |
|
131 |
/**
|
132 |
* Initialize the mini-UserLayer
|
133 |
* @param source name of the source stream (currently: udp://ipaddr:port is supported)
|
134 |
* @param chunk_duration length of a chunk in secords
|
135 |
* @return 0 on success
|
136 |
*/
|
137 |
//int init_source_ul(const char *source, double chunk_duration);
|
138 |
|
139 |
//void new_chunk(struct chunk_buffer *cb, void *cbarg, const struct chunk *c) ;
|
140 |
|
141 |
|
142 |
//#endif
|