-
Notifications
You must be signed in to change notification settings - Fork 3
/
draft-ietf-anima-grasp-api-02.txt
1456 lines (891 loc) · 46.9 KB
/
draft-ietf-anima-grasp-api-02.txt
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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Network Working Group B. Carpenter
Internet-Draft Univ. of Auckland
Intended status: Informational B. Liu, Ed.
Expires: January 1, 2019 Huawei Technologies
W. Wang
X. Gong
BUPT University
June 30, 2018
Generic Autonomic Signaling Protocol Application Program Interface
(GRASP API)
draft-ietf-anima-grasp-api-02
Abstract
This document is a conceptual outline of an application programming
interface (API) for the Generic Autonomic Signaling Protocol (GRASP).
Such an API is needed for Autonomic Service Agents (ASA) calling the
GRASP protocol module to exchange autonomic network messages with
other ASAs.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on January 1, 2019.
Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
Carpenter, et al. Expires January 1, 2019 [Page 1]
Internet-Draft GRASP API June 2018
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. GRASP API for ASA . . . . . . . . . . . . . . . . . . . . . . 3
2.1. Design Principles . . . . . . . . . . . . . . . . . . . . 4
2.2. Asynchronous Operations . . . . . . . . . . . . . . . . . 5
2.3. API definition . . . . . . . . . . . . . . . . . . . . . 6
2.3.1. Parameters and data structures . . . . . . . . . . . 6
2.3.2. Registration . . . . . . . . . . . . . . . . . . . . 9
2.3.3. Discovery . . . . . . . . . . . . . . . . . . . . . . 12
2.3.4. Negotiation . . . . . . . . . . . . . . . . . . . . . 12
2.3.5. Synchronization and Flooding . . . . . . . . . . . . 17
2.3.6. Invalid Message Function . . . . . . . . . . . . . . 21
3. Example Logic Flows . . . . . . . . . . . . . . . . . . . . . 21
4. Security Considerations . . . . . . . . . . . . . . . . . . . 21
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22
6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 22
7. References . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.1. Normative References . . . . . . . . . . . . . . . . . . 22
7.2. Informative References . . . . . . . . . . . . . . . . . 22
Appendix A. Error Codes . . . . . . . . . . . . . . . . . . . . 23
Appendix B. Change log [RFC Editor: Please remove] . . . . . . . 24
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 26
1. Introduction
As defined in [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) [I-D.ietf-anima-grasp].
As the following figure shows, a GRASP implementation 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 contains
some extended functions based upon GRASP basic protocol. For
example, [I-D.liu-anima-grasp-distribution] describes a possible
extended function.
It is desirable that ASAs can be designed as portable user-space
programs using a portable API. In many operating systems, the GRASP
Carpenter, et al. Expires January 1, 2019 [Page 2]
Internet-Draft GRASP API June 2018
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. In particular, the GRASP
library might need to communicate with the GRASP core via an inter-
process communication (IPC) mechanism.
+----+ +----+
|ASAs| |ASAs|
+----+ +----+
| |
| GRASP Function API |
| |
+------------------+ |GRASP API
| GRASP Extended | |
| Function Modules | |
+------------------+ |
+------------------------------------------+
| GRASP Library |
| GRASP Module - - - - - - - - - - - - - -|
| GRASP Core |
+------------------------------------------+
Both the GRASP library and the extended function modules should be
available to the ASAs. Thus, there need 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 describes the base GRASP
API.
Note that a very simple autonomic node might contain only a single
ASA in addition to the autonomic infrastructure components described
in [I-D.ietf-anima-bootstrapping-keyinfra] and
[I-D.ietf-anima-autonomic-control-plane]. Such a node might directly
integrate GRASP in its autonomic code and therefore not require this
API to be installed.
This document gives a conceptual outline of the API. It is not a
formal specification for any particular programming language or
operating system, and it is expected that details will be clarified
in individual implementations.
2. GRASP API for ASA
Carpenter, et al. Expires January 1, 2019 [Page 3]
Internet-Draft GRASP API June 2018
2.1. Design Principles
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. The semantics of objectives are unknown to the GRASP
module and are handled only by the ASAs. Thus, this is a high level
abstract API for use by ASAs. Individual language bindings should be
defined in separate documents.
An assumption of this API is that ASAs may fall into various classes:
o ASAs that only use GRASP for discovery purposes.
o ASAs that use GRASP negotiation but only as an initiator (client).
o ASAs that use GRASP negotiation but only as a responder.
o ASAs that use GRASP negotiation as an initiator or responder.
o ASAs that use GRASP synchronization but only as an initiator
(recipient).
o ASAs that use GRASP synchronization but only as a responder and/or
flooder.
o ASAs that use GRASP synchronization as an initiator, responder
and/or flooder.
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.
The API design assumes that the operating system and programming
language provide a mechanism for simultaneous asynchronous
operations. This is discussed in detail in Section 2.2.
This is a preliminary version. A few gaps exist:
o Authorization of ASAs is out of scope.
o User-supplied explicit locators for an objective are not
supported.
o The Rapid mode of GRASP is not supported.
Carpenter, et al. Expires January 1, 2019 [Page 4]
Internet-Draft GRASP API June 2018
2.2. Asynchronous Operations
GRASP includes asynchronous operations and wait states. Most ASAs
will need to support several simultaneous operations; for example an
ASA might need to negotiate one objective with a peer while
discovering and synchronizing a different objective with a different
peer. Alternatively, an ASA which acts as a resource manager might
need to run simultaneous negotiations for a given objective with
multiple different peers. Thus, both the GRASP core and most ASAs
need to support asynchronous operations. Depending on both the
operating system and the programming language in use, there are two
main techniques for such parallel operations: multi-threading, or a
polling or 'event loop' structure.
In multi-threading, the operating system and language will provide
the necessary support for asynchronous operations, including creation
of new threads, context switching between threads, queues, locks, and
implicit wait states. In this case, all API calls can be treated
naturally as synchronous, even if they include wait states, blocking
and queueing. Simultaneous operations will each run in their own
threads.
In an event loop implementation, synchronous blocking calls are not
acceptable. Therefore all calls must be non-blocking, and the main
loop will support multiple GRASP sessions in parallel by repeatedly
checking each one for a change of state. To facilitate this, the API
implementation will provide non-blocking versions of all the
functions that otherwise involve blocking and queueing. In these
calls, a 'noReply' code will be returned by each call instead of
blocking, until such time as the event for which it is waiting (or a
failure) has occurred. Thus, for example, discover() would return
"noReply" instead of waiting until discovery has succeeded or timed
out. The discover() call would be repeated in every cycle of the
main loop until it completes. A 'session_nonce' parameter (described
below) is used to distinguish simultaneous GRASP sessions from each
other, so that any number of sessions may proceed in parallel.
The following calls involve waiting for a remote operation, so they
could use this mechanism:
discover()
request_negotiate()
negotiate_step()
listen_negotiate()
Carpenter, et al. Expires January 1, 2019 [Page 5]
Internet-Draft GRASP API June 2018
synchronize()
In all these calls, the 'session_nonce' is a read/write parameter.
On the first call, it is set to a null value, and the API returns the
'noReply' code and a non-null session_nonce value. This value must
be used in all subsequent calls for the same session. By this
mechanism, multiple overlapping sessions can be distinguished, both
in the ASA and in the GRASP core.
An additional mechanism that might increase efficiency for event loop
implementations is to add a general call, say notify(), which would
check the status of all outstanding operations for the calling ASA
and return the session_nonce values for all sessions that have
changed state. This would eliminate the need for repeated calls to
the individual functions returning a "noReply". This call is not
described below as the details are likely to be implementation-
specific.
2.3. API definition
2.3.1. Parameters and data structures
This section describes parameters and data structures uaed in
multiple API calls.
2.3.1.1. Errorcode
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:
1. Declined: used to indicate that the other end has sent a GRASP
Negotiation End message (M_END) with a Decline option
(O_DECLINE).
2. No reply: used in non-blocking calls to indicate that the other
end has sent no reply so far (see Section 2.2).
3. Unspecified error: used when no more specific error code applies.
Appendix A gives a full list of currently defined error codes, based
on implementation experience.
Carpenter, et al. Expires January 1, 2019 [Page 6]
Internet-Draft GRASP API June 2018
2.3.1.2. Timeout
Wherever a 'timeout' parameter appears, it is an integer expressed in
milliseconds. If it is zero, the GRASP default timeout
(GRASP_DEF_TIMEOUT, see [I-D.ietf-anima-grasp]) will apply. If no
response is received before the timeout expires, the call will fail
unless otherwise noted.
2.3.1.3. Objective
An 'objective' parameter is a data structure with the following
components:
o name (UTF-8 string) - the objective's name
o neg (Boolean flag) - True if objective supports negotiation
(default False)
o synch (Boolean flag) - True if objective supports synchronization
(default False)
o dry (Boolean flag) - True if objective supports dry-run
negotiation (default False)
* Note 1: All objectives are assumed to support discovery, so
there is no Boolean for that.
* Note 2: Only one of 'synch' or 'neg' may be True.
* Note 3: 'dry' must not be True unless 'neg' is also True.
* Note 4: In a language such as C the preferred implementation
may be to represent the Boolean flags as bits in a single byte.
o loop_count (integer) - Limit on negotiation steps etc. (default
GRASP_DEF_LOOPCT, see [I-D.ietf-anima-grasp])
o 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).
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.
Carpenter, et al. Expires January 1, 2019 [Page 7]
Internet-Draft GRASP API June 2018
An example data structure definition for an objective in the C
language is:
typedef struct {
char *name;
uint8_t flags; // flag bits as defined by GRASP
int loop_count;
int value_size; // size of value
uint8_t cbor_value[]; // CBOR bytestring of value
} objective;
An example data structure definition for an objective in the
Python language is:
class objective:
"""A GRASP objective"""
def __init__(self, name):
self.name = name #Unique name, string
self.neg = False #True if objective supports negotiation
self.dry = False #True if objective supports dry-run neg.
self.synch = False #True if objective supports synch
self.loop_count = GRASP_DEF_LOOPCT #Default starting value
self.value = 0 #Place holder; any valid Python object
2.3.1.4. ASA_locator
An 'ASA_locator' parameter is a data structure with the following
contents:
o locator - The actual locator, either an IP address or an ASCII
string.
o ifi (integer) - The interface identifier index via which this was
discovered - probably no use to a normal ASA
o expire (system dependent type) - The time on the local system
clock when this locator will expire from the cache
o is_ipaddress (Boolean) - True if the locator is an IP address
o is_fqdn (Boolean) - True if the locator is an FQDN
o is_uri (Boolean) - True if the locator is a URI
o diverted (Boolean) - True if the locator was discovered via a
Divert option
Carpenter, et al. Expires January 1, 2019 [Page 8]
Internet-Draft GRASP API June 2018
o protocol (integer) - Applicable transport protocol (IPPROTO_TCP or
IPPROTO_UDP)
o port (integer) - Applicable port number
2.3.1.5. Tagged_objective
A 'tagged_objective' parameter is a data structure with the following
contents:
o objective - An objective
o locator - The ASA_locator associated with the objective, or a null
value.
2.3.1.6. Asa_nonce
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
[I-D.ietf-anima-grasp]. Another possible implementation is to hash
the name of the ASA with a locally defined secret key.
2.3.1.7. Session_nonce
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
(see Section 2.2). 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.
2.3.2. Registration
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.
o register_asa()
Input parameter:
Carpenter, et al. Expires January 1, 2019 [Page 9]
Internet-Draft GRASP API June 2018
name of the ASA (UTF-8 string)
Return parameters:
errorcode (integer)
asa_nonce (integer) (if successful)
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.
o deregister_asa()
Input parameters:
asa_nonce (integer)
name of the ASA (UTF-8 string)
Return parameter:
errorcode (integer)
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.
Note - the ASA name is strictly speaking redundant in this
call, but is present for clarity.
o register_objective()
Input parameters:
asa_nonce (integer)
objective (structure)
ttl (integer - default GRASP_DEF_TIMEOUT)
discoverable (Boolean - default False)
overlap (Boolean - default False)
Carpenter, et al. Expires January 1, 2019 [Page 10]
Internet-Draft GRASP API June 2018
local (Boolean - default False)
Return parameter:
errorcode (integer)
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.
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 [I-D.ietf-anima-grasp]).
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.
If the optional parameter 'overlap' is True, more than one ASA
may register this objective in the same GRASP instance.
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.
This call may be repeated for multiple objectives.
o deregister_objective()
Input parameters:
asa_nonce (integer)
objective (structure)
Return parameter:
errorcode (integer)
Carpenter, et al. Expires January 1, 2019 [Page 11]
Internet-Draft GRASP API June 2018
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.
2.3.3. Discovery
o discover()
Input parameters:
asa_nonce (integer)
objective (structure)
timeout (integer)
flush (Boolean - default False)
Return parameters:
errorcode (integer)
locator_list (structure)
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.
Threaded implementation: This should be called in a separate
thread if asynchronous operation is required.
Event loop implementation: An additional read/write
'session_nonce' parameter is used.
2.3.4. Negotiation
o request_negotiate()
Input parameters:
asa_nonce (integer)
objective (structure)
Carpenter, et al. Expires January 1, 2019 [Page 12]
Internet-Draft GRASP API June 2018
peer (ASA_locator)
timeout (integer)
Return parameters:
errorcode (integer)
session_nonce (structure) (if successful)
proffered_objective (structure) (if successful)
reason (string) (if negotiation declined)
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.
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.
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.
If the 'errorcode' return parameter is 0, the negotiation has
successfully started. There are then two cases:
1. 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.
2. 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.
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.
Carpenter, et al. Expires January 1, 2019 [Page 13]
Internet-Draft GRASP API June 2018
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.
Threaded implementation: This should be called in a separate
thread if asynchronous operation is required.
Event loop implementation: The 'session_nonce' parameter is
used in read/write mode.
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.
o listen_negotiate()
Input parameters:
asa_nonce (integer)
objective (structure)
Return parameters:
errorcode (integer)
session_nonce (structure) (if successful)
requested_objective (structure) (if successful)
This function instructs GRASP to listen for negotiation
requests for the given 'objective'. It also enables discovery
responses for the objective.
Threaded implementation: It will block waiting for an incoming
request, so should be called in a separate thread if
asynchronous operation is required.
Event loop implementation: A read/write 'session_nonce'
parameter is used.
Carpenter, et al. Expires January 1, 2019 [Page 14]
Internet-Draft GRASP API June 2018
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.
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.
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.
o stop_listen_negotiate()
Input parameters:
asa_nonce (integer)
objective (structure)
Return parameter:
errorcode (integer)
Instructs GRASP to stop listening for negotiation requests for
the given objective, i.e., cancels 'listen_negotiate'.
Threaded implementation: Must be called from a different thread
than 'listen_negotiate'.
Event loop implementation: no special considerations.
o negotiate_step()
Input parameters:
asa_nonce (integer)
session_nonce (structure)
Carpenter, et al. Expires January 1, 2019 [Page 15]
Internet-Draft GRASP API June 2018
objective (structure)
timeout (integer)
Return parameters:
Exactly as for 'request_negotiate'
Executes the next negotation step with the peer. The
'objective' parameter contains the next value being proffered
by the ASA in this step.
Threaded implementation: Called in the same thread as the
preceding 'request_negotiate' or 'listen_negotiate', with the
same value of 'session_nonce'.
Event loop implementation: Must use the same value of
'session_nonce' returned by the preceding 'request_negotiate'
or 'listen_negotiate'.
o negotiate_wait()
Input parameters:
asa_nonce (integer)
session_nonce (structure)
timeout (integer)
Return parameters:
errorcode (integer)
Delay negotiation session by 'timeout' milliseconds.
Threaded implementation: Called in the same thread as the
preceding 'request_negotiate' or 'listen_negotiate', with the
same value of 'session_nonce'.
Event loop implementation: Must use the same value of
'session_nonce' returned by the preceding 'request_negotiate'
or 'listen_negotiate'.
o end_negotiate()
Input parameters:
Carpenter, et al. Expires January 1, 2019 [Page 16]
Internet-Draft GRASP API June 2018
asa_nonce (integer)
session_nonce (structure)
reply (Boolean)
reason (UTF-8 string)
Return parameters:
errorcode (integer)
End the negotiation session.
'reply' = True for accept (successful negotiation), False for
decline (failed negotiation).
'reason' = optional string describing reason for decline.
Threaded implementation: Called in the same thread as the
preceding 'request_negotiate' or 'listen_negotiate', with the
same value of 'session_nonce'.
Event loop implementation: Must use the same value of
'session_nonce' returned by the preceding 'request_negotiate'
or 'listen_negotiate'.
2.3.5. Synchronization and Flooding
o synchronize()
Input parameters:
asa_nonce (integer)
objective (structure)
peer (ASA_locator)
timeout (integer)
Return parameters:
errorcode (integer)
objective (structure) (if successful)
Carpenter, et al. Expires January 1, 2019 [Page 17]
Internet-Draft GRASP API June 2018
This call requests the synchronized value of the given
'objective'.
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.
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.
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.
This call should be repeated whenever the latest value is
needed.
Threaded implementation: Call in a separate thread if
asynchronous operation is required.
Event loop implementation: An additional read/write
'session_nonce' parameter is used.
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.
In the case of failure, an exponential backoff is recommended
before retrying.
o listen_synchronize()
Input parameters:
asa_nonce (integer)
objective (structure)
Return parameters:
errorcode (integer)