Project

General

Profile

Actions

Feature #4722

closed

Block literal

Added by Junxiao Shi over 6 years ago. Updated over 5 years 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.

Actions #1

Updated by Junxiao Shi over 6 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.

Actions #2

Updated by Davide Pesavento over 6 years ago

  • Status changed from Code review to Closed
Actions #3

Updated by Ju Pan over 5 years ago

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

Actions #4

Updated by Junxiao Shi over 5 years 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.

Actions #5

Updated by Alex Afanasyev over 5 years 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.

Actions #6

Updated by Ju Pan over 5 years 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.

Actions #7

Updated by Davide Pesavento over 5 years 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.

Actions #8

Updated by Ju Pan over 5 years 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.

Actions

Also available in: Atom PDF