coding.h File Reference

Details of the ccn binary wire encoding. More...

Go to the source code of this file.

Data Structures

struct  ccn_dict_entry
struct  ccn_dict
struct  ccn_skeleton_decoder

Defines

#define CCN_TT_BITS   3
#define CCN_TT_MASK   ((1 << CCN_TT_BITS) - 1)
#define CCN_MAX_TINY   ((1 << (7-CCN_TT_BITS)) - 1)
#define CCN_TT_HBIT   ((unsigned char)(1 << 7))
#define CCN_CLOSE   ((unsigned char)(0))
 CCN_CLOSE terminates composites.
#define CCN_DSTATE_PAUSE   (1 << 15)
 If the CCN_DSTATE_PAUSE bit is set in the decoder state, the decoder will return just after recognizing each token.
#define CCN_GET_TT_FROM_DSTATE(state)   (CCN_TT_MASK & ((state) >> 16))
#define CCN_FINAL_DSTATE(state)   (((state) & (CCN_DSTATE_PAUSE-1)) == 0)

Enumerations

enum  ccn_tt {
  CCN_EXT, CCN_TAG, CCN_DTAG, CCN_ATTR,
  CCN_DATTR, CCN_BLOB, CCN_UDATA, CCN_NO_TOKEN
}
 

Type tag for a ccnb start marker.

More...
enum  ccn_ext_subtype { CCN_PROCESSING_INSTRUCTIONS = 16 }
enum  ccn_dtag {
  CCN_DTAG_Any = 13, CCN_DTAG_Name = 14, CCN_DTAG_Component = 15, CCN_DTAG_Certificate = 16,
  CCN_DTAG_Collection = 17, CCN_DTAG_CompleteName = 18, CCN_DTAG_Content = 19, CCN_DTAG_SignedInfo = 20,
  CCN_DTAG_ContentDigest = 21, CCN_DTAG_ContentHash = 22, CCN_DTAG_Count = 24, CCN_DTAG_Header = 25,
  CCN_DTAG_Interest = 26, CCN_DTAG_Key = 27, CCN_DTAG_KeyLocator = 28, CCN_DTAG_KeyName = 29,
  CCN_DTAG_Length = 30, CCN_DTAG_Link = 31, CCN_DTAG_LinkAuthenticator = 32, CCN_DTAG_NameComponentCount = 33,
  CCN_DTAG_RootDigest = 36, CCN_DTAG_Signature = 37, CCN_DTAG_Start = 38, CCN_DTAG_Timestamp = 39,
  CCN_DTAG_Type = 40, CCN_DTAG_Nonce = 41, CCN_DTAG_Scope = 42, CCN_DTAG_Exclude = 43,
  CCN_DTAG_Bloom = 44, CCN_DTAG_BloomSeed = 45, CCN_DTAG_AnswerOriginKind = 47, CCN_DTAG_InterestLifetime = 48,
  CCN_DTAG_Witness = 53, CCN_DTAG_SignatureBits = 54, CCN_DTAG_DigestAlgorithm = 55, CCN_DTAG_BlockSize = 56,
  CCN_DTAG_FreshnessSeconds = 58, CCN_DTAG_FinalBlockID = 59, CCN_DTAG_PublisherPublicKeyDigest = 60, CCN_DTAG_PublisherCertificateDigest = 61,
  CCN_DTAG_PublisherIssuerKeyDigest = 62, CCN_DTAG_PublisherIssuerCertificateDigest = 63, CCN_DTAG_ContentObject = 64, CCN_DTAG_WrappedKey = 65,
  CCN_DTAG_WrappingKeyIdentifier = 66, CCN_DTAG_WrapAlgorithm = 67, CCN_DTAG_KeyAlgorithm = 68, CCN_DTAG_Label = 69,
  CCN_DTAG_EncryptedKey = 70, CCN_DTAG_EncryptedNonceKey = 71, CCN_DTAG_WrappingKeyName = 72, CCN_DTAG_Action = 73,
  CCN_DTAG_FaceID = 74, CCN_DTAG_IPProto = 75, CCN_DTAG_Host = 76, CCN_DTAG_Port = 77,
  CCN_DTAG_MulticastInterface = 78, CCN_DTAG_ForwardingFlags = 79, CCN_DTAG_FaceInstance = 80, CCN_DTAG_ForwardingEntry = 81,
  CCN_DTAG_MulticastTTL = 82, CCN_DTAG_MinSuffixComponents = 83, CCN_DTAG_MaxSuffixComponents = 84, CCN_DTAG_ChildSelector = 85,
  CCN_DTAG_RepositoryInfo = 86, CCN_DTAG_Version = 87, CCN_DTAG_RepositoryVersion = 88, CCN_DTAG_GlobalPrefix = 89,
  CCN_DTAG_LocalName = 90, CCN_DTAG_Policy = 91, CCN_DTAG_Namespace = 92, CCN_DTAG_GlobalPrefixName = 93,
  CCN_DTAG_PolicyVersion = 94, CCN_DTAG_KeyValueSet = 95, CCN_DTAG_KeyValuePair = 96, CCN_DTAG_IntegerValue = 97,
  CCN_DTAG_DecimalValue = 98, CCN_DTAG_StringValue = 99, CCN_DTAG_BinaryValue = 100, CCN_DTAG_NameValue = 101,
  CCN_DTAG_Entry = 102, CCN_DTAG_ACL = 103, CCN_DTAG_ParameterizedName = 104, CCN_DTAG_Prefix = 105,
  CCN_DTAG_Suffix = 106, CCN_DTAG_Root = 107, CCN_DTAG_ProfileName = 108, CCN_DTAG_Parameters = 109,
  CCN_DTAG_InfoString = 110, CCN_DTAG_StatusResponse = 112, CCN_DTAG_StatusCode = 113, CCN_DTAG_StatusText = 114,
  CCN_DTAG_SequenceNumber = 256, CCN_DTAG_CCNProtocolDataUnit = 17702112
}
 

