blob: 1980e6e59ba4e454c064a53bcb243a78e9efe973 [file] [log] [blame]
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -08001#include "ccnx-wrapper.h"
Zhenkai Zhu43eb2732012-12-28 00:48:26 -08002extern "C" {
3#include <ccn/fetch.h>
4}
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -08005#include <poll.h>
6#include <boost/throw_exception.hpp>
7#include <boost/date_time/posix_time/posix_time.hpp>
8#include <boost/random.hpp>
9#include <sstream>
10
11typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
12typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
13
14using namespace std;
15using namespace boost;
16
17namespace Ccnx {
18
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080019void
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080020readRaw(Bytes &bytes, const unsigned char *src, size_t len)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080021{
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080022 if (len > 0)
23 {
24 bytes.resize(len);
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080025 memcpy(&bytes[0], src, len);
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080026 }
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080027}
28
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080029const unsigned char *
30head(const Bytes &bytes)
31{
32 return &bytes[0];
33}
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080034
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080035CcnxWrapper::CcnxWrapper()
36 : m_handle (0)
37 , m_keyStore (0)
38 , m_keyLoactor (0)
39 , m_running (true)
40 , m_connected (false)
41{
42 connectCcnd();
43 initKeyStore ();
44 createKeyLocator ();
45 m_thread = thread (&CcnxWrapper::ccnLoop, this);
46}
47
48void
49CcnxWrapper::connectCcnd()
50{
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -080051 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080052 if (m_handle != 0) {
53 ccn_disconnect (m_handle);
54 ccn_destroy (&m_handle);
55 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080056
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080057 m_handle = ccn_create ();
58 if (ccn_connect(m_handle, NULL) < 0)
59 {
60 BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("connection to ccnd failed"));
61 }
62 m_connected = true;
63
64 if (!m_registeredInterests.empty())
65 {
66 for (map<std::string, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
67 {
68 // clearInterestFilter(it->first);
69 setInterestFilter(it->first, it->second);
70 }
71 }
72}
73
74CcnxWrapper::~CcnxWrapper()
75{
76 {
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -080077 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080078 m_running = false;
79 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080080
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -080081 m_thread.join ();
82 ccn_disconnect (m_handle);
83 ccn_destroy (&m_handle);
84 ccn_charbuf_destroy (&m_keyLoactor);
85 ccn_keystore_destroy (&m_keyStore);
86}
87
88void
89CcnxWrapper::createKeyLocator ()
90{
91 m_keyLoactor = ccn_charbuf_create();
92 ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_KeyLocator, CCN_DTAG);
93 ccn_charbuf_append_tt (m_keyLoactor, CCN_DTAG_Key, CCN_DTAG);
94 int res = ccn_append_pubkey_blob (m_keyLoactor, ccn_keystore_public_key(m_keyStore));
95 if (res >= 0)
96 {
97 ccn_charbuf_append_closer (m_keyLoactor); /* </Key> */
98 ccn_charbuf_append_closer (m_keyLoactor); /* </KeyLocator> */
99 }
100}
101
102const ccn_pkey*
103CcnxWrapper::getPrivateKey ()
104{
105 return ccn_keystore_private_key (m_keyStore);
106}
107
108const unsigned char*
109CcnxWrapper::getPublicKeyDigest ()
110{
111 return ccn_keystore_public_key_digest(m_keyStore);
112}
113
114ssize_t
115CcnxWrapper::getPublicKeyDigestLength ()
116{
117 return ccn_keystore_public_key_digest_length(m_keyStore);
118}
119
120void
121CcnxWrapper::initKeyStore ()
122{
123 m_keyStore = ccn_keystore_create ();
124 string keyStoreFile = string(getenv("HOME")) + string("/.ccnx/.ccnx_keystore");
125 if (ccn_keystore_init (m_keyStore, (char *)keyStoreFile.c_str(), (char*)"Th1s1sn0t8g00dp8ssw0rd.") < 0)
126 BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str(keyStoreFile.c_str()));
127}
128
129void
130CcnxWrapper::ccnLoop ()
131{
132 static boost::mt19937 randomGenerator (static_cast<unsigned int> (std::time (0)));
133 static boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rangeUniformRandom (randomGenerator, uniform_int<> (0,1000));
134
135 while (m_running)
136 {
137 try
138 {
139 int res = 0;
140 {
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800141 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800142 res = ccn_run (m_handle, 0);
143 }
144
145 if (!m_running) break;
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800146
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800147 if (res < 0)
148 BOOST_THROW_EXCEPTION (CcnxOperationException()
149 << errmsg_info_str("ccn_run returned error"));
150
151
152 pollfd pfds[1];
153 {
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800154 UniqueRecLock(m_mutex);
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800155
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800156 pfds[0].fd = ccn_get_connection_fd (m_handle);
157 pfds[0].events = POLLIN;
158 if (ccn_output_is_pending (m_handle))
159 pfds[0].events |= POLLOUT;
160 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800161
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800162 int ret = poll (pfds, 1, 1);
163 if (ret < 0)
164 {
165 BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("ccnd socket failed (probably ccnd got stopped)"));
166 }
167 }
168 catch (CcnxOperationException &e)
169 {
170 // do not try reconnect for now
171 throw e;
172 /*
173 m_connected = false;
174 // probably ccnd has been stopped
175 // try reconnect with sleep
176 int interval = 1;
177 int maxInterval = 32;
178 while (m_running)
179 {
180 try
181 {
182 this_thread::sleep (boost::get_system_time () + TIME_SECONDS(interval) + TIME_MILLISECONDS (rangeUniformRandom ()));
183
184 connectCcnd();
185 _LOG_DEBUG("reconnect to ccnd succeeded");
186 break;
187 }
188 catch (CcnxOperationException &e)
189 {
190 this_thread::sleep (boost::get_system_time () + TIME_SECONDS(interval) + TIME_MILLISECONDS (rangeUniformRandom ()));
191
192 // do exponential backup for reconnect interval
193 if (interval < maxInterval)
194 {
195 interval *= 2;
196 }
197 }
198 }
199 */
200 }
201 catch (const std::exception &exc)
202 {
203 // catch anything thrown within try block that derives from std::exception
204 std::cerr << exc.what();
205 }
206 catch (...)
207 {
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800208 cout << "UNKNOWN EXCEPTION !!!" << endl;
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800209 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800210 }
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800211}
212
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800213Bytes
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800214CcnxWrapper::createContentObject(const std::string &name, const unsigned char *buf, size_t len, int freshness)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800215{
216 ccn_charbuf *pname = ccn_charbuf_create();
217 ccn_charbuf *signed_info = ccn_charbuf_create();
218 ccn_charbuf *content = ccn_charbuf_create();
219
220 ccn_name_from_uri(pname, name.c_str());
221 ccn_signed_info_create(signed_info,
222 getPublicKeyDigest(),
223 getPublicKeyDigestLength(),
224 NULL,
225 CCN_CONTENT_DATA,
226 freshness,
227 NULL,
228 m_keyLoactor);
229 if(ccn_encode_ContentObject(content, pname, signed_info,
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800230 buf, len,
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800231 NULL, getPrivateKey()) < 0)
232 {
233 // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("encode content failed"));
234 }
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800235
236 Bytes bytes;
237 readRaw(bytes, content->buf, content->length);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800238
239 ccn_charbuf_destroy (&pname);
240 ccn_charbuf_destroy (&signed_info);
241 ccn_charbuf_destroy (&content);
242
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800243 return bytes;
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800244}
245
246int
Zhenkai Zhubad089c2012-12-28 10:28:27 -0800247CcnxWrapper::putToCcnd (const Bytes &contentObject)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800248{
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800249 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800250 if (!m_running || !m_connected)
251 return -1;
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800252
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800253
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800254 if (ccn_put(m_handle, head(contentObject), contentObject.size()) < 0)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800255 {
256 // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("ccnput failed"));
257 }
258
259 return 0;
260}
261
262int
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800263CcnxWrapper::publishData (const string &name, const unsigned char *buf, size_t len, int freshness)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800264{
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800265 Bytes co = createContentObject(name, buf, len, freshness);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800266 return putToCcnd(co);
267}
268
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800269int
270CcnxWrapper::publishData (const string &name, const Bytes &content, int freshness)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800271{
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800272 publishData(name, head(content), content.size(), freshness);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800273}
274
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800275string
Zhenkai Zhubad089c2012-12-28 10:28:27 -0800276CcnxWrapper::extractName(const unsigned char *data, const ccn_indexbuf *comps)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800277{
278 ostringstream name (ostringstream::out);
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800279 for (int i = 0; i < comps->n - 1; i++)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800280 {
281 char *comp;
282 size_t size;
283 name << "/";
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800284 ccn_name_comp_get(data, comps, i, (const unsigned char **)&comp, &size);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800285 string compStr(comp, size);
286 name << compStr;
287 }
288
289 return name.str();
290}
291
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800292
293static ccn_upcall_res
294incomingInterest(ccn_closure *selfp,
295 ccn_upcall_kind kind,
296 ccn_upcall_info *info)
297{
298 CcnxWrapper::InterestCallback *f = static_cast<CcnxWrapper::InterestCallback*> (selfp->data);
299
300 switch (kind)
301 {
302 case CCN_UPCALL_FINAL: // effective in unit tests
303 delete f;
304 delete selfp;
305 return CCN_UPCALL_RESULT_OK;
306
307 case CCN_UPCALL_INTEREST:
308 break;
309
310 default:
311 return CCN_UPCALL_RESULT_OK;
312 }
313
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800314 string interest = CcnxWrapper::extractName(info->interest_ccnb, info->interest_comps);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800315
316 (*f) (interest);
317 return CCN_UPCALL_RESULT_OK;
318}
319
320static ccn_upcall_res
321incomingData(ccn_closure *selfp,
322 ccn_upcall_kind kind,
323 ccn_upcall_info *info)
324{
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800325 Closure *cp = static_cast<Closure *> (selfp->data);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800326
327 switch (kind)
328 {
329 case CCN_UPCALL_FINAL: // effecitve in unit tests
330 delete cp;
331 cp = NULL;
332 delete selfp;
333 return CCN_UPCALL_RESULT_OK;
334
335 case CCN_UPCALL_CONTENT:
336 break;
337
338 case CCN_UPCALL_INTEREST_TIMED_OUT: {
339 if (cp != NULL && cp->getRetry() > 0) {
340 cp->decRetry();
341 return CCN_UPCALL_RESULT_REEXPRESS;
342 }
343
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800344 string interest = CcnxWrapper::extractName(info->interest_ccnb, info->interest_comps);
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800345 Closure::TimeoutCallbackReturnValue rv = cp->runTimeoutCallback(interest);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800346 switch(rv)
347 {
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800348 case Closure::RESULT_OK : return CCN_UPCALL_RESULT_OK;
349 case Closure::RESULT_REEXPRESS : return CCN_UPCALL_RESULT_REEXPRESS;
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800350 default : break;
351 }
352 return CCN_UPCALL_RESULT_OK;
353 }
354
355 default:
356 return CCN_UPCALL_RESULT_OK;
357 }
358
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800359 const unsigned char *pcontent;
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800360 size_t len;
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800361 if (ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, &pcontent, &len) < 0)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800362 {
363 // BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("decode ContentObject failed"));
364 }
365
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800366 string name = CcnxWrapper::extractName(info->content_ccnb, info->content_comps);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800367
Zhenkai Zhu43eb2732012-12-28 00:48:26 -0800368 Bytes content;
369 // copy content and do processing on the copy
370 // otherwise the pointed memory may have been changed during the processing
371 readRaw(content, pcontent, len);
372
373 cp->runDataCallback(name, content);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800374
375 return CCN_UPCALL_RESULT_OK;
376}
377
Zhenkai Zhuf47109b2013-01-02 19:41:34 -0800378int CcnxWrapper::sendInterest (const string &interest, Closure *closure)
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800379{
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800380 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800381 if (!m_running || !m_connected)
382 return -1;
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800383
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800384 ccn_charbuf *pname = ccn_charbuf_create();
385 ccn_closure *dataClosure = new ccn_closure;
386
Zhenkai Zhuf47109b2013-01-02 19:41:34 -0800387 ccn_name_from_uri (pname, interest.c_str());
Zhenkai Zhu974c5a62012-12-28 14:15:30 -0800388 dataClosure->data = (void *)closure;
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800389
390 dataClosure->p = &incomingData;
391 if (ccn_express_interest (m_handle, pname, dataClosure, NULL) < 0)
392 {
393 }
394
395 ccn_charbuf_destroy (&pname);
396 return 0;
397}
398
399int CcnxWrapper::setInterestFilter (const string &prefix, const InterestCallback &interestCallback)
400{
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800401 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800402 if (!m_running || !m_connected)
403 return -1;
404
405 ccn_charbuf *pname = ccn_charbuf_create();
406 ccn_closure *interestClosure = new ccn_closure;
407
408 ccn_name_from_uri (pname, prefix.c_str());
409 interestClosure->data = new InterestCallback (interestCallback); // should be removed when closure is removed
410 interestClosure->p = &incomingInterest;
411 int ret = ccn_set_interest_filter (m_handle, pname, interestClosure);
412 if (ret < 0)
413 {
414 }
415
416 m_registeredInterests.insert(pair<std::string, InterestCallback>(prefix, interestCallback));
417 ccn_charbuf_destroy(&pname);
418}
419
420void
421CcnxWrapper::clearInterestFilter (const std::string &prefix)
422{
Zhenkai Zhu7f4258e2012-12-29 19:55:13 -0800423 UniqueRecLock(m_mutex);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800424 if (!m_running || !m_connected)
425 return;
426
427 ccn_charbuf *pname = ccn_charbuf_create();
428
429 ccn_name_from_uri (pname, prefix.c_str());
430 int ret = ccn_set_interest_filter (m_handle, pname, 0);
431 if (ret < 0)
432 {
433 }
434
435 m_registeredInterests.erase(prefix);
436 ccn_charbuf_destroy(&pname);
437}
438
439string
440CcnxWrapper::getLocalPrefix ()
441{
442 struct ccn * tmp_handle = ccn_create ();
443 int res = ccn_connect (tmp_handle, NULL);
444 if (res < 0)
445 {
446 return "";
447 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800448
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800449 string retval = "";
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800450
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800451 struct ccn_charbuf *templ = ccn_charbuf_create();
452 ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
453 ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
454 ccn_charbuf_append_closer(templ); /* </Name> */
455 // XXX - use pubid if possible
456 ccn_charbuf_append_tt(templ, CCN_DTAG_MaxSuffixComponents, CCN_DTAG);
457 ccnb_append_number(templ, 1);
458 ccn_charbuf_append_closer(templ); /* </MaxSuffixComponents> */
459 ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", 2);
460 ccn_charbuf_append_closer(templ); /* </Interest> */
461
462 struct ccn_charbuf *name = ccn_charbuf_create ();
463 res = ccn_name_from_uri (name, "/local/ndn/prefix");
464 if (res < 0) {
465 }
466 else
467 {
468 struct ccn_fetch *fetch = ccn_fetch_new (tmp_handle);
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800469
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800470 struct ccn_fetch_stream *stream = ccn_fetch_open (fetch, name, "/local/ndn/prefix",
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800471 NULL, 4, CCN_V_HIGHEST, 0);
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800472 if (stream == NULL) {
473 }
474 else
475 {
476 ostringstream os;
477
478 int counter = 0;
479 char buf[256];
480 while (true) {
481 res = ccn_fetch_read (stream, buf, sizeof(buf));
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800482
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800483 if (res == 0) {
484 break;
485 }
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800486
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800487 if (res > 0) {
488 os << string(buf, res);
489 } else if (res == CCN_FETCH_READ_NONE) {
490 if (counter < 2)
491 {
492 ccn_run(tmp_handle, 1000);
493 counter ++;
494 }
495 else
496 {
497 break;
498 }
499 } else if (res == CCN_FETCH_READ_END) {
500 break;
501 } else if (res == CCN_FETCH_READ_TIMEOUT) {
502 break;
503 } else {
504 break;
505 }
506 }
507 retval = os.str ();
508 stream = ccn_fetch_close(stream);
509 }
510 fetch = ccn_fetch_destroy(fetch);
511 }
512
513 ccn_charbuf_destroy (&name);
514
515 ccn_disconnect (tmp_handle);
516 ccn_destroy (&tmp_handle);
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -0800517
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800518 return retval;
519}
520
Zhenkai Zhu1ddeb6f2012-12-27 14:04:18 -0800521}