aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-core.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-06-12 12:43:18 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-06-12 12:43:18 +0000
commit0bdbba19b1b81dd177eb72e9e5c01aaf99e59c02 (patch)
treef7dbeb50ca226bcac5e67adaf834521bc890e13a /src/core/gnunet-core.c
parent5a48ee09998ddd6748d286b927cef50634e93181 (diff)
downloadgnunet-0bdbba19b1b81dd177eb72e9e5c01aaf99e59c02.tar.gz
gnunet-0bdbba19b1b81dd177eb72e9e5c01aaf99e59c02.zip
exclude notification about myself
Diffstat (limited to 'src/core/gnunet-core.c')
-rw-r--r--src/core/gnunet-core.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 4f49f8130..ebdd8aab3 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -44,6 +44,8 @@ static int monitor_connections_counter;
44 44
45static struct GNUNET_CORE_Handle *ch; 45static struct GNUNET_CORE_Handle *ch;
46 46
47static struct GNUNET_PeerIdentity my_id;
48
47/** 49/**
48 * Task run in monitor mode when the user presses CTRL-C to abort. 50 * Task run in monitor mode when the user presses CTRL-C to abort.
49 * Stops monitoring activity. 51 * Stops monitoring activity.
@@ -84,6 +86,15 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
84 printf (_("Peer `%s'\n"), (const char *) &enc); 86 printf (_("Peer `%s'\n"), (const char *) &enc);
85} 87}
86 88
89void
90monitor_notify_startup (void *cls,
91 struct GNUNET_CORE_Handle * server,
92 const struct GNUNET_PeerIdentity *
93 my_identity)
94{
95 my_id = (*my_identity);
96}
97
87 98
88/** 99/**
89 * Function called to notify core users that another 100 * Function called to notify core users that another
@@ -98,16 +109,20 @@ static void
98monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, 109monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
99 const struct GNUNET_ATS_Information *ats, uint32_t ats_count) 110 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
100{ 111{
101 monitor_connections_counter ++;
102 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 112 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
103 char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); 113 char *now_str;
104 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), 114 if (0 != memcmp (&my_id, peer, sizeof (my_id)))
105 now_str, 115 {
106 _("Connected to"), 116 monitor_connections_counter ++;
107 GNUNET_i2s (peer), 117 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
108 monitor_connections_counter); 118 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
109 119 now_str,
110 GNUNET_free (now_str); 120 _("Connected to"),
121 GNUNET_i2s (peer),
122 monitor_connections_counter);
123
124 GNUNET_free (now_str);
125 }
111} 126}
112 127
113 128
@@ -122,17 +137,22 @@ static void
122monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 137monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
123{ 138{
124 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get(); 139 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
125 char *now_str = GNUNET_STRINGS_absolute_time_to_string (now); 140 char *now_str;
141
142 if (0 != memcmp (&my_id, peer, sizeof (my_id)))
143 {
144 now_str = GNUNET_STRINGS_absolute_time_to_string (now);
126 145
127 GNUNET_assert (monitor_connections_counter > 0); 146 GNUNET_assert (monitor_connections_counter > 0);
128 monitor_connections_counter --; 147 monitor_connections_counter --;
129 148
130 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), 149 FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"),
131 now_str, 150 now_str,
132 _("Disconnected from"), 151 _("Disconnected from"),
133 GNUNET_i2s (peer), 152 GNUNET_i2s (peer),
134 monitor_connections_counter); 153 monitor_connections_counter);
135 GNUNET_free (now_str); 154 GNUNET_free (now_str);
155 }
136} 156}
137 157
138 158
@@ -162,7 +182,10 @@ run (void *cls, char *const *args, const char *cfgfile,
162 {NULL, 0, 0} 182 {NULL, 0, 0}
163 }; 183 };
164 184
165 ch = GNUNET_CORE_connect (cfg, NULL, NULL, 185 memset(&my_id, '\0', sizeof (my_id));
186
187 ch = GNUNET_CORE_connect (cfg, NULL,
188 monitor_notify_startup,
166 monitor_notify_connect, 189 monitor_notify_connect,
167 monitor_notify_disconnect, 190 monitor_notify_disconnect,
168 NULL, GNUNET_NO, 191 NULL, GNUNET_NO,