/
CCNLiteInterfaceCCNbJni.scala
104 lines (95 loc) · 2.93 KB
/
CCNLiteInterfaceCCNbJni.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package ccnliteinterface.jni
import ccnliteinterface.CCNLiteInterface
/**
* Created by basil on 03/09/14.
*/
class CCNLiteInterfaceCCNbJni extends CCNLiteInterface {
System.loadLibrary("CCNLiteInterfaceCCNbJni")
/**
* Native call to create a binary interest for name components
* @param nameCmps Each element of this array is a seperate component for the interest name
* @return Binary data of interest in ccnb format
*/
@native def mkBinaryInterest(nameCmps: Array[String]): Array[Byte]
/**
* Native call to create a binary content object for name compoents and given data
* @param name Each elemet of this array is a separate component for the content name
* @param data Binary data of the content object
* @return Binary data of the content in ccnb format
*/
@native def mkBinaryContent(name: Array[String], data: Array[Byte]): Array[Byte]
/**
* Creates an xml representation for ccnb formated data.
* attribute dt for the data element represents the encoding of the data. Currently "string" or "base64" is supported.
* String is fragile because it can contain unescaped characters.
*
* Interest(["cmp1", "cmp2"]:
* <interest>
* <name>
* <component>
* <data size="4" dt="string">
* cmp1
* </data>
* </component>
* <component>
* <data size="4" dt="string">
* cmp2
* </data>
* </component>
* </name>
* <scope>
* <data size="0" dt="string">
*
* </data>
* </scope>
* <nonce>
* <data size="4" dt="string">
* '%0d0S
* </data>
* </nonce>
* </interest>
*
* Content(["cmp1", "cmp2"], "content"):
* <contentobj>
* <name>
* <component>
* <data size="4" dt="string">
* "cmp1"
* </data>
* </component>
* <component>
* <data size="4" dt="string">
* "cmp2"
* </data>
* </component>
* </name>
* <timestamp>
* <data size="6" dt="string">
* S0%0d'%07/
* </data>
* </timestamp>
* <signedinfo>
* <publisherPubKeyDigest>
* <data size="0" dt="string">
* </data>
* </publisherPubKeyDigest>
* </signedinfo>
* <content>
* <data size="8" dt="string">
* content
* </data>
* </content>
* <contentobj>
*
* @param binaryPacket Data in ccnb format
* @return A string containing the xml representation of the ccnb data
*/
@native def ccnbToXml(binaryPacket: Array[Byte]): String
/**
* Creates an ccnb format interest to add a content object to the localAbstractMachine ccn cache.
* The content object itself must formated in ccnb and stored in a file.
* @param ccnbAbsoluteFilename Filename of the file containing the content object formated in ccnb
* @return Binary data of the interest in ccnb format
*/
@native def mkAddToCacheInterest(ccnbAbsoluteFilename: String): Array[Byte]
}