diff options
author | Bart Polot <bart@net.in.tum.de> | 2015-07-31 06:58:55 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2015-07-31 06:58:55 +0000 |
commit | c14ff64b5c9ca4cfc5004e30622499cc782694c5 (patch) | |
tree | 85f5f098c4054fccffcf56159e3543cf1d252c48 /src/cadet/gnunet-service-cadet_peer.h | |
parent | 5eb722ace41a4cccf9d65bf408cfd3c45756cf2f (diff) | |
download | gnunet-c14ff64b5c9ca4cfc5004e30622499cc782694c5.tar.gz gnunet-c14ff64b5c9ca4cfc5004e30622499cc782694c5.zip |
- refactor GCP_get_peer, fix get peer info
Diffstat (limited to 'src/cadet/gnunet-service-cadet_peer.h')
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index 87e828b66..7a60b33bd 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h | |||
@@ -39,6 +39,7 @@ extern "C" | |||
39 | 39 | ||
40 | #include "platform.h" | 40 | #include "platform.h" |
41 | #include "gnunet_util_lib.h" | 41 | #include "gnunet_util_lib.h" |
42 | #include "cadet_path.h" | ||
42 | 43 | ||
43 | /** | 44 | /** |
44 | * Struct containing all information regarding a given peer | 45 | * Struct containing all information regarding a given peer |
@@ -72,6 +73,20 @@ typedef int | |||
72 | uint16_t type, uint32_t pid, int fwd, size_t size, | 73 | uint16_t type, uint32_t pid, int fwd, size_t size, |
73 | struct GNUNET_TIME_Relative wait); | 74 | struct GNUNET_TIME_Relative wait); |
74 | 75 | ||
76 | /** | ||
77 | * Peer path iterator. | ||
78 | * | ||
79 | * @param cls Closure. | ||
80 | * @param peer Peer this path is towards. | ||
81 | * @param path Path itself | ||
82 | * @return #GNUNET_YES if should keep iterating. | ||
83 | * #GNUNET_NO otherwise. | ||
84 | */ | ||
85 | typedef int | ||
86 | (*GCP_path_iterator) (void *cls, | ||
87 | struct CadetPeer *peer, | ||
88 | struct CadetPeerPath *path); | ||
89 | |||
75 | 90 | ||
76 | /******************************************************************************/ | 91 | /******************************************************************************/ |
77 | /******************************** API ***********************************/ | 92 | /******************************** API ***********************************/ |
@@ -93,27 +108,32 @@ GCP_shutdown (void); | |||
93 | 108 | ||
94 | 109 | ||
95 | /** | 110 | /** |
96 | * Retrieve the CadetPeer stucture associated with the peer, create one | 111 | * Retrieve the CadetPeer stucture associated with the peer. Optionally create |
97 | * and insert it in the appropriate structures if the peer is not known yet. | 112 | * one and insert it in the appropriate structures if the peer is not known yet. |
98 | * | 113 | * |
99 | * @param peer_id Full identity of the peer. | 114 | * @param peer_id Full identity of the peer. |
115 | * @param create #GNUNET_YES if a new peer should be created if unknown. | ||
116 | * #GNUNET_NO otherwise. | ||
100 | * | 117 | * |
101 | * @return Existing or newly created peer structure. | 118 | * @return Existing or newly created peer structure. |
119 | * NULL if unknown and not requested @a create | ||
102 | */ | 120 | */ |
103 | struct CadetPeer * | 121 | struct CadetPeer * |
104 | GCP_get (const struct GNUNET_PeerIdentity *peer_id); | 122 | GCP_get (const struct GNUNET_PeerIdentity *peer_id, int create); |
105 | |||
106 | 123 | ||
107 | /** | 124 | /** |
108 | * Retrieve the CadetPeer stucture associated with the peer, create one | 125 | * Retrieve the CadetPeer stucture associated with the peer. Optionally create |
109 | * and insert it in the appropriate structures if the peer is not known yet. | 126 | * one and insert it in the appropriate structures if the peer is not known yet. |
110 | * | 127 | * |
111 | * @param peer Short identity of the peer. | 128 | * @param peer Short identity of the peer. |
129 | * @param create #GNUNET_YES if a new peer should be created if unknown. | ||
130 | * #GNUNET_NO otherwise. | ||
112 | * | 131 | * |
113 | * @return Existing or newly created peer structure. | 132 | * @return Existing or newly created peer structure. |
133 | * NULL if unknown and not requested @a create | ||
114 | */ | 134 | */ |
115 | struct CadetPeer * | 135 | struct CadetPeer * |
116 | GCP_get_short (const GNUNET_PEER_Id peer); | 136 | GCP_get_short (const GNUNET_PEER_Id peer, int create); |
117 | 137 | ||
118 | /** | 138 | /** |
119 | * Try to establish a new connection to this peer (in its tunnel). | 139 | * Try to establish a new connection to this peer (in its tunnel). |
@@ -444,6 +464,20 @@ GCP_notify_broken_link (struct CadetPeer *peer, | |||
444 | unsigned int | 464 | unsigned int |
445 | GCP_count_paths (const struct CadetPeer *peer); | 465 | GCP_count_paths (const struct CadetPeer *peer); |
446 | 466 | ||
467 | /** | ||
468 | * Iterate over the paths to a peer. | ||
469 | * | ||
470 | * @param peer Peer to get path info. | ||
471 | * @param callback Function to call for every path. | ||
472 | * @param cls Closure for @a callback. | ||
473 | * | ||
474 | * @return Number of iterated paths. | ||
475 | */ | ||
476 | unsigned int | ||
477 | GCP_iterate_paths (struct CadetPeer *peer, | ||
478 | GCP_path_iterator callback, | ||
479 | void *cls); | ||
480 | |||
447 | 481 | ||
448 | /** | 482 | /** |
449 | * Iterate all known peers. | 483 | * Iterate all known peers. |