DTAG identifies ccnb-encoded elements.

More...
enum  ccn_decoder_state {
  CCN_DSTATE_INITIAL = 0, CCN_DSTATE_NEWTOKEN, CCN_DSTATE_NUMVAL, CCN_DSTATE_UDATA,
  CCN_DSTATE_TAGNAME, CCN_DSTATE_ATTRNAME, CCN_DSTATE_BLOB, CCN_DSTATE_ERR_OVERFLOW = -1,
  CCN_DSTATE_ERR_ATTR = -2, CCN_DSTATE_ERR_CODING = -3, CCN_DSTATE_ERR_NEST = -4, CCN_DSTATE_ERR_BUG = -5
}
 

The decoder state is one of these, possibly with some additional bits set for internal use.

More...

Functions

ssize_t ccn_skeleton_decode (struct ccn_skeleton_decoder *d, const unsigned char *p, size_t n)
 Decodes ccnb decoded data.

Variables

struct ccn_dict ccn_dtag_dict
 Table for translating from DTAGs to names and vice versa.

Detailed Description

Details of the ccn binary wire encoding.

Part of the CCNx C Library.

Copyright (C) 2008-2010 Palo Alto Research Center, Inc.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Definition in file coding.h.


Define Documentation

#define CCN_CLOSE   ((unsigned char)(0))
#define CCN_DSTATE_PAUSE   (1 << 15)

If the CCN_DSTATE_PAUSE bit is set in the decoder state, the decoder will return just after recognizing each token.

In this instance, use CCN_GET_TT_FROM_DSTATE() to extract the token type from the decoder state; CCN_CLOSE will be reported as CCN_NO_TOKEN. The pause bit persists, so the end test should take that into account by using the CCN_FINAL_DSTATE macro instead of testing for state 0.

Definition at line 212 of file coding.h.

Referenced by ccn_buf_decoder_start(), ccn_skeleton_decode(), ccnbx(), main(), process_input_message(), and process_test().

#define CCN_FINAL_DSTATE ( state   )     (((state) & (CCN_DSTATE_PAUSE-1)) == 0)
#define CCN_GET_TT_FROM_DSTATE ( state   )     (CCN_TT_MASK & ((state) >> 16))
#define CCN_MAX_TINY   ((1 << (7-CCN_TT_BITS)) - 1)

