diff --git a/ndniptunnel/mNetIO.cpp b/ndniptunnel/mNetIO.cpp index ef55cc7..5fe3398 100644 --- a/ndniptunnel/mNetIO.cpp +++ b/ndniptunnel/mNetIO.cpp @@ -46,7 +46,9 @@ int MNetIO::sendData(char *buf, int size, char *name) { // Create Data packet auto data = make_shared(dataName); data->setFreshnessPeriod(0_s); - data->setContent(reinterpret_cast(buf), size); + if (size > 0) { + data->setContent(reinterpret_cast(buf), size); + } string dsha = "id:/localhost/identity/digest-sha256"; ndn::security::SigningInfo si(dsha); diff --git a/ndniptunnel/main.go b/ndniptunnel/main.go index b56d672..54d9e03 100644 --- a/ndniptunnel/main.go +++ b/ndniptunnel/main.go @@ -88,7 +88,11 @@ func sendInterest(name string) error { //int sendData(char *buf, int size, char *name) ; func sendData(pkt []byte, name string) error { cstr := C.CString(name) - C.sendData((*C.char)(unsafe.Pointer(&pkt[0])), C.int(len(pkt)), cstr) + if pkt == nil { + C.sendData((*C.char)(unsafe.Pointer(nil)), C.int(0), cstr) + } else { + C.sendData((*C.char)(unsafe.Pointer(&pkt[0])), C.int(len(pkt)), cstr) + } C.free(unsafe.Pointer(cstr)) return nil }