Project

General

Profile

Feature #4722

Block literal

Added by Junxiao Shi over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
0.50 h

Description

Block literal allows creating a Block with a simple syntax like "0703 080141"_block.
It is a useful feature and should be exposed to callers outside of ndn-cxx tests.

#1

Updated by Junxiao Shi over 2 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 0 to 100

https://gerrit.named-data.net/#/c/ndn-cxx/+/4926 moves block literal operator and adds unit testing.

#2

Updated by Davide Pesavento over 2 years ago

  • Status changed from Code review to Closed
#3

Updated by Ju Pan over 1 year ago

A stupid question, how should I generate the input for _block operator?
For "0703 080141"_block, How should I generate "0703 080141"

#4

Updated by Junxiao Shi over 1 year ago

For "0703 080141"_block, How should I generate "0703 080141"

These are handwritten according to packet format.

Every L2 developer should learn to read and write common packets in hexadecimal.

#5

Updated by Alex Afanasyev over 1 year ago

Junxiao, please try to more considerate statements.

@Ju, as Junxiao mentioned, one way is to do it by hand. If you want to just fix encoding of a certain block, you can write a small for loop that will print out values to std::cout/cerr and then you copy/paste. We used to have such for loops (commented out) in some of the test cases, but not sure if we still have.

#6

Updated by Ju Pan over 1 year ago

Alex Afanasyev wrote:

Junxiao, please try to more considerate statements.

@Ju, as Junxiao mentioned, one way is to do it by hand. If you want to just fix encoding of a certain block, you can write a small for loop that will print out values to std::cout/cerr and then you copy/paste. We used to have such for loops (commented out) in some of the test cases, but not sure if we still have.

Hey Alex, thanks for the explanation. Yes, there is a for loop to generate the plain hex (now sure if you are talking about this one):

for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
  printf("0x%02x", *it);
}

but according to Juxiao's code review:

There's a guideline about improving readability. Whether you use block literal or HEX, I need to see comments about TLV structure:
- label every TLV-TYPE
- indent nested TLV

It seems we still need to handwrite the encoding according to the packet format for the formatting. Not sure if I understand it correctly.

#7

Updated by Davide Pesavento over 1 year ago

@Ju, I would suggest to manually edit the existing hex array. Just add the new field, adjust the length of affected TLVs, and that's it. And write the corresponding TLV type in a comment next to the element's hex representation, to make Junxiao happy.

#8

Updated by Ju Pan over 1 year ago

Davide Pesavento wrote:

@Ju, I would suggest to manually edit the existing hex array. Just add the new field, adjust the length of affected TLVs, and that's it. And write the corresponding TLV type in a comment next to the element's hex representation, to make Junxiao happy.

@Davide, thanks for the suggestion, I've changed the code.

Also available in: Atom PDF