Definition at line 30 of file coding.h.

Referenced by ccn_charbuf_append_tt(), ccn_decoder_decode(), ccn_skeleton_decode(), and emit_tt().

#define CCN_TT_BITS   3

Definition at line 28 of file coding.h.

Referenced by ccn_charbuf_append_tt(), ccn_decoder_decode(), ccn_skeleton_decode(), and emit_tt().

#define CCN_TT_HBIT   ((unsigned char)(1 << 7))

Definition at line 31 of file coding.h.

Referenced by ccn_charbuf_append_tt(), ccn_decoder_decode(), ccn_skeleton_decode(), and emit_tt().

#define CCN_TT_MASK   ((1 << CCN_TT_BITS) - 1)

Definition at line 29 of file coding.h.

Referenced by ccn_charbuf_append_tt(), ccn_decoder_decode(), ccn_skeleton_decode(), and emit_tt().


Enumeration Type Documentation

The decoder state is one of these, possibly with some additional bits set for internal use.

A complete parse ends up in state 0 or an error state. Not all possible error states are listed here.

Enumerator:
CCN_DSTATE_INITIAL 
CCN_DSTATE_NEWTOKEN 
CCN_DSTATE_NUMVAL 
CCN_DSTATE_UDATA 
CCN_DSTATE_TAGNAME 
CCN_DSTATE_ATTRNAME 
CCN_DSTATE_BLOB 
CCN_DSTATE_ERR_OVERFLOW 
CCN_DSTATE_ERR_ATTR 
CCN_DSTATE_ERR_CODING 
CCN_DSTATE_ERR_NEST 
CCN_DSTATE_ERR_BUG 

Definition at line 187 of file coding.h.

enum ccn_dtag

DTAG identifies ccnb-encoded elements.

c.f. tagname.csvdict See the gen_enum_dtag script for help updating these.

Enumerator:
CCN_DTAG_Any 
CCN_DTAG_Name 
CCN_DTAG_Component 
CCN_DTAG_Certificate 
CCN_DTAG_Collection 
CCN_DTAG_CompleteName 
CCN_DTAG_Content 
CCN_DTAG_SignedInfo 
CCN_DTAG_ContentDigest 
CCN_DTAG_ContentHash 
CCN_DTAG_Count 
CCN_DTAG_Header 
CCN_DTAG_Interest 
CCN_DTAG_Key 
CCN_DTAG_KeyLocator 
CCN_DTAG_KeyName 
CCN_DTAG_Length 
CCN_DTAG_Link 
CCN_DTAG_LinkAuthenticator 
CCN_DTAG_NameComponentCount 
CCN_DTAG_RootDigest 
CCN_DTAG_Signature 
CCN_DTAG_Start 
CCN_DTAG_Timestamp 
CCN_DTAG_Type 
CCN_DTAG_Nonce 
CCN_DTAG_Scope 
CCN_DTAG_Exclude 
CCN_DTAG_Bloom 
CCN_DTAG_BloomSeed 
CCN_DTAG_AnswerOriginKind 
CCN_DTAG_InterestLifetime 
CCN_DTAG_Witness 
CCN_DTAG_SignatureBits 
CCN_DTAG_DigestAlgorithm 
CCN_DTAG_BlockSize 
CCN_DTAG_FreshnessSeconds 
CCN_DTAG_FinalBlockID 
CCN_DTAG_PublisherPublicKeyDigest 
CCN_DTAG_PublisherCertificateDigest 
CCN_DTAG_PublisherIssuerKeyDigest 
CCN_DTAG_PublisherIssuerCertificateDigest 
CCN_DTAG_ContentObject 
CCN_DTAG_WrappedKey 
CCN_DTAG_WrappingKeyIdentifier 
CCN_DTAG_WrapAlgorithm 
CCN_DTAG_KeyAlgorithm 
CCN_DTAG_Label 
CCN_DTAG_EncryptedKey 
CCN_DTAG_EncryptedNonceKey 
CCN_DTAG_WrappingKeyName 
CCN_DTAG_Action 
CCN_DTAG_FaceID 
CCN_DTAG_IPProto 
CCN_DTAG_Host 
CCN_DTAG_Port 
CCN_DTAG_MulticastInterface 
CCN_DTAG_ForwardingFlags 
CCN_DTAG_FaceInstance 
CCN_DTAG_ForwardingEntry 
CCN_DTAG_MulticastTTL 
CCN_DTAG_MinSuffixComponents 
CCN_DTAG_MaxSuffixComponents 
CCN_DTAG_ChildSelector 
CCN_DTAG_RepositoryInfo 
CCN_DTAG_Version 
CCN_DTAG_RepositoryVersion 
CCN_DTAG_GlobalPrefix 
CCN_DTAG_LocalName 
CCN_DTAG_Policy 
CCN_DTAG_Namespace 
CCN_DTAG_GlobalPrefixName 
CCN_DTAG_PolicyVersion 
CCN_DTAG_KeyValueSet 
CCN_DTAG_KeyValuePair 
CCN_DTAG_IntegerValue 
CCN_DTAG_DecimalValue 
CCN_DTAG_StringValue 
CCN_DTAG_BinaryValue 
CCN_DTAG_NameValue 
CCN_DTAG_Entry 
CCN_DTAG_ACL 
CCN_DTAG_ParameterizedName 
CCN_DTAG_Prefix 
CCN_DTAG_Suffix 
CCN_DTAG_Root 
CCN_DTAG_ProfileName 
CCN_DTAG_Parameters 
CCN_DTAG_InfoString 
CCN_DTAG_StatusResponse 
CCN_DTAG_StatusCode 
CCN_DTAG_StatusText 
CCN_DTAG_SequenceNumber 
CCN_DTAG_CCNProtocolDataUnit 

