-
Notifications
You must be signed in to change notification settings - Fork 3
/
draft-liu-anima-grasp-api-03.xml
822 lines (741 loc) · 40.4 KB
/
draft-liu-anima-grasp-api-03.xml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
<?xml version="1.0" encoding="US-ASCII"?>
<!-- This is built from a template for a generic Internet Draft. Suggestions for
improvement welcome - write to Brian Carpenter, brian.e.carpenter @ gmail.com
This can be converted using the Web service at http://xml.resource.org/ -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<!-- You want a table of contents -->
<?rfc symrefs="yes"?>
<!-- Use symbolic labels for references -->
<?rfc sortrefs="yes"?>
<!-- This sorts the references -->
<?rfc iprnotified="no" ?>
<!-- Change to "yes" if someone has disclosed IPR for the draft -->
<?rfc compact="yes"?>
<!-- This defines the specific filename and version number of your draft (and inserts the appropriate IETF boilerplate -->
<rfc category="std" docName="draft-liu-anima-grasp-api-03" ipr="trust200902">
<front>
<title abbrev="GRASP API">Generic Autonomic Signaling Protocol Application
Program Interface (GRASP API)</title>
<author fullname="Brian Carpenter" initials="B. E." surname="Carpenter">
<organization abbrev="Univ. of Auckland"/>
<address>
<postal>
<street>Department of Computer Science</street>
<street>University of Auckland</street>
<street>PB 92019</street>
<city>Auckland</city>
<region/>
<code>1142</code>
<country>New Zealand</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Bing Liu" initials="B." role="editor" surname="Liu">
<organization>Huawei Technologies</organization>
<address>
<postal>
<street>Q22, Huawei Campus</street>
<street>No.156 Beiqing Road</street>
<city>Hai-Dian District, Beijing</city>
<code>100095</code>
<country>P.R. China</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Wendong Wang" initials="W." surname="Wang ">
<organization>BUPT University</organization>
<address>
<postal>
<street>Beijing University of Posts & Telecom.</street>
<street>No.10 Xitucheng Road</street>
<city>Hai-Dian District, Beijing 100876</city>
<country>P.R. China</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<author fullname="Xiangyang Gong" initials="X." surname="Gong">
<organization>BUPT University</organization>
<address>
<postal>
<street>Beijing University of Posts & Telecom.</street>
<street>No.10 Xitucheng Road</street>
<city>Hai-Dian District, Beijing 100876</city>
<country>P.R. China</country>
</postal>
<email>[email protected]</email>
</address>
</author>
<!---->
<date day="13" month="February" year="2017"/>
<abstract>
<t>This document specifies the application programming interface (API) of the
Generic Autonomic Signaling Protocol (GRASP). The API is used for
Autonomic Service Agents (ASA) calling the GRASP protocol module to
exchange autonomic network messages with other ASAs.</t>
</abstract>
</front>
<middle>
<section anchor="intro" title="Introduction">
<t>As defined in <xref target="I-D.ietf-anima-reference-model"/>, the
Autonomic Service Agent (ASA)
is the atomic entity of an autonomic function; and it is instantiated
on autonomic nodes. When ASAs communicate with each other, they should
use the Generic Autonomic Signaling Protocol (GRASP) <xref target="I-D.ietf-anima-grasp"/>.</t>
<t>As the following figure shows, GRASP could contain two major
sub-layers. The bottom is the GRASP base protocol module, which is only
responsible for sending and receiving GRASP messages and maintaining
shared data structures. The upper layer is
some extended functions based upon GRASP basic protocol. For example,
<xref target="I-D.liu-anima-grasp-distribution"/> describes a possible extended
function.</t>
<t>It is desirable that ASAs can be designed as portable user-space programs
using a portable API. In many operating systems, the GRASP module will therefore
be split into two layers, one being a library that provides the API and the other
being core code containing common components such as multicast handling and
the discovery cache. The details of this are system-dependent.
</t>
<t><figure>
<artwork align="center"><![CDATA[+----+ +----+
|ASAs| |ASAs|
+----+ +----+
| |
| GRASP Function API |
| |
+------------------+ |GRASP API
| GRASP Extended | |
| Function Modules | |
+------------------+ |
+------------------------------------------+
| GRASP Library |
| GRASP Module - - - - - - - - - - - - - -|
| GRASP Core |
+------------------------------------------+
]]></artwork>
</figure></t>
<t>Both the GRASP base module and the extended function modules should
be available to the ASAs. Thus, there needs to be two sub-sets of API.
However, since the extended functions are expected to be added in an incremental
manner, it is inappropriate to define the function APIs in a single
document. This document only defines the base GRASP API.</t>
</section>
<section title="GRASP API for ASA">
<t/>
<section title="Design Principles">
<t>The assumption of this document is that any Autonomic Service Agent
(ASA) needs to call a GRASP module that handles protocol details
(security, sending and listening for GRASP messages, waiting, caching
discovery results, negotiation looping, sending and receiving
sychronization data, etc.) but understands nothing about individual
objectives. So this is a high level abstract API for use by ASAs. Individual
language bindings should be defined in separate documents.</t>
<t>An assumption of this API is that ASAs may fall into various classes:
<list style="symbols">
<t>ASAs that only use GRASP for discovery purposes.</t>
<t>ASAs that use GRASP negotiation but only as an initiator (client).</t>
<t>ASAs that use GRASP negotiation but only as a responder.</t>
<t>ASAs that use GRASP negotiation as an initiator or responder.</t>
<t>ASAs that use GRASP synchronization but only as an initiator (recipient).</t>
<t>ASAs that use GRASP synchronization but only as a responder and/or flooder.</t>
<t>ASAs that use GRASP synchronization as an initiator, responder and/or flooder.</t>
</list>
The API also assumes that one ASA may support multiple objectives. Nothing prevents
an ASA from supporting some objectives for synchronization and others for negotiation.
</t>
<t>The API design assumes that the operating system and programming language
provide a convenient mechanism for multi-threaded code. A solution in case this
does not apply is described in <xref target="noThread"/>.</t>
<t>This is a preliminary version. Two particular gaps exist:<list style="symbols">
<t>Authorization of ASAs is out of scope.</t>
<t>The Rapid mode of GRASP is not supported.</t>
</list></t>
</section>
<section title="API definition">
<section title="Parameters and data structures">
<t>This section describes parameters and data structures uaed in multiple API calls.</t>
<section title="Errorcode">
<t>All functions in the API have an unsigned 'errorcode' integer as their return value (the first returned value
in languages that allow multiple returned parameters). An errorcode of zero indicates success.
Any other value indicates failure of some kind. The first three errorcodes have special importance:
<list style="numbers">
<t>Declined: used to indicate that the other end has sent a GRASP Negotiation End message (M_END) with a Decline option (O_DECLINE).</t>
<t>No reply: used in non-blocking calls to indicate that the other end has sent no reply so far (see <xref target="noThread"/>).</t>
<t>Unspecified error: used when no more specific error code applies.</t>
</list></t>
<t><xref target="ErrAppx"/> gives a full list of currently defined error codes.</t>
</section>
<section title="Timeout">
<t>Wherever a 'timeout' parameter appears, it is an integer expressed
in milliseconds. If it is zero, the GRASP default timeout (GRASP_DEF_TIMEOUT,
see <xref target="I-D.ietf-anima-grasp"/>) will apply. If no response
is received before the timeout expires, the call will fail unless otherwise noted.</t>
</section>
<section title="Objective">
<t>An 'objective' parameter is a data structure with the following components:
<list style="symbols">
<t>name (UTF-8 string) - the objective's name</t>
<t>neg (Boolean) - True if objective supports negotiation (default False)</t>
<t>synch (Boolean) - True if objective supports synchronization (default False)</t>
<t>dry (Boolean) - True if objective also supports dry-run synchronization (default False)
<list style="symbols">
<t>Note 1: All objectives are assumed to support discovery, so there is no Boolean for that.</t>
<t>Note 2: Only one of 'synch' or 'neg' may be True.</t>
<t>Note 3: 'dry' must not be True unless 'neg' is also True.</t>
</list></t>
<t>loop_count (integer) - Limit on negotiation steps etc. (default GRASP_DEF_LOOPCT,
see <xref target="I-D.ietf-anima-grasp"/>)</t>
<t>value - a specific data structure expressing the value of the objective. The format is
language dependent, with the constraint that it can be validly represented in CBOR (default integer = 0).
<vspace blankLines="1"/>
An essential requirement for all language mappings and all implementations is that, regardless
of what other options exist for a language-specific represenation of the value, there is
always an option to use a CBOR byte string as the value. The API will then wrap this
byte string in CBOR Tag 24 for transmission via GRASP, and unwrap it after reception.
<vspace blankLines="1"/>
An example data structure definition for an objective in the C language is:
<figure>
<artwork align="center"><![CDATA[
typedef struct {
char *name;
bool neg;
bool dry;
bool synch;
int loop_count;
int value_size; // size of value
uint8_t cbor_value[]; // CBOR bytestring of value
} objective;
]]></artwork>
</figure>
</t>
</list>
</t>
</section>
<section title="ASA_locator">
<t>An 'ASA_locator' parameter is a data structure with the following contents:
<list style="symbols">
<t>locator - The actual locator, either an IP address or an ASCII string.</t>
<t>ifi (integer) - The interface identifier index via which this was discovered - probably no use to a normal ASA</t>
<t>expire (system dependent type) - The time on the local system clock when this locator will expire from the cache</t>
<t>is_ipaddress (Boolean) - True if the locator is an IP address</t>
<t>is_fqdn (Boolean) - True if the locator is an FQDN</t>
<t>is_uri (Boolean) - True if the locator is a URI</t>
<t>diverted (Boolean) - True if the locator was discovered via a Divert option</t>
<t>protocol (integer) - Applicable transport protocol (IPPROTO_TCP or IPPROTO_UDP)</t>
<t>port (integer) - Applicable port number</t>
</list>
</t>
</section>
<section title="Tagged_objective">
<t>A 'tagged_objective' parameter is a data structure with the following contents:
<list style="symbols">
<t>objective - An objective</t>
<t>locator - The ASA_locator associated with the objective, or a null value.</t>
</list>
</t>
</section>
<section title="Asa_nonce">
<t>In most calls, an 'asa_nonce' parameter is required. It is generated when an ASA registers with GRASP,
and any call in which an invalid nonce is presented will fail.
It is an up to 32-bit opaque value (for example represented as a uint32_t, depending on the language).
It should be unpredictable; a possible implementation is to use the same mechanism that GRASP
uses to generate Session IDs <xref target="I-D.ietf-anima-grasp"/>. Another possible
implementation is to hash the name of the
ASA with a locally defined secret key.</t>
</section>
<section title="Session_nonce">
<t>In some calls, a 'session_nonce' parameter is required. This is an opaque data structure as far as the ASA is concerned,
used to identify calls to the API as belonging to a specific GRASP session. In fully threaded implementations this parameter
might not be needed, but it is included to act as a session handle if necessary. It will also allow GRASP to detect and ignore
malicious calls or calls from timed-out sessions. A possible implementation is to form the nonce from the underlying
GRASP Session ID and the source address of the session.</t>
</section>
</section>
<section title="Registration">
<t>These functions are used to register an ASA and the objectives that it supports with
the GRASP module. If an authorization model is added to GRASP, it would be added here.</t>
<t><list style="symbols">
<t>register_asa()<list style="none">
<t>Input parameter:<list style="hanging">
<t>name of the ASA (UTF-8 string)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>asa_nonce (integer) (if successful)</t>
</list></t>
<t>This initialises state in the GRASP module for the calling entity (the ASA).
In the case of success, an 'asa_nonce' is returned which the ASA must present in
all subsequent calls.
In the case of failure, the ASA has not been authorized and cannot operate.</t>
</list></t>
<t>deregister_asa()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>name of the ASA (UTF-8 string)</t>
</list></t>
<t>Return parameter:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This removes all state in the GRASP module for the calling entity (the ASA),
and deregisters any objectives it has registered. Note that these actions must
also happen automatically if an ASA crashes.</t>
<t>Note - the ASA name is strictly speaking redundant in this call, but is present for clarity.</t>
</list></t>
<t>register_objective()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
<t>ttl (integer - default GRASP_DEF_TIMEOUT)</t>
<t>discoverable (Boolean - default False)</t>
<t>overlap (Boolean - default False)</t>
<t>local (Boolean - default False)</t>
</list></t>
<t>Return parameter:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This registers an objective that this ASA supports and may modify.
The 'objective' becomes a candidate for discovery. However, discovery
responses should not be enabled until the ASA calls listen_negotiate() or
listen_synchronize(), showing that it is able to act as a responder.
The ASA may negotiate the objective or send synchronization or flood data.
Registration is not needed if the ASA only wants to receive synchronization
or flood data for the objective concerned. </t>
<t>The 'ttl' parameter is the valid lifetime (time to live) in milliseconds of any
discovery response for this objective. The default value should be the GRASP
default timeout (GRASP_DEF_TIMEOUT, see <xref target="I-D.ietf-anima-grasp"/>).</t>
<t>If the optional parameter 'discoverable' is True, the objective
is immediately discoverable. This is
intended for objectives that are only defined for GRASP discovery,
and which do not support negotiation or synchronization.</t>
<t>If the optional parameter 'overlap' is True, more than one ASA may register this objective
in the same GRASP instance.</t>
<t>If the optional parameter 'local' is True, discovery must return a link-local address.
This feature is for objectives that must be restricted to the local link.</t>
<t>This call may be repeated for multiple objectives.</t>
</list></t>
<t>deregister_objective()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameter:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>The 'objective' must have been registered by the calling ASA; if not, this call fails.
Otherwise, it removes all state in the GRASP module for the given objective.</t>
</list></t>
</list></t> <!-- End of registration functions -->
</section>
<section title="Discovery">
<t><list style="symbols">
<t>discover()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
<t>timeout (integer)</t>
<t>flush (Boolean - default False)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>locator_list (structure)</t>
</list></t>
<t>This returns a list of discovered 'ASA_locator's for the given objective.
If the optional parameter 'flush' is True, any locally cached locators for the
objective are deleted first. Otherwise, they are returned immediately. If not,
GRASP discovery is performed, and all results obtained before the timeout expires
are returned. If no results are obtained, an empty list is returned after the timeout.
That is not an error condition.</t>
<t>This should be called in a separate thread if asynchronous operation is required.</t>
</list></t>
</list></t>
</section> <!-- End of discovery functions -->
<section title="Negotiation">
<t><list style="symbols">
<t>request_negotiate()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
<t>peer (ASA_locator)</t>
<t>timeout (integer)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>session_nonce (structure) (if successful)</t>
<t>proffered_objective (structure) (if successful)</t>
<t>reason (string) (if negotiation declined)</t>
</list></t>
<t>This function opens a negotiation session. The 'objective' parameter must
include the requested value, and its loop count should be set to a
suitable value by the ASA. If not, the GRASP default will apply.</t>
<t>Note that a given negotiation session may or may not be a dry-run negotiation;
the two modes must not be mixed in a single session.</t>
<t>The 'peer' parameter is the target node; it must be an 'ASA_locator' as returned
by discover(). If the peer is null, GRASP discovery is performed first.</t>
<t>If the 'errorcode' return parameter is 0, the negotiation has successfully
started. There are then two cases:
<list style="numbers">
<t>The 'session_nonce' parameter is null. In this case the negotiation
has succeeded (the peer has accepted the request). The returned
'proffered_objective' contains the value accepted by the peer.</t>
<t>The 'session_nonce' parameter is not null. In this case negotiation
must continue. The returned 'proffered_objective' contains the first value
proffered by the negotiation peer. Note that this instance of the objective
must be used in the subsequent negotiation call because
it also contains the current loop count. The 'session_nonce' must be
presented in all subsequent negotiation steps.
<vspace blankLines="1"/>
This function must be followed by calls to 'negotiate_step' and/or 'negotiate_wait'
and/or 'end_negotiate' until the negotiation ends. 'request_negotiate' may then be called
again to start a new negotation.</t>
</list></t>
<t>If the 'errorcode' parameter has the value 1 ('declined'), the negotiation has been declined
by the peer (M_END and O_DECLINE features of GRASP). The 'reason' string is then available for
information and diagnostic use, but it may be a null string. For this and any other error code,
an exponential backoff is recommended before any retry.</t>
<t>This should be called in a separate thread if asynchronous operation is required.</t>
<t>Special note for the ACP infrastructure ASA: It is likely that this ASA will need to
discover and negotiate with its peers in each of its on-link neighbors. It will therefore need to
know not only the link-local IP address but also the physical interface and transport port for
connecting to each neighbor. One implementation approach to this is to include these
details in the 'session_nonce' data structure, which is opaque to normal ASAs.</t>
</list></t>
<t>listen_negotiate()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>session_nonce (structure) (if successful)</t>
<t>requested_objective (structure) (if successful)</t>
</list></t>
<t>This function instructs GRASP to listen for negotiation
requests for the given 'objective'. It also enables discovery responses for the objective.
It will block waiting for an incoming request, so
should be called in a separate thread if asynchronous operation is required. Unless
there is an unexpected failure,
this call only returns after an incoming negotiation request. When it does so,
'requested_objective' contains the first value requested by
the negotiation peer. Note that this instance of the objective
must be used in the subsequent negotiation call because
it also contains the current loop count. The 'session_nonce' must be
presented in all subsequent negotiation steps. </t>
<t>This function must be followed by calls to 'negotiate_step' and/or 'negotiate_wait'
and/or 'end_negotiate' until the negotiation ends. 'listen_negotiate' may then be called
again to await a new negotation.</t>
<t>If an ASA is capable of handling multiple negotiations simultaneously, it may
call 'listen_negotiate' simultaneously from multiple threads. The API and GRASP implementation
must support re-entrant use of the listening state and the negotiation calls. Simultaneous
sessions will be distinguished by the threads themselves, the GRASP Session IDs, and the underlying unicast
transport sockets.</t>
</list></t>
<t>stop_listen_negotiate()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameter:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>Instructs GRASP to stop listening for negotiation
requests for the given objective, i.e., cancels 'listen_negotiate'. Of course, it must be called
from a different thread. </t>
</list></t>
<t>negotiate_step()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>session_nonce (structure)</t>
<t>objective (structure)</t>
<t>timeout (integer)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>Exactly as for 'request_negotiate'</t>
</list></t>
<t>Executes the next negotation step with the peer. The 'objective' parameter
contains the next value being proffered by the ASA in this step.</t>
</list></t>
<t>negotiate_wait()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>session_nonce (structure)</t>
<t>timeout (integer)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>Delay negotiation session by 'timeout' milliseconds.</t>
</list></t>
<t>end_negotiate()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>session_nonce (structure)</t>
<t>reply (Boolean)</t>
<t>reason (UTF-8 string)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>End the negotiation session.
<vspace blankLines="1"/>
'reply' = True for accept (successful negotiation), False for decline (failed negotiation).
<vspace blankLines="1"/>
'reason' = optional string describing reason for decline.</t>
</list></t>
</list></t>
</section> <!-- End of negotiation functions -->
<section title="Synchronization and Flooding">
<t><list style="symbols">
<t>synchronize()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
<t>peer (ASA_locator)</t>
<t>timeout (integer)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>objective (structure) (if successful)</t>
</list></t>
<t>This call requests the synchronized value of the given 'objective'.</t>
<t>Since this is essentially a read operation, any ASA can do it. Therefore
the API checks that the ASA is registered but the objective doesn't need to
be registered by the calling ASA.</t>
<t>If the objective was already flooded, the flooded value is
returned immediately in the 'result' parameter. In this case, the 'source'
and 'timeout' are ignored.</t>
<t> Otherwise, synchronization with a discovered ASA is performed.
The 'peer' parameter is an 'ASA_locator' as returned by discover().
If 'peer' is null, GRASP discovery is performed first.</t>
<t>This call should be repeated whenever the latest value is needed.</t>
<t>Call in a separate thread if asynchronous operation is required.</t>
<t>Since this is essentially a read operation, any ASA can use
it. Therefore GRASP checks that the calling ASA is registered but the
objective doesn't need to be registered by the calling ASA.</t>
<t>In the case of failure, an exponential backoff is recommended before retrying.</t>
</list></t>
<t>listen_synchronize()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This instructs GRASP to listen for synchronization
requests for the given objective, and to
respond with the value given in the 'objective' parameter.
It also enables discovery responses for the objective.</t>
<t>This call is non-blocking and may be repeated whenever the value changes.</t>
</list></t>
<t>stop_listen_synchronize()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This call instructs GRASP to stop listening for synchronization
requests for the given 'objective', i.e. it cancels a previous listen_synchronize.</t>
</list></t>
<t>flood()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>ttl (integer)</t>
<t>tagged_objective_list (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This call instructs GRASP to flood the given synchronization
objective(s) and their value(s) and associated locator(s) to all GRASP nodes.</t>
<t>The 'ttl' parameter is the valid lifetime (time to live) of
the flooded data in milliseconds (0 = infinity)</t>
<t>The 'tagged_objective_list' parameter is a list of one or more 'tagged_objective'
couplets.
The 'locator' parameter that tags each objective is normally null but may
be a valid 'ASA_locator'.
Infrastructure ASAs needing to flood an {address, protocol, port} 3-tuple
with an objective create an ASA_locator object to do so. If the IP address
in that locator is the unspecified address
('::') it is replaced by the link-local address of the sending node in each
copy of the flood multicast, which will be forced to have a loop count of 1.
This feature is for objectives that must be restricted to the local link.
</t>
<t>The function checks that the ASA registered each objective.</t>
<t>This call may be repeated whenever any value changes.</t>
</list></t>
<t>get_flood()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>objective (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
<t>tagged_objective_list (structure) (if successful)</t>
</list></t>
<t>This call instructs GRASP to return the given synchronization
objective if it has been flooded and its lifetime has not expired. </t>
<t>Since this is essentially a read operation, any ASA can do
it. Therefore the API checks that the ASA is registered but the
objective doesn't need to be registered by the calling ASA.</t>
<t>The 'tagged_objective_list' parameter is a list of 'tagged_objective'
couplets, each one being a copy of the flooded objective and a coresponding locator.
Thus if the same objective has been flooded by multiple ASAs, the recipient can distinguish
the copies.</t>
<t>Note that this call is for advanced ASAs. In a simple case, an ASA can simply call
synchronize() in order to get a valid flooded objective.</t>
</list></t>
<t>expire_flood()<list style="none">
<t>Input parameters:<list style="hanging">
<t>asa_nonce (integer)</t>
<t>tagged_objective (structure)</t>
</list></t>
<t>Return parameters:<list style="hanging">
<t>errorcode (integer)</t>
</list></t>
<t>This is a call that can only be used after a preceding
call to get_flood() by an ASA that is capable of deciding
that the flooded value is stale or invalid. Use with care.</t>
<t>The 'tagged_objective' parameter is the one to be expired.</t>
</list></t>
</list></t>
</section> <!-- End of synchronization functions -->
</section>
</section>
<section anchor="noThread" title="Non-threaded Implementations">
<t>If an operating system or language does not provide convenient support for
multi-threading, ASAs may need to be written using a polling or 'event loop'
structure, whereby a main loop supports multiple GRASP sessions in parallel
by repeatedly checking each one for a change of state. To facilitate this, an
API implementation may provide alternative versions of all the functions that
involve blocking and queueing. In the calls, the error code 2 ("noReply")
will be returned by each call instead of blocking, until such time as the event
for which it is waiting has been queued. Thus, for example, request_negotiate
would return "noReply" instead of waiting until an incoming request or
timeout arrived.
The calls to which this applies are:
<list>
<t>discover()</t>
<t>request_negotiate()</t>
<t>negotiate_step()</t>
<t>synchronize()</t>
<t>listen_negotiate()</t>
</list>
</t>
</section>
<section anchor="examples" title="Example Logic Flows">
<t>TBD</t>
<t>(Until this section is written, some Python examples can be found at
<eref target="https://www.cs.auckland.ac.nz/~brian/graspy/Briggs.py"/>,
<eref target="https://www.cs.auckland.ac.nz/~brian/graspy/Gray.py"/>,
and <eref target="https://www.cs.auckland.ac.nz/~brian/graspy/brski/"/>.)
</t>
</section>
<!---->
<section anchor="security" title="Security Considerations">
<t>Security issues for the GRASP protocol are discussed in <xref target="I-D.ietf-anima-grasp"/>.
Authorization of ASAs is a subject for future study.</t>
<t>The 'asa_nonce' parameter is used in the API as a first line of defence against a malware process attempting
to imitate a legitimately registered ASA. The 'session_nonce' parameter is used in the API as a first line
of defence against a malware process attempting to hijack a GRASP session. </t>
</section>
<section anchor="iana" title="IANA Considerations">
<t>This does not need IANA assignment.</t>
<t/>
</section>
<section anchor="ack" title="Acknowledgements">
<t>This document was produced using the xml2rfc tool <xref target="RFC7749"/>.</t>
<t>Excellent suggestions were made by Michael Richardson.</t>
</section>
</middle>
<back>
<references title="Normative References">
<!-- <?rfc include='reference.RFC.2119'?> -->
<?rfc include='reference.I-D.ietf-anima-grasp'?>
</references>
<references title="Informative References">
<?rfc include='reference.RFC.7749'?>
<?rfc include='reference.I-D.ietf-anima-reference-model'?>
<?rfc include='reference.I-D.liu-anima-grasp-distribution'?>
</references>
<section anchor="ErrAppx" title="Error Codes">
<t>This Appendix lists the error codes defined so far, with suggested symbolic names
and corresponding descriptive strings in English. It is expected that complete API
implementations will provide for localisation of these descriptive strings.</t>
<t><figure>
<artwork><![CDATA[
ok 0 "OK"
declined 1 "Declined"
noReply 2 "No reply"
unspec 3 "Unspecified error"
ASAfull 4 "ASA registry full"
dupASA 5 "Duplicate ASA name"
noASA 6 "ASA not registered"
notYourASA 7 "ASA registered but not by you"
notBoth 8 "Objective cannot support both negotiation
and synchronization"
notDry 9 "Dry-run allowed only with negotiation"
notOverlap 10 "Overlap not supported by this implementation"
objFull 11 "Objective registry full"
objReg 12 "Objective already registered"
notYourObj 13 "Objective not registered by this ASA"
notObj 14 "Objective not found"
notNeg 15 "Objective not negotiable"
noSecurity 16 "No security"
noDiscReply 17 "No reply to discovery"
sockErrNegRq 18 "Socket error sending negotiation request"
noSession 19 "No session"
noSocket 20 "No socket"
loopExhausted 21 "Loop count exhausted"
sockErrNegStep 22 "Socket error sending negotiation step"
noPeer 23 "No negotiation peer"
CBORfail 24 "CBOR decode failure"
invalidNeg 25 "Invalid Negotiate message"
invalidEnd 26 "Invalid end message"
noNegReply 27 "No reply to negotiation step"
noValidStep 28 "No valid reply to negotiation step"
sockErrWait 29 "Socket error sending wait message"
sockErrEnd 30 "Socket error sending end message"
IDclash 31 "Incoming request Session ID clash"
notSynch 32 "Not a synchronization objective"
notFloodDisc 33 "Not flooded and no reply to discovery"
sockErrSynRq 34 "Socket error sending synch request"
noListener 35 "No synch listener"
noSynchReply 36 "No reply to synchronization request"
noValidSynch 37 "No valid reply to synchronization request"
invalidLoc 38 "Invalid locator"
]]></artwork>
</figure></t>
</section>
<section anchor="changes" title="Change log [RFC Editor: Please remove]">
<t>draft-liu-anima-grasp-api-03, 2017-02-13:
<vspace blankLines="1"/>
Changed error return to integers.
<vspace blankLines="1"/>
Required all implementations to accept objective values in CBOR.
<vspace blankLines="1"/>
Added non-blocking alternatives.
</t>
<t>draft-liu-anima-grasp-api-02, 2016-12-17:
<vspace blankLines="1"/>
Updated for draft-ietf-anima-grasp-09
</t>
<t>draft-liu-anima-grasp-api-02, 2016-09-30:
<vspace blankLines="1"/>
Added items for draft-ietf-anima-grasp-07
<vspace blankLines="1"/>
Editorial corrections</t>
<t>draft-liu-anima-grasp-api-01, 2016-06-24:
<vspace blankLines="1"/>
Updated for draft-ietf-anima-grasp-05
<vspace blankLines="1"/>
Editorial corrections</t>
<t>draft-liu-anima-grasp-api-00, 2016-04-04:
<vspace blankLines="1"/>
Initial version</t>
</section>
</back>
</rfc>