ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-Porttracker/Porttracker/protocol.pod
Revision: 1.2
Committed: Mon Nov 15 20:41:17 2010 UTC (13 years, 7 months ago) by root
Branch: MAIN
Changes since 1.1: +7 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 =head1 DESCRIPTION
2
3 This document describes the porttracker API for third-party programs to
4 use (it is also used internally to communicate with the tawnyd).
5
6 =head1 CONVENTIONS
7
8 In this document, command names, paths and similar entities are F<formatted like this>.
9
10 Preformatted sections are indented like this. This is used for verbatim
11 text. Portions of the section that need to be replaced by dynamic
12 content are enclosed in <angle brackets>.
13
14 < Lines starting with "< " are received from the server.
15 > Lines starting with "> " are sent to the server. # and this is a comment
16
17 Both text refering to these variable sections and verbatim text inside
18 other paragraphs is formatted C<like this>.
19
20 =head1 OVERVIEW
21
22 =head2 SOCKET LAYER
23
24 The API uses a tcp connection to port 55 on the porttracker management
25 machine. The TCP connection must be 8-bit-clean (as UTF-8 is used as
26 character encoding) and can be driven either in binary or text mode.
27
28 Alternatively, the server also listens on the Unix socket
29 F</tmp/.tawny/.tawnyd> for local connections (where "none" is one of the
30 guaranteed auth methods).
31
32 There are currently no timeouts for the connection itself, but TCP
33 keepalive might be enabled server-side.
34
35 =head2 PACKAGE ENCAPSULATION LAYER
36
37 The protocol is based on sending and receiving JSON arrays encoded as
38 UTF-8. The server expects JSON arrays to be sent back-to-back, without any
39 separators, but for testing purposes it is often convenient to end JSON
40 arrays with ASCII LF (or ASCII CR LF) characters ("newline"), effectively
41 treating it as a line-based protocol.
42
43 To support programming languages without incremental JSON parsers,
44 the server will append an ASCII LF character to each JSON array and
45 additionally will make sure that its replies will never contain any ASCII
46 LF characters, so instead of directly parsing the JSON stream, the client
47 may also read single lines and then decode the JSON array contained in
48 each line.
49
50 Note 1: This means that one can use C<telnet> or a similar program to test
51 the protocol, as the server ignores ASCII CR and LF characters but sends
52 its responses as single lines.
53
54 Note 2: There are two principal parsing strategies: the obvious one is to
55 read a single (potentially very large) line and then decode it, and the
56 less obvious one is to use a streaming parser and simply read JSON arrays
57 one after each other.
58
59 =head2 MESSAGE LAYER
60
61 Server and client can send messages to each other at any time (usually the
62 client first has to wait and parse the initial server greeting, though, to
63 see what kind of authentication is required).
64
65 All messages are JSON arrays in one of the following formats:
66
67 [<id>, <type>, <args...>] # client request
68 [<id>, <status>, <args...>] # server response
69 [null, <type>, <args...>] # server notification
70
71 The first member, C<id>, identifies the request/response pair: Each
72 request the client sends has to use a unique ID not currently in use
73 by any request that is still ongoing. Any string or number can be
74 used for the C<id> value. The C<type> member is a string indicating
75 the type of request to the server. The remaining members (if any) are
76 request-specific.
77
78 Each server response to a request will use the same C<id> value as the
79 request. The second member, C<status>, is either C<0> for failure,
80 followed by an error message and optionally more information, or C<1> for
81 success and request-specific return values.
82
83 The protocol supports pipelining (sending multiple requests without
84 processing any replies) and responses to a request can come in any
85 order. Most requests will be handled in parallel, only some (like the
86 login messages) are guaranteed to get processed in order.
87
88 If the first member is the JSON C<null> value, then the message is a
89 server notification and the C<type> member identified the notification
90 type. This mechanism is used for the initial server greeting and any fatal
91 errors (such as wrongly formatted client requests).
92
93 Note: The type model used for JSON is "soft", that is, numbers might
94 sometimes be returned as strings, and vice versa. The only values in the
95 protocol where you can be sure of the type are the C<id> and status return
96 values, for other values you have to be liberal in what you accept.
97
98
99 =head1 SESSION STRUCTURE
100
101 When connecting, the server sends a server greeting notification
102 ("hello"), informing the client of the protocol version, whether
103 authentication is required and which kind of authentication is supported.
104
105 If the server indicated that authentication is required, the client will
106 then have to send login requests until it successfully authenticated.
107
108 After that, the server will continue serving client requests.
109
110 To end a session, the client just should simply drop the connection.
111
112
113 =head1 EXAMPLE SESSION
114
115 < [null,"hello",1,["login"]]
116 Server sent the initial greeting and requests the
117 use of a login request for authentication.
118
119 > ["someid", "realm_poll", 5100005442]
120 < ["someid",0,"you need to authenticate first"]
121 Most requests are only valid once logged-in.
122
123 > [100, "login", "username", "password"]
124 < [100,1]
125 The client sent a login request with credentials,
126 and the server accepted them.
127
128 > ["someid", "realm_poll", 5100005442]
129 Starts a poll, which takes a long time.
130
131 > [3, "ping"]
132 < [3,1,1202674637.64799,17372]
133 Ping simply returns a timestamp and the daemon pid as fast as possible.
134
135 > ["someid",1,{"port_updates":"2","device_seens":"88","device_inserts":"9","switch_updates":"3","port_seens":"73"}]
136 The result of the poll, with some statistical data.
137
138
139 =head1 MESSAGE TYPES
140
141 Messages might contain more than the documented number of array
142 members. If that is the case, the application must simply ignore them.
143
144 =head2 NOTIFICATIONS
145
146 =over 4
147
148 =item "hello" - initial server greeting
149
150 < [null, "hello", <version>, [<auth-types...>], <nonce>]
151
152 The server usually sends this notification after the initial connect and
153 never thereafter. The C<version> argument specified the protocol version
154 (always C<1>), the C<auth-types> argument is an array of authentication
155 types that the server accepts (there can be more than one). The nonce can
156 be used to securely authenticate, and is base64-encoded.
157
158 Before a client is authenticated, all other requests will fail.
159
160 The defined authentication types are:
161
162 =over 4
163
164 =item "none"
165
166 No additional authentication is required, the client can simply
167 start sending other requests. This is available when the server
168 detects a "secure" connection, e.g. from the local host, or when other
169 authentication methods are used, such as an SSL certificate or IP-based
170 authentication.
171
172 =item "login"
173
174 The client may use password authentication by sending a login request
175 (described later).
176
177 =item "login_cram_md6"
178
179 The client may use a challenge response mechanism based on MD6 to authenticate.
180
181 =back
182
183 =item "info" - an informational message
184
185 < [null, "info", <informational-message>]
186
187 The server sends an informational message. These can be ignored by the
188 client, or logged, depending on taste.
189
190 =item "error" - a fatal error has occured
191
192 < [null, "error", <error-message>]
193
194 A fatal error has occurred. This should be logged, and the connection
195 should probably be closed if the cause cannot be identified, as this
196 signifies fatal events such as a non-decodable request or runtime errors
197 in the server.
198
199 =item "start_tls" - TLS negotiation starts
200
201 < [null, "start_tls"]
202
203 This notice is sent when the server wants to start TLS/SSL negotiation,
204 either because the server requires TLS to proceed, or because the client
205 requested it via a C<start_tls> request.
206
207 TLS negotiation will start directly after the final ASCII LF ending the
208 notice. The protocol will continue as normal after the TLS handshake.
209
210 =back
211
212
213 =head2 REQUESTS AND RESPONSES
214
215 =over 4
216
217 =item "login" - username/password-based authentication
218
219 > [<id>, "login", <username>, <password>]
220 < [<id>, 1]
221
222 Tries to log-in with the given username and password. The username
223 and password must belong to a valid admin user configured in the user
224 interface.
225
226 =item "login_cram_md6" - secure username/password-based authentication
227
228 > [<id>, "login_cram_md6", <username>, <cr>, <cc>]
229 < [<id>, 1, <sr>]
230
231 Tries to securely login with a username and password. First, a shared key
232 is calculated, by using (all MD6 invocations are with blocksize 64 and
233 hashsize 256):
234
235 key = hmac_md6 (password, username) # as defined by RFC 2104
236
237 Then, the client generates a a nonce of any length (empty nonces are ok),
238 called C<cc>. Then it calculates C<cr> using the C<key>, C<cc> and the
239 server C<nonce> as follows ("+" means concatenation):
240
241 cr = hmac_md6 (key, cc + nonce)
242
243 Then it sends both C<cr> and C<cc> in the login request, base64-encoded.
244
245 If authentication is successful, the server responds with a base64-encoded
246 C<sr>:
247
248 sr = hmac_md6 (key, nonce + cc)
249
250 If the client used a non-empty C<cc>, then it can use the C<sr> value to
251 shield against man-in-the-middle attacks by comparing it with its own
252 calculation.
253
254 Test vectors:
255
256 nonce/base64 = YWVlYWJkZjQzMWEzYWM2
257 username/text = user
258 password/text = pass
259 key/base64 = C1JQ4jnjsrBzJtTZXt8Po+wA/iXtaM5r4BIIjl0lfMA
260 cc/base64 = ZmZiOTczMjE=
261 cr/base64 = 5UJKUqehqBKwXiSk6RzYjsPWqivMJcEgE2crTLVyw04
262 sr/base64 = gGKEpOuv5WuuQ7ZbwDWNIdyJtAnCimVN/faM5qWtOZM
263
264 =item "ping" - ping the server, return some informational data
265
266 > [<id>, "ping"]
267 < [<id>, 1, <timestamp>, <server-pid>]
268
269 =item "start_tls" - request SSL/TLS handshake
270
271 > [<id>, "start_tls"]
272 < [null, "start_tls"]
273 <--tls negotiation-->
274 < [<id>, 1]
275
276 This request request TLS negotiation. If accepted, the server replies
277 first with a C<start_tls> notification, followed by the TLS handshake,
278 followed by the request reply. If TLS is rejected, then there will be no
279 notification and no handshake, just the reply.
280
281
282 The client must not send anything after sending this request until
283 the server sends a C<start_tls> notification (i.e. nothing must be
284 written after the closing C<]> until either a reply or a notification is
285 received).
286
287 The handshake must be started immediately after the final ASCII LF that
288 ends the notification reply.
289
290 Note that it is quite possible to receive other responses and
291 notifications before the TLS notification is received.
292
293 =item "product_id" - return the product id
294
295 > [<id>, "product_id"]
296 < [<id>, 1, <branding>, <product-id>]
297
298 Example:
299
300 > [1,"product_id"]
301 < [1,1,"n","00:1d:60:e8:6e:36"]
302
303 Returns the branding (e.g. "n" for Porttracker, "i" for PortIQ) and
304 product ID for licencing purposes.
305
306 =item "set_license" - configure a new licence
307
308 > [<id>, "set_license", <license-string>]
309 < [<id>, <status>]
310
311 Configures the given licence string as new licence for the box. Returns
312 successful if the licence is valid, fails otherwise.
313
314 Setting the license requires admin privileges.
315
316 =item "realm_info" - information about realms
317
318 > [<id>, "realm_info", [<fields...>], [<realms...>]]
319 < [<id>, 1, [ [<fields...>]... ]]
320
321 Example:
322
323 > [1,"realm_info",["gid","description","polling","name","seeds"]]
324 < [1,1,["5000015442","","0","Realm Name","192.168.33.19"]]
325
326 > [1, "realm_info", ["gid", "discovery_result", "poll_result", "sync_result"]]
327 < [1,1,["64424509927",{"infrastructure":13},{"poll":{"infrastructure":13,
328 "ports":"339","end":"79"}},{"sync":{"qsync":null,"bsync":"Success"}}]]
329
330 Requests information about the given realms (or all realms if specified as
331 C<null>). The following fields can be requested, and their contents will be
332 returned in the order specified in the C<fields> array:
333
334 =over 4
335
336 =item gid - the gid (id value) identifying the realm
337
338 =item name - the user-specified name of the realm
339
340 =item description - the user-specified description for this realm
341
342 =item last_discover - timestamp of last discover run
343
344 =item last_poll - timestamp of last poll run
345
346 =item last_sync - timestamp of last sync run
347
348 =item polling - 0 (not polling) or 1 (currently polling)
349
350 =item syncing - 0 (not syncing) or 1 (currently syncing)
351
352 =item seeds - the seed list (whitespace-separated list of seed devices)
353
354 =item pollers - a list of poller-gids of pollers attached to the realm
355
356 =item discovery_result - a hash with key as infrastructure and value as number of devices discovered
357
358 =item poll_result - a hash with keys infrastructure, ports and end and values as their counts
359
360 =item sync_result - a hash with keys qsync and bsync and values as their results
361
362 =item ageing_interval - ping sweep interval for this realm.
363
364 =back
365
366 =item "realm_info_modify" - edits the given realm
367
368 > [<id>, "realm_info_modify", <realm-gid>, {<prop>:<value>,...}]
369 < [<id>, 1]
370
371 A property hash followed by a realm gid. Keys of the hash are name,
372 description, discovery_poller and ageing_interval.
373
374 Example:
375
376 > [1, "realm_info_modify", "38952865423", {"name":"default-1"}]
377 < [1, 1]
378
379 =item "realm_modify" - adds and/or deletes realms
380
381 > [<id>, "realm_modify", [delete-ids...], [[add-realm],...]]
382 < [<id>, 1]
383
384 Two arrays expected as input. First array is a list of realm gids needs to be deleted.
385 Second array is a list of realm needs to be added. An array per realm can contain
386 realm name and description.
387
388 Example:
389
390 > [1, "realm_modify", ["38456782341"], [["Test Realm", "for test"]]]
391 < [1, 1]
392
393 =item "realm_discover" - run discovery on a given realm
394
395 > [<id>, "realm_discover", <realm-gid>]
396 < [<id>, 1]
397
398 =item "realm_poll" - run a poll on a given realm
399
400 > [<id>, "realm_poll", <realm-gid>]
401 < [<id>, 1, { <statistical data> } ]
402
403 =item "switch_poll" - run a poll on a given realm and switch ip
404
405 > [<id>, "switch_poll", <realm-gid>, <switch ip>]
406 < [<id>, 1, { <statistical data> } ]
407
408 =item "realm_sync" - run a sync on a given realm and plugin
409
410 > [<id>, "realm_sync", <realm-gid>, <sync module>]
411 < [<id>, 1]
412
413 The C<sync module> can be either bsync or qsync.
414
415 =item "realm_query" - query the database
416
417 This request executes a database query with filtering, much like the
418 device and switch views work in the user interface.
419
420 > [<id>, "realm_query", <realm-gid>, <type>
421 [<column-name>...], [<raw-column-name]>...],
422 {<column-name> : <filter-expression>...},
423 <history mask>,
424 {<port unused period> : <unused value>}
425 ]
426 < [<id>, 1, [ [<result-data>]... ]]
427
428 The C<realm-gid> is the GID of the realm to query, as returned by
429 C<real_info>. The C<type> is the string C<device>, C<switch> or
430 C<switch_detail>, which corresponds to the device view, switch view or
431 switch detail view.
432
433 The first array of C<column-name>s specifies which columns should be
434 returned. The second array of C<raw-column-name>s works likewise, but
435 the values returned will be the "raw" (possibly octet-encoded) database
436 contents. Specifying the same column name in both array causes undefined
437 behaviour.
438
439 The hash of C<column-name> => C<filter-expression> pairs specifies
440 additional filters. The syntax for the C<filter-expression> is the same as
441 the ones used by the GUI.
442
443 The C<history mask> is the history selection option.
444 Value 0 means C<current>, value 1 means C<All> and value 2 means
445 C<All+Changes>. Default value is 0.
446
447 The hash of C<port unused period> => C<unused> pairs specifies
448 port unused time. The C<port unused period> can be days, months or years.
449
450 The reply contains an array of result rows. Each row consists of data
451 values using the same ordering as in the requested column-name arrays, raw
452 columns last.
453
454 The (JSON) type of each column depends on the column itself, and can vary
455 between rows.
456
457 =over 4
458
459 =item valid columns for "device" query
460
461 vlanname, port_pktcount, linkduplex, port_mac, device_log_end,
462 port_errorcount, vtpdomain, switch_ip, device_log_start,
463 linkstatus, linkspeed, device_mac, history_device, linkadminduplex,
464 ifname, device_comment, device_notes, vlan, device_dnsname,
465 ifalias, switch_uid, ifdescr, linkadminstatus,
466 port_error_percentage, device_ip
467
468 =item valid columns for "switch" query
469
470 number_ports, switch_action, switch_syslocation,
471 free_ports_percentage, switch_sysservices, switch_dnsname,
472 history_switch, switch_log_end, switch_pollduration, switch_model,
473 available_ports_percentage, switch_comment, ports_lastchange,
474 switch_ip, switch_sysdescr, switch_notes, available_ports,
475 poe_ports, switch_log_start, switch_uid, switch, free_ports
476
477 =back
478
479 Example:
480
481 > [1, "realm_query", "5100005442", "device",
482 ["switch_uid", "device_ip"],
483 ["device_mac"],
484 { "switch_uid" : "switch03%" }]
485 < [1,1,[["switch03.ibm.de","192.168.40.11","\u00000B\u0006D^"],...
486
487 =item valid columns for "switch_detail" view
488
489 port_pktcount, history_port, linkduplex, port_mac, port_comment,
490 port_log_start, port_errorcount, port_log_end,
491 detected_devices_current, linkstatus, linkspeed, linkadminduplex,
492 ifname, port_action, poe_power, ifalias, switch_uid, poe_status, switch,
493 ifdescr, linkadminstatus, port_error_percentage
494
495 Example:
496
497 > [5, "realm_query", "5100005442", "switch_detail",
498 ["ifname"], [],
499 { "switch" : 27 }]
500 < [5,1,[["Fa0/11"],["Fa0/21"], ... ,["Fa0/5"]]]
501
502 =item "user_view_info" - return the available views list
503
504 This request returns the report views list for the logged-in user.
505
506 > [<id>, "user_view_info", [<field-list>], [<type-list>]]
507 < [<id>, 1, [ [<fields>, ...], ...]]
508
509 Valid fields are C<name> and C<gid> and valid types are C<switch>,
510 C<port> and C<device>. The reply will contains an array for each view.
511
512 Example:
513
514 > [1, "user_view_info", ["gid", "name"]]
515 < [1,1,[["107374182462","Ports:Default"],
516 ["94489280669","Ports:Multiple Devices on Port"],
517 ["107374182460","End Devices:Default"],
518 ["3865500631171226","End Devices:test"],
519 ["3865500631171236","End Devices:tns04"]]]
520
521 =item "realm_view" - query database with given view in a given realm
522
523 This request returns the database entries for the given view and the realm.
524
525 > [<id>, "realm_view", <realm-gid>, <view-gid>]
526 < [<id>, 1,[ [<result-data>]]]
527
528 Valid view gid should be given followed by a valid realm gid.
529 The reply will contain the results from database query and one array per
530 database row.
531
532 Example:
533
534 > [1, "realm_view", "64424509927", "107374182461"]
535 < [1,1,[["tnsw04.uk.internal","S","26","15","15","58","0","2009-12-08 12:17:00",
536 "2009-12-08 12:17:00",null],["tnsw05.uk.internal","S","26","20","20"
537 ,"77","0","2009-12-08 12:17:00","2009-12-08 12:17:00",null]]]
538
539 =item "realm_seed_list" - return the seed list
540
541 This request returns the seed list for the given realm.
542
543 > [<id>, "realm_seed_list", <realm-gid>]
544 < [<id>, 1, [ [<ip>, <flags>]... ]]
545
546 The reply contains an array with all configured seed devices. Each device
547 is represented by an array with the IP address in textual form and a flags
548 bitset. The only defined bit value (not number) is C<2>, which indicates a
549 manually-added seed entry.
550
551 Example:
552
553 > [1, "realm_seed_list", "5100005442"]
554 < [1,1,[["192.168.40.11",0],["192.168.40.1",2]]]
555
556 =item "realm_seed_list_modify" - add/remove seed list entries
557
558 This request modifies the seed list for a realm.
559
560 > [<id>, "realm_seed_list_modify", <realm-gid>, [<delete-ip>...], [<add-ip>...>]]
561 < [<id>, 1]
562
563 The two arrays after the realm-gid specify the IP addresses (in textual
564 form) of seed entries to remove, followed by a list of IP addresses to be
565 added afterwards. Newly added IP addresses will have the manual flag set on them.
566
567 Example: set the manually-added flag on 10.0.0.5, or add it if it didn't
568 exist yet.
569
570 > [1, "realm_seed_list_modify", "5100005442", ["10.0.0.5"], ["10.0.0.5"]]
571 < [1,1]
572
573 =item "realm_snmp_credential_list" - list snmp credentials
574
575 This request returns the snmp credentials for the given realm.
576
577 > [<id>, "realm_snmp_credential_list", <realm-gid>]
578 < [<id>, 1, [ [<subnet>, <bits>, [ 2, [<community>...], [3, <v3 settings>] ], <flags>]... ]]
579
580 The reply contains an array with all configured snmp credentials, one per
581 subnet. Each snmp credential will contain the subnet address in textual
582 form, the leading number of significant bits in the subnet (0..32 for
583 IPv4, 0..128 for IPv6), an array per snmp v2 and v3 settings and a flags bitset
584 (bit value C<1> means it is an include, otherwise it is an exclude).
585 v2 array starts with bit value C<2> means it is version v2 and followed by an array
586 of community strings. v3 array starts with bit value C<3> means it is version v3 and
587 followed by v3 user name, authentication password, privacy password, authentication
588 algorithm and privacy algorithm.
589
590 Example:
591
592 > [1, "realm_snmp_credential_list", "5100005442"]
593 < [1,1,[ ["10.1.0.0",16,[[2,["test"]], [3,"authPrivUser","authpass","privpass","md5","aes"]],1] ]]
594
595 =item "realm_snmp_credential_list_modify" - modify snmp credentials
596
597 Removes and/or adds snmp credential entries.
598
599 > [<id>, "realm_snmp_credential_list_modify", <realm-gid>, [<remove-subnet>], [<add-subnet>...]]
600 < [<id>, 1]
601
602 The two arrays after the realm-gid specify a list of subnet addresses to
603 remove (only exact matches wil be removed) and a list of subnet-entries to
604 be added afterwards. Each entry in the <add-subnet> list follows the same
605 format as returned by C<realm_snmp_credentials>.
606
607 Example:
608 > [1, "realm_snmp_credential_list_modify", "5100005442", [ ["10.0.0.0", 8], ["11.1.1.0", 24] ],
609 [ ["192.168.240.0", 24, [2, ["w0rld", "peace"], [3, "noAuthUser"]], 1] ]]
610 < [1, 1]
611
612 =item "realm_device_assignment_list" - list all assignable devices for a realm
613
614 This request returns all assignable devices.
615
616 > [<id>, "realm_device_assignment", <realm-gid>]
617 < [<id>, 1, [ [<ip>, <poller-gid>] ]]
618
619 The reply contains an array with all assignable devices in a realm. Each
620 device entry will contain the device IP address in textual form, and
621 the gid of the poller it is assigned to, or C<null> if the device isn't
622 currently assigned.
623
624 Example:
625
626 > [1, "realm_device_assignment_list", "64424509927"]
627 < [1,1,[ ["192.168.71.21",null],["192.168.75.2",null],["1.1.1.1",64424509930],["5.5.5.5",64424509930]] ]
628
629 =item "realm_device_assign" - assign a device to a poller
630
631 Assigns or unassigns a device, or all devices.
632
633 > [<id>, "realm_device_assign", <realm-gid>]
634 < [<id>, 1]
635
636 > [<id>, "realm_device_assign", <realm-gid>, [<device-ip>, <poller-gid>]]
637 < [<id>, 1]
638
639 If only a realm-gid is specified and device and poller-gid are missing,
640 then all devices get auto-assigned to pollers, if possible.
641
642 Otherwise, the specified device will be assigned to the specified
643 C<poller-gid>, or unassigned if C<poller-gid> is C<null>.
644
645 Example:
646
647 > [1, "realm_device_assign", "64424509927"]
648 < [1, 1]
649
650 > [1, "realm_device_assign", "64424509927", ["1.1.1.1", null]]
651 < [1, 1]
652
653 > [1, "realm_device_assign", "64424509927", ["1.1.1.1", "64424509930"]]
654 < [1, 1]
655
656 =item "realm_advanced_settings" - list advanced settings of a given realm
657
658 This request returns all/specific properties and their values.
659
660 > [<id>, "realm_advanced_settings", <realm-gid>, [<property>,...]]
661 < [<id>, 1, [[<property>, <value>]...]]
662
663 If only the realm-gid is specified then all the properties and their values returned.
664
665 valid properties are
666
667 block_port_macs, stp_enabled, cdp_enabled, lldp_enabled
668
669 Example:
670
671 > [1, "realm_advanced_settings", "64424509927", ["cdp_enabled"]]
672 < [1,1,[["cdp_enabled","1"]]]
673
674 =item "realm_advanced_settings_modify" - modify advanced settings of a given realm
675
676 This request modifies advanced settings of a given realm-gid.
677
678 > [<id>, "realm_advanced_settings_modify", <realm-gid>, [[<property>, <value>]...]]
679 < [<id>, 1]
680
681 > [<id>, "realm_advanced_settings_modify", <realm-gid>, [[<property>, [<delete-list>], [<add-list>]]]]
682 < [<id>, 1]
683
684 realm-gid followed by a array of property and value pairs. one array for each property
685 and value pair.
686
687 block_port_macs property expects two arrays in place of value. First array is a list of
688 macs needs to be deleted from port exclusion list and second array is a list of
689 macs needs to be added into port exclusion list. MAC addresses should be in the following
690 format "AA:BB:CC:DD:EE:FF".
691 When no array given for block_port_macs property all the macs from port exclusion list
692 will get deleted.
693
694 Example:
695
696 > [1, "realm_advanced_settings_modify", "64424509927", [["cdp_enabled", "0"]]]
697 < [1, 1]
698
699 > [1, "realm_advanced_settings_modify", "64424509927", [["block_port_macs",
700 ["11:00:0a:0b:11:22"], ["0a:11:22:44:0e:0b"]]]]
701 < [1, 1]
702
703 =item "poller_info" - - information about pollers
704
705 > [<id>, "poller_info", [<fields...>], [<pollers...>]]
706 < [<id>, 1, [ [<fields...>]... ]]
707
708 Example:
709
710 > [1, "poller_info", ["gid", "name", "description", "hostname"]]
711 < [1,1,[["64424509930","localhost","localhost","127.0.0.1"]]]
712
713
714 Requests information about the given pollers (or all pollers if specified as
715 C<null>). The following fields can be requested, and their contents will be
716 returned in the order specified in the C<fields> array:
717
718 =over 4
719
720 =item gid - the gid (id value) identifying the poller
721
722 =item name - the user-specified name of the poller
723
724 =item description - the user-specified description for this poller
725
726 =item hostname - hostname/ip of this poller
727
728 =item dns_max_outstanding - maximum number of dns queries for this poller
729
730 =back
731
732 =item "poller_modify" - adds and/or deletes pollers
733
734 This request adds and/or deletes given pollers.
735
736 > [<id>, "poller_modify", <realm-gid>, [<delete-gid>, ...],
737 [[<name>, <description>, <hostname>, <secret>], ...]]
738 < [<id>, 1]
739
740 Two arrays followed by a realm gid. First array is a list of poller gids
741 needs to be deleted. Second array is a list of pollers needs to be added.
742 An array per poller should contain poller name, description, hostname and
743 secret password.
744
745 Example:
746
747 > [1, "poller_modify", "385611201213", ["98456723211"], [["test1",
748 "Test poller", "127.0.0.1", "test"]]]
749 < [1, 1]
750
751 =item "poller_info_modify - edits the given poller
752
753 This request edits the given poller with new values.
754
755 > [<id>, "poller_info_modify", <poller-gid>, {<prop>:<value>,...}]
756 < [<id>, 1]
757
758 A property hash followed by a poller gid. Keys expected in the hash
759 are name, description, hostname, secret and dns_max_outstanding.
760
761 Example:
762
763 > [1, "poller_info_modify", "6789345621", {"name":"test1",
764 "secret":"test123", "hostname":"localhost",
765 "dns_max_outstanding":"65"}]
766 < [1, 1]
767
768 =item "poller_subnet_list" - list subnets attached to a given poller
769
770 This request returns all subnets attached to a given poller.
771
772 > [<id>, "poller_subnet_list", <poller-gid>]
773 < [<id>, 1, [ [<subnet>, <bits>, <ping-limit>, <flags>]... ]]
774
775 The reply contains an array with all configured subnets. Each subnet
776 will contain the subnet address in textual form, the leading number of
777 significant bits in the subnet (0..32 for IPv4, 0..128 for IPv6), a ping
778 limit (in kbit/s) and a flags value (bit value C<1> indicates whether the
779 subnet is exclided (C<0>) or included (C<1>), bit value C<2> indicates
780 whether pings are enabled (C<2>) or not).
781
782 Example:
783
784 > [1, "poller_subnet_list", "64424509930"]
785 < [1,1,[["1.1.1.1",32,1000,1,2],["10.1.1.1",32,1000,0,0]]]
786
787 =item "poller_subnet_list_modify" - modify subnets of a poller
788
789 Removes and/or adds subnet entries.
790
791 > [<id>, "poller_subnet_list_modify", <poller-gid>, [<remove-subnet>], [<add-subnet>...]]
792 < [<id>, 1]
793
794 The two arrays after the poller-gid specify a list of subnet addresses to
795 remove (only exact matches wil be removed) and a list of subnet-entries to
796 be added afterwards. Each entry in the <add-subnet> list follows the same
797 format as returned by C<poller_subnet_list>.
798
799 Example:
800
801 > [ 1, "poller_subnet_list_modify", "64424509930",[["1.1.1.1",32,1000,1,2],
802 ["10.1.1.1",32,1000,0,0]], [["192.168.0.0", 16, 1200, 1,2]] ]
803 < [1, 1]
804
805 =item "global_settings" - list global settings
806
807 This request returns all global settings or specific settings.
808
809 > [<id>, "global_settings"]
810 < [<id>, 1, [ [<property>, <value>]... ]]
811
812 The reply contains an array with all configured properties and values. Each property
813 and value will be in textual form.
814
815 valid properties are
816
817 normalization_algorithm, snmp_parallel_requests, session_timeout, snmp_retries,
818 agni_verbose, domain, snmp_timeout, smtp_server, skip_access_points, max_history_length,
819 smtp_user, autoassign, skip_cisco_phones, skip_mitel_phones, max_log_length
820
821 Example:
822
823 > [1, "global_settings"]
824 < [1,1,[["normalization_algorithm","loopback highest-ip lowest-ip"],
825 ["snmp_parallel_requests","10"],["session_timeout","86400"],["snmp_retries","5"],
826 ["agni_verbose",null],["domain",""],["snmp_timeout","4"],["smtp_server",""],
827 ["skip_access_points","1"],["max_history_length","0"],["smtp_user",""],["autoassign","1"],["skip_cisco_phones","1"]]]
828
829 > [1, "global_settings", ["normalization_algorithm", "session_timeout"]]
830 < [1,1,[["normalization_algorithm","loopback highest-ip lowest-ip"],["session_timeout","86400"]]]
831
832 =item "global_settings_modify" - modify global settings
833
834 This request modifies global settings. Each property modified with a new value given.
835
836 > [<id>, "global_settings_modify", [ [<property>, <value>]... ]]
837 < [<id>, 1]
838
839 one array for each property and value pair. Properties and values should be in
840 textual format.
841
842 valid properties are
843
844 normalization_algorithm, snmp_parallel_requests, session_timeout, snmp_retries,
845 agni_verbose, domain, snmp_timeout, smtp_server, skip_access_points, max_history_length,
846 smtp_user, autoassign, skip_cisco_phones, max_log_length, skip_mitel_phones, smtp_pass
847
848 Example:
849
850 > [1, "global_settings_modify", [["snmp_parallel_requests", "15"]]]
851 < [1, 1]
852
853 =item "advanced_settings" - list advanced settings
854
855 This request returns all advanced settings or specific settings.
856
857 > [<id>, "advanced_settings"]
858 < [<id>, 1, [ [<property>, <value>]... ]]
859
860 The reply contains an array with all configured properties and values. Each property
861 and value will be in textual form.
862
863 valid properties are
864
865 max_parallel_jobs, max_debug_scans, debug_level
866
867 Example:
868
869 > [1, "advanced_settings", ["max_parallel_jobs"]]
870 < [1,1,[["max_parallel_jobs","1000"]]]
871
872 =item "advanced_settings_modify" - modify advanced settings
873
874 This request modifies advanced settings. Each property modified with a new value given.
875
876 > [<id>, "advanced_settings_modify", [ [<property>, <value>]...]]
877 < [<id>, 1]
878
879 one array for each property and value pair. Properties and values should be in
880 textual format.
881
882 Example:
883
884 > [1, "advanced_settings_modify", [ ["max_parallel_jobs", "900"]]]
885 < [1, 1]
886
887
888 =item "security_misc_settings" - lists misellenous security settings
889
890 This request returns all misellenous settings or specific settings.
891
892 > [<id>, "security_misc_settings", [<property, ... ]]
893 < [<id>, 1, [<value>, ...] ]
894
895 valid properties are
896
897 login_banner enable_login_banner
898
899 Example:
900
901 > [1, "security_misc_settings", ["login_banner"]]
902 < [1,1,["This system is the property of ..."]]
903
904 =item "security_misc_settings_modify" - modifies given misellenous property
905
906 This request modifies given property with the given new value.
907
908 > [<id>, "security_misc_settings_modify", {<property> : <value>, ... }]
909 < [<id>, 1]
910
911 Example:
912
913 > [1, "security_misc_settings_modify", {"login_banner" : "Its My Box."}]
914 < [1, 1]
915
916 =item "security_certificate_list" - lists available certificates
917
918 This request returns all or given properties of all certificates.
919
920 > [<id>, "security_certificate_list", [<property>, ...] ]
921 < [<id>, 1, [ [<value>, ...] , ... ] ]
922
923 Valid properties are
924
925 name certificate
926
927 Example:
928
929 > [1, "security_certificate_list"]
930 < [1, 1, [["System Default",""],["custom", ,"-----BEGIN RSA PRIVATE KEY..."]]]
931
932 =item "security_certificate_list_modify" - adds/deletes given certificates
933
934 This request deletes and adds given certificates.
935
936 > [<id>, "security_certificate_list_modify", [<delete-list>], [[<name>, <certificate>], ...]]
937 < [<id>, 1]
938
939 delete-list contains list of certificate names.
940 add-list should have a name and certificate one array per certificate.
941
942 Example:
943
944 > [1, "security_certificate_list_modify", ["old_custom"], [["new_custom", "-----BEGIN RSA PRIVATE KEY..."]
945 ]]
946 < [1, 1]
947
948 =item "security_certificate_assignment_list" - lists all assignable certificates
949
950 This request returns all certificate name and their current status.
951 one array per certicate will be used. current status shows whether it is assigned
952 to C<apache> or C<api> or C<null> for not in use.
953
954 > [<id>, "security_certificate_assignment_list"]
955 < [<id>, 1, [ [<name>, <status>], ... ]]
956
957 Example:
958
959 > [1, "security_certificate_assignment_list"]
960 > [1,1,[["System Default","apache"],["System Default","api"],["custome",null]]]
961
962 =item "security_certificate_assign" - assigns given certificate to api or apache
963
964 This request assigns given certificate to apache or api.
965
966 > [<id>, "security_certificate_assign", [ [<name>, <assign>], ...] ]
967 < [<id>, 1]
968
969 Example:
970
971 > [1, "security_certificate_assign", [["custom", "apache"], ["custom", "api"]]]
972 < [1, 1]
973
974 =item "security_authentication_method_list" - lists authentication methods and settings
975
976 This request returns all or specified properties of all or specified authentication method.
977 First array contains the list of properties and the second array contains the list of gids
978 of methods. Result array will have one array per authentication method.
979
980 Valid properties are
981
982 name gid inuse settings
983
984 > [<id>, "security_authentication_method_list", [<properties>, ...], [<method-gid>, ...]]
985 < [<id>, 1, [ [<value>, ...], ...]]
986
987 Example:
988
989 > [1, "security_authentication_method_list", ["name"], ["90194313753", "90194313603"]]
990 < [1,1,[["RADIUS"],["Active Directory (LDAPS)"]]]
991
992 =item "security_authentication_modify" - modifies given authentication methods
993
994 This request edits given authentication method.
995 First argument is the authentication method gid.
996 All new values should be mentioned in a hash.
997
998 Valid properties are
999
1000 inuse server secret csecret domain ctrls certificate
1001
1002 bit value C<inuse> will activate/inactivate the given authentication method.
1003 C<server> is the RADIUS server for RADIUS authentication method.
1004 C<secret> and C<csecret> are secret password and confirm secret password for RADIUS server.
1005 C<domain> is the domain name for LDAP and LDAPS authentication methods.
1006 C<ctrls> is the array of delete and add lists of domain controls.
1007 C<certificate> is the valid certificate name for LDAPS authentication method.
1008 C<timeout> is the value in seconds to be used when communicating with Active Directory servers.
1009
1010 > [<id>, "security_authentication_modify", <method-gid>, {<property> : <value>,... }]
1011 < [<id>, 1]
1012
1013 Example:
1014
1015 > [1, "security_authentication_modify", "90194313753", {"inuse" : 1, "server" : "4test"}]
1016 < [1, 1]
1017
1018 > [1, "security_authentication_modify", "90194313603", {"certificate" : "custom", "domain" : "new"
1019 "ctrls" : [ ["10.1.50.1"], ["10.1.50.2"] ]}]
1020 < [1, 1]
1021
1022 =item "group_info" - lists group information
1023
1024 This request returns all groups or specific groups. The request returns all
1025 fields or specific fields.
1026
1027 > [<id>, "group_info", [<field1>, <field2>, ...], [<group-gid>, ...]]
1028 < [<id>, 1, [ [<value>, <value>, ...] , ...]
1029
1030 The reply contains an array for each group with specified field values or all.
1031
1032 Example:
1033
1034 > [1, "group_info", ["name"]]
1035 < [1,1,[["helpme"],["Network Administrator"],["Network Operator"],["Super Admin"]]]
1036
1037 =item "group_modify" - adds and/or deletes groups
1038
1039 This request adds and/or deletes given groups.
1040
1041 > [<id>, "group_modify", [<delete-gid>, ...], [[<name>, <description>], ...]]
1042 < [<id>, 1]
1043
1044 Two arrays expected as input. First array is a list of group gids needs to be deleted.
1045 Second array is a list of groups needs to be added. An array per group should contain
1046 group name and description.
1047
1048 Example:
1049
1050 > [1, "group_modify", ["9845672231"], [["test1", "Test group"]]]
1051 < [1, 1]
1052
1053 =item "group_settings" - lists permissions for a given group
1054
1055 > [<id>, "group_settings", <group-gid>, [<role>, <role>, ...], [<realm-gid>, ...]]
1056 < [<id>, 1, [[[<system-role>, <permission>], ...],
1057 [[<realm-gid>, [[<realm-role>, <permission>], ...]], ...]]]
1058
1059 The input should have a valid group gid in textual format. Two arrays followed by group gid
1060 are list of roles and list of realm gids. These two arrays are optional.
1061 The result contains two arrays. First array is for system specific roles. One array per role.
1062 Second array is for realm specific roles. One array per realm. First element of the array is
1063 realm-gid in textual format followed by an array of realm specific roles and their permission.
1064 Permission will be referred in bit value. bit value C<0> means NO Access, C<1> means
1065 Read Access and C<2> means Read/Write Access.
1066
1067 Example:
1068
1069 > [1, "group_settings", "98784248728"]
1070 < [1,1,[[["API",2],["Add Realms",2],["Advanced Settings",1],["Global Settings",2]]
1071 ,[["3865500631171652",[["Advanced Realm Settings",0],["Assign Devices",0]]]]]]
1072
1073 > [1, "group_settings", "98784248728", ["Add Realms", "Assign Devices"]]
1074 < [1,1,[[["Add Realms",2]],[["3865500631171652",[["Assign Devices",0]]],
1075 ["3865500631171517",[["Assign Devices",0]]]]]]
1076
1077
1078 =item "group_settings_modify" - edits group properties and permissions
1079
1080 > [<id>, "group_settings_modify", <group-gid>
1081 , {"name":<group-name>, "description":<group description>}
1082 , [[<system-role>, <permission>], ...], [[<realm-gid>,
1083 [[<realm-role>, <permission>], ...]], ...] ]
1084 < [<id>, 1]
1085
1086 The input should have a valid group gid. A property hash followed by the group gid.
1087 The values of keys C<name> and C<description> are new group name and description.
1088 Two arrays followed by hash. First array is for system specific roles. Format of the
1089 array is same as output of C<group_settings> query. Second array is for realm specific roles.
1090 One array per realm. Format of this array is same as output of C<group_settings> query.
1091
1092 valid system specific roles are
1093
1094 "API", "Add Realms", "Advanced Settings", "Global Settings", "Group Management", "License",
1095 "Schedule Backup", "Security Settings", "System Utilities", "User Management", "View Log"
1096
1097 valid realm specific roles are
1098
1099 "Advanced Realm Settings", "Assign Devices", "Discovery Realm Settings", "Views",
1100 "Plugins", "Poller Settings", "Schedule Discovery","Schedule Poll","Schedule Report"
1101 ,"Schedule Sync"
1102
1103 Example:
1104
1105 > [1, "group_settings_modify", "98784248723", {"name":"TEST"},
1106 [["Add Realms",0]]], [["386550063117151",[["Poller Setting",1]]]]]
1107 < [1, 1]
1108
1109
1110 > [1, "group_settings_modify", "98784248723", {},
1111 [["Add Realms",0],["Global Settings",1]]]
1112 < [1, 1]
1113
1114
1115 =back
1116
1117 =head1 AUTHOR
1118
1119 Marc Lehmann <marc@nethype.de>.
1120