Definition at line 60 of file coding.h.

Enumerator:
CCN_PROCESSING_INSTRUCTIONS 

Definition at line 50 of file coding.h.

enum ccn_tt

Type tag for a ccnb start marker.

Enumerator:
CCN_EXT 

starts composite extension - numval is subtype

CCN_TAG 

starts composite - numval is tagnamelen-1

CCN_DTAG 

starts composite - numval is tagdict index (enum ccn_dtag)

CCN_ATTR 

attribute - numval is attrnamelen-1, value follows

CCN_DATTR 

attribute numval is attrdict index

CCN_BLOB 

opaque binary data - numval is byte count

CCN_UDATA 

UTF-8 encoded character data - numval is byte count.

CCN_NO_TOKEN 

should not occur in encoding

Definition at line 36 of file coding.h.


Function Documentation

ssize_t ccn_skeleton_decode ( struct ccn_skeleton_decoder d,
const unsigned char *  p,
size_t  n 
)

Decodes ccnb decoded data.

Parameters:
d holds the current state of the decoder.
p points to a new block of ccnb data to feed to the decoder.
n is the size of the input, in bytes.
Returns:
the number of bytes consumed.

The client should ensure that the decoder is initialized to all zero before the first call. In the default mode, the decoder will return only when it runs out of data, encounters an error, or reaches the end of the element that it started at. This is a good way to pull ccnb-encoded objects from a byte stream.

By setting the CCN_DSTATE_PAUSE bit is set in the decoder state, the decoder will additionally return just after recognizing each token. In this instance, use CCN_GET_TT_FROM_DSTATE() to extract the token type from the decoder state; CCN_CLOSE will be reported as CCN_NO_TOKEN.

The pause bit persists, so the end test should take that into account by using the CCN_FINAL_DSTATE() macro instead of testing for state 0.

Once an error state is entered, no addition input is processed.

See also:
ccn_buf_decoder_start(), ccn_buf_advance(), ccn_buf_check_close()

Definition at line 57 of file ccn_coding.c.

Referenced by ccn_buf_advance(), ccn_buf_decoder_start(), ccn_process_input(), ccn_put(), ccnbx(), main(), process_input(), process_input_buffer(), process_input_message(), and process_test().


Variable Documentation

Table for translating from DTAGs to names and vice versa.

Definition at line 124 of file ccn_dtag_table.c.

Referenced by dtag_lookup(), and main().

Generated on Fri May 13 16:27:16 2011 for Content-Centric Networking in C by  doxygen 1.6.3