ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-Porttracker/Porttracker/protocol.pod
Revision: 1.3
Committed: Tue Nov 16 01:10:50 2010 UTC (15 years, 11 months ago) by root
Branch: MAIN
CVS Tags: rel-0_1
Changes since 1.2: +55 -0 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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 root 1.2 There are currently no timeouts for the connection itself, but TCP
33     keepalive might be enabled server-side.
34    
35 root 1.1 =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 root 1.3 =item "event" - subscribed system event
211    
212     < [null, "event", <type>, <args...>]
213    
214     This notice is sent each time an event occurs that the session is
215     subscribed to (see C<subscribe> and C<unsubscribe> commands).
216    
217     Currently known events are:
218    
219     =over 4
220    
221     =item realm_discover_start realm-gid
222    
223     Called with the GID of the realm that has just started a discovery process.
224    
225     =item realm_discover_stop realm-gid
226    
227     Called with the GID of the realm that has just finished a discovery process.
228    
229     =item realm_poll_start realm-gid
230    
231     Called with the GID of the realm that has just started a poll process.
232    
233     =item realm_poll_stop realm-gid
234    
235     Called with the GID of the realm that has just finished a poll process.
236    
237     =back
238    
239 root 1.1 =back
240    
241    
242     =head2 REQUESTS AND RESPONSES
243    
244     =over 4
245    
246     =item "login" - username/password-based authentication
247    
248     > [<id>, "login", <username>, <password>]
249     < [<id>, 1]
250    
251     Tries to log-in with the given username and password. The username
252     and password must belong to a valid admin user configured in the user
253     interface.
254    
255     =item "login_cram_md6" - secure username/password-based authentication
256    
257     > [<id>, "login_cram_md6", <username>, <cr>, <cc>]
258     < [<id>, 1, <sr>]
259    
260     Tries to securely login with a username and password. First, a shared key
261     is calculated, by using (all MD6 invocations are with blocksize 64 and
262     hashsize 256):
263    
264     key = hmac_md6 (password, username) # as defined by RFC 2104
265    
266     Then, the client generates a a nonce of any length (empty nonces are ok),
267     called C<cc>. Then it calculates C<cr> using the C<key>, C<cc> and the
268     server C<nonce> as follows ("+" means concatenation):
269    
270     cr = hmac_md6 (key, cc + nonce)
271    
272     Then it sends both C<cr> and C<cc> in the login request, base64-encoded.
273    
274     If authentication is successful, the server responds with a base64-encoded
275     C<sr>:
276    
277     sr = hmac_md6 (key, nonce + cc)
278    
279     If the client used a non-empty C<cc>, then it can use the C<sr> value to
280     shield against man-in-the-middle attacks by comparing it with its own
281     calculation.
282    
283     Test vectors:
284    
285     nonce/base64 = YWVlYWJkZjQzMWEzYWM2
286     username/text = user
287     password/text = pass
288     key/base64 = C1JQ4jnjsrBzJtTZXt8Po+wA/iXtaM5r4BIIjl0lfMA
289     cc/base64 = ZmZiOTczMjE=
290     cr/base64 = 5UJKUqehqBKwXiSk6RzYjsPWqivMJcEgE2crTLVyw04
291     sr/base64 = gGKEpOuv5WuuQ7ZbwDWNIdyJtAnCimVN/faM5qWtOZM
292    
293     =item "ping" - ping the server, return some informational data
294    
295     > [<id>, "ping"]
296     < [<id>, 1, <timestamp>, <server-pid>]
297    
298     =item "start_tls" - request SSL/TLS handshake
299    
300     > [<id>, "start_tls"]
301     < [null, "start_tls"]
302     <--tls negotiation-->
303     < [<id>, 1]
304    
305     This request request TLS negotiation. If accepted, the server replies
306     first with a C<start_tls> notification, followed by the TLS handshake,
307     followed by the request reply. If TLS is rejected, then there will be no
308     notification and no handshake, just the reply.
309    
310    
311     The client must not send anything after sending this request until
312     the server sends a C<start_tls> notification (i.e. nothing must be
313     written after the closing C<]> until either a reply or a notification is
314     received).
315    
316     The handshake must be started immediately after the final ASCII LF that
317     ends the notification reply.
318    
319     Note that it is quite possible to receive other responses and
320     notifications before the TLS notification is received.
321    
322     =item "product_id" - return the product id
323    
324     > [<id>, "product_id"]
325 root 1.2 < [<id>, 1, <branding>, <product-id>]
326 root 1.1
327     Example:
328    
329     > [1,"product_id"]
330     < [1,1,"n","00:1d:60:e8:6e:36"]
331    
332 root 1.2 Returns the branding (e.g. "n" for Porttracker, "i" for PortIQ) and
333     product ID for licencing purposes.
334 root 1.1
335 root 1.3 =item "subscribe" - subscribe to system events
336    
337     > [<id>, "subscribe", <events...>]
338     < [<id>, <status>]
339    
340     Tries to subscribe to the specified events (see the C<event> notification
341     earlier in this document for a list of supported events). As a special
342     case, the event named C<*> matches all events.
343    
344     =item "unsubscribe" - unsubscribe from system events
345    
346     > [<id>, "unsubscribe", <events...>]
347     < [<id>, <status>]
348    
349     Unsubscribes from the specified events - no further events of the
350     specified types will be received by this session.
351    
352     =item "log" - log a message
353    
354     > [<id>, "log", <message>, <priority>]
355     < [<id>, <status>]
356    
357     Logs the given message as if tawnyd had logged it. The C<priority> is a
358     standard syslog priority, ranging from C<0> (C<emerg>) to 7 (C<debug>). IF
359     it is missing, then the message will be logged with priority C<info>.
360    
361 root 1.1 =item "set_license" - configure a new licence
362    
363 root 1.2 > [<id>, "set_license", <license-string>]
364 root 1.1 < [<id>, <status>]
365    
366     Configures the given licence string as new licence for the box. Returns
367     successful if the licence is valid, fails otherwise.
368    
369     Setting the license requires admin privileges.
370    
371     =item "realm_info" - information about realms
372    
373     > [<id>, "realm_info", [<fields...>], [<realms...>]]
374     < [<id>, 1, [ [<fields...>]... ]]
375    
376     Example:
377    
378     > [1,"realm_info",["gid","description","polling","name","seeds"]]
379     < [1,1,["5000015442","","0","Realm Name","192.168.33.19"]]
380    
381     > [1, "realm_info", ["gid", "discovery_result", "poll_result", "sync_result"]]
382     < [1,1,["64424509927",{"infrastructure":13},{"poll":{"infrastructure":13,
383     "ports":"339","end":"79"}},{"sync":{"qsync":null,"bsync":"Success"}}]]
384    
385     Requests information about the given realms (or all realms if specified as
386     C<null>). The following fields can be requested, and their contents will be
387     returned in the order specified in the C<fields> array:
388    
389     =over 4
390    
391     =item gid - the gid (id value) identifying the realm
392    
393     =item name - the user-specified name of the realm
394    
395     =item description - the user-specified description for this realm
396    
397     =item last_discover - timestamp of last discover run
398    
399     =item last_poll - timestamp of last poll run
400    
401     =item last_sync - timestamp of last sync run
402    
403     =item polling - 0 (not polling) or 1 (currently polling)
404    
405     =item syncing - 0 (not syncing) or 1 (currently syncing)
406    
407     =item seeds - the seed list (whitespace-separated list of seed devices)
408    
409     =item pollers - a list of poller-gids of pollers attached to the realm
410    
411     =item discovery_result - a hash with key as infrastructure and value as number of devices discovered
412    
413     =item poll_result - a hash with keys infrastructure, ports and end and values as their counts
414    
415     =item sync_result - a hash with keys qsync and bsync and values as their results
416    
417     =item ageing_interval - ping sweep interval for this realm.
418    
419     =back
420    
421     =item "realm_info_modify" - edits the given realm
422    
423     > [<id>, "realm_info_modify", <realm-gid>, {<prop>:<value>,...}]
424     < [<id>, 1]
425    
426     A property hash followed by a realm gid. Keys of the hash are name,
427     description, discovery_poller and ageing_interval.
428    
429     Example:
430    
431     > [1, "realm_info_modify", "38952865423", {"name":"default-1"}]
432     < [1, 1]
433    
434     =item "realm_modify" - adds and/or deletes realms
435    
436     > [<id>, "realm_modify", [delete-ids...], [[add-realm],...]]
437     < [<id>, 1]
438    
439     Two arrays expected as input. First array is a list of realm gids needs to be deleted.
440     Second array is a list of realm needs to be added. An array per realm can contain
441     realm name and description.
442    
443     Example:
444    
445     > [1, "realm_modify", ["38456782341"], [["Test Realm", "for test"]]]
446     < [1, 1]
447    
448     =item "realm_discover" - run discovery on a given realm
449    
450     > [<id>, "realm_discover", <realm-gid>]
451     < [<id>, 1]
452    
453     =item "realm_poll" - run a poll on a given realm
454    
455     > [<id>, "realm_poll", <realm-gid>]
456     < [<id>, 1, { <statistical data> } ]
457    
458     =item "switch_poll" - run a poll on a given realm and switch ip
459    
460     > [<id>, "switch_poll", <realm-gid>, <switch ip>]
461     < [<id>, 1, { <statistical data> } ]
462    
463     =item "realm_sync" - run a sync on a given realm and plugin
464    
465     > [<id>, "realm_sync", <realm-gid>, <sync module>]
466     < [<id>, 1]
467    
468     The C<sync module> can be either bsync or qsync.
469    
470     =item "realm_query" - query the database
471    
472     This request executes a database query with filtering, much like the
473     device and switch views work in the user interface.
474    
475     > [<id>, "realm_query", <realm-gid>, <type>
476     [<column-name>...], [<raw-column-name]>...],
477     {<column-name> : <filter-expression>...},
478     <history mask>,
479     {<port unused period> : <unused value>}
480     ]
481     < [<id>, 1, [ [<result-data>]... ]]
482    
483     The C<realm-gid> is the GID of the realm to query, as returned by
484     C<real_info>. The C<type> is the string C<device>, C<switch> or
485     C<switch_detail>, which corresponds to the device view, switch view or
486     switch detail view.
487    
488     The first array of C<column-name>s specifies which columns should be
489     returned. The second array of C<raw-column-name>s works likewise, but
490     the values returned will be the "raw" (possibly octet-encoded) database
491     contents. Specifying the same column name in both array causes undefined
492     behaviour.
493    
494     The hash of C<column-name> => C<filter-expression> pairs specifies
495     additional filters. The syntax for the C<filter-expression> is the same as
496     the ones used by the GUI.
497    
498     The C<history mask> is the history selection option.
499     Value 0 means C<current>, value 1 means C<All> and value 2 means
500     C<All+Changes>. Default value is 0.
501    
502     The hash of C<port unused period> => C<unused> pairs specifies
503     port unused time. The C<port unused period> can be days, months or years.
504    
505     The reply contains an array of result rows. Each row consists of data
506     values using the same ordering as in the requested column-name arrays, raw
507     columns last.
508    
509     The (JSON) type of each column depends on the column itself, and can vary
510     between rows.
511    
512     =over 4
513    
514     =item valid columns for "device" query
515    
516     vlanname, port_pktcount, linkduplex, port_mac, device_log_end,
517     port_errorcount, vtpdomain, switch_ip, device_log_start,
518     linkstatus, linkspeed, device_mac, history_device, linkadminduplex,
519     ifname, device_comment, device_notes, vlan, device_dnsname,
520     ifalias, switch_uid, ifdescr, linkadminstatus,
521     port_error_percentage, device_ip
522    
523     =item valid columns for "switch" query
524    
525     number_ports, switch_action, switch_syslocation,
526     free_ports_percentage, switch_sysservices, switch_dnsname,
527     history_switch, switch_log_end, switch_pollduration, switch_model,
528     available_ports_percentage, switch_comment, ports_lastchange,
529     switch_ip, switch_sysdescr, switch_notes, available_ports,
530     poe_ports, switch_log_start, switch_uid, switch, free_ports
531    
532     =back
533    
534     Example:
535    
536     > [1, "realm_query", "5100005442", "device",
537     ["switch_uid", "device_ip"],
538     ["device_mac"],
539     { "switch_uid" : "switch03%" }]
540     < [1,1,[["switch03.ibm.de","192.168.40.11","\u00000B\u0006D^"],...
541    
542     =item valid columns for "switch_detail" view
543    
544     port_pktcount, history_port, linkduplex, port_mac, port_comment,
545     port_log_start, port_errorcount, port_log_end,
546     detected_devices_current, linkstatus, linkspeed, linkadminduplex,
547     ifname, port_action, poe_power, ifalias, switch_uid, poe_status, switch,
548     ifdescr, linkadminstatus, port_error_percentage
549    
550     Example:
551    
552     > [5, "realm_query", "5100005442", "switch_detail",
553     ["ifname"], [],
554     { "switch" : 27 }]
555     < [5,1,[["Fa0/11"],["Fa0/21"], ... ,["Fa0/5"]]]
556    
557     =item "user_view_info" - return the available views list
558    
559     This request returns the report views list for the logged-in user.
560    
561     > [<id>, "user_view_info", [<field-list>], [<type-list>]]
562     < [<id>, 1, [ [<fields>, ...], ...]]
563    
564     Valid fields are C<name> and C<gid> and valid types are C<switch>,
565     C<port> and C<device>. The reply will contains an array for each view.
566    
567     Example:
568    
569     > [1, "user_view_info", ["gid", "name"]]
570     < [1,1,[["107374182462","Ports:Default"],
571     ["94489280669","Ports:Multiple Devices on Port"],
572     ["107374182460","End Devices:Default"],
573     ["3865500631171226","End Devices:test"],
574     ["3865500631171236","End Devices:tns04"]]]
575    
576     =item "realm_view" - query database with given view in a given realm
577    
578     This request returns the database entries for the given view and the realm.
579    
580     > [<id>, "realm_view", <realm-gid>, <view-gid>]
581     < [<id>, 1,[ [<result-data>]]]
582    
583     Valid view gid should be given followed by a valid realm gid.
584     The reply will contain the results from database query and one array per
585     database row.
586    
587     Example:
588    
589     > [1, "realm_view", "64424509927", "107374182461"]
590     < [1,1,[["tnsw04.uk.internal","S","26","15","15","58","0","2009-12-08 12:17:00",
591     "2009-12-08 12:17:00",null],["tnsw05.uk.internal","S","26","20","20"
592     ,"77","0","2009-12-08 12:17:00","2009-12-08 12:17:00",null]]]
593    
594     =item "realm_seed_list" - return the seed list
595    
596     This request returns the seed list for the given realm.
597    
598     > [<id>, "realm_seed_list", <realm-gid>]
599     < [<id>, 1, [ [<ip>, <flags>]... ]]
600    
601     The reply contains an array with all configured seed devices. Each device
602     is represented by an array with the IP address in textual form and a flags
603     bitset. The only defined bit value (not number) is C<2>, which indicates a
604     manually-added seed entry.
605    
606     Example:
607    
608     > [1, "realm_seed_list", "5100005442"]
609     < [1,1,[["192.168.40.11",0],["192.168.40.1",2]]]
610    
611     =item "realm_seed_list_modify" - add/remove seed list entries
612    
613     This request modifies the seed list for a realm.
614    
615     > [<id>, "realm_seed_list_modify", <realm-gid>, [<delete-ip>...], [<add-ip>...>]]
616     < [<id>, 1]
617    
618     The two arrays after the realm-gid specify the IP addresses (in textual
619     form) of seed entries to remove, followed by a list of IP addresses to be
620     added afterwards. Newly added IP addresses will have the manual flag set on them.
621    
622     Example: set the manually-added flag on 10.0.0.5, or add it if it didn't
623     exist yet.
624    
625     > [1, "realm_seed_list_modify", "5100005442", ["10.0.0.5"], ["10.0.0.5"]]
626     < [1,1]
627    
628     =item "realm_snmp_credential_list" - list snmp credentials
629    
630     This request returns the snmp credentials for the given realm.
631    
632     > [<id>, "realm_snmp_credential_list", <realm-gid>]
633     < [<id>, 1, [ [<subnet>, <bits>, [ 2, [<community>...], [3, <v3 settings>] ], <flags>]... ]]
634    
635     The reply contains an array with all configured snmp credentials, one per
636     subnet. Each snmp credential will contain the subnet address in textual
637     form, the leading number of significant bits in the subnet (0..32 for
638     IPv4, 0..128 for IPv6), an array per snmp v2 and v3 settings and a flags bitset
639     (bit value C<1> means it is an include, otherwise it is an exclude).
640     v2 array starts with bit value C<2> means it is version v2 and followed by an array
641     of community strings. v3 array starts with bit value C<3> means it is version v3 and
642     followed by v3 user name, authentication password, privacy password, authentication
643     algorithm and privacy algorithm.
644    
645     Example:
646    
647     > [1, "realm_snmp_credential_list", "5100005442"]
648     < [1,1,[ ["10.1.0.0",16,[[2,["test"]], [3,"authPrivUser","authpass","privpass","md5","aes"]],1] ]]
649    
650     =item "realm_snmp_credential_list_modify" - modify snmp credentials
651    
652     Removes and/or adds snmp credential entries.
653    
654     > [<id>, "realm_snmp_credential_list_modify", <realm-gid>, [<remove-subnet>], [<add-subnet>...]]
655     < [<id>, 1]
656    
657     The two arrays after the realm-gid specify a list of subnet addresses to
658     remove (only exact matches wil be removed) and a list of subnet-entries to
659     be added afterwards. Each entry in the <add-subnet> list follows the same
660     format as returned by C<realm_snmp_credentials>.
661    
662     Example:
663     > [1, "realm_snmp_credential_list_modify", "5100005442", [ ["10.0.0.0", 8], ["11.1.1.0", 24] ],
664     [ ["192.168.240.0", 24, [2, ["w0rld", "peace"], [3, "noAuthUser"]], 1] ]]
665     < [1, 1]
666    
667     =item "realm_device_assignment_list" - list all assignable devices for a realm
668    
669     This request returns all assignable devices.
670    
671     > [<id>, "realm_device_assignment", <realm-gid>]
672     < [<id>, 1, [ [<ip>, <poller-gid>] ]]
673    
674     The reply contains an array with all assignable devices in a realm. Each
675     device entry will contain the device IP address in textual form, and
676     the gid of the poller it is assigned to, or C<null> if the device isn't
677     currently assigned.
678    
679     Example:
680    
681     > [1, "realm_device_assignment_list", "64424509927"]
682     < [1,1,[ ["192.168.71.21",null],["192.168.75.2",null],["1.1.1.1",64424509930],["5.5.5.5",64424509930]] ]
683    
684     =item "realm_device_assign" - assign a device to a poller
685    
686     Assigns or unassigns a device, or all devices.
687    
688     > [<id>, "realm_device_assign", <realm-gid>]
689     < [<id>, 1]
690    
691     > [<id>, "realm_device_assign", <realm-gid>, [<device-ip>, <poller-gid>]]
692     < [<id>, 1]
693    
694     If only a realm-gid is specified and device and poller-gid are missing,
695     then all devices get auto-assigned to pollers, if possible.
696    
697     Otherwise, the specified device will be assigned to the specified
698     C<poller-gid>, or unassigned if C<poller-gid> is C<null>.
699    
700     Example:
701    
702     > [1, "realm_device_assign", "64424509927"]
703     < [1, 1]
704    
705     > [1, "realm_device_assign", "64424509927", ["1.1.1.1", null]]
706     < [1, 1]
707    
708     > [1, "realm_device_assign", "64424509927", ["1.1.1.1", "64424509930"]]
709     < [1, 1]
710    
711     =item "realm_advanced_settings" - list advanced settings of a given realm
712    
713     This request returns all/specific properties and their values.
714    
715     > [<id>, "realm_advanced_settings", <realm-gid>, [<property>,...]]
716     < [<id>, 1, [[<property>, <value>]...]]
717    
718     If only the realm-gid is specified then all the properties and their values returned.
719    
720     valid properties are
721    
722     block_port_macs, stp_enabled, cdp_enabled, lldp_enabled
723    
724     Example:
725    
726     > [1, "realm_advanced_settings", "64424509927", ["cdp_enabled"]]
727     < [1,1,[["cdp_enabled","1"]]]
728    
729     =item "realm_advanced_settings_modify" - modify advanced settings of a given realm
730    
731     This request modifies advanced settings of a given realm-gid.
732    
733     > [<id>, "realm_advanced_settings_modify", <realm-gid>, [[<property>, <value>]...]]
734     < [<id>, 1]
735    
736     > [<id>, "realm_advanced_settings_modify", <realm-gid>, [[<property>, [<delete-list>], [<add-list>]]]]
737     < [<id>, 1]
738    
739     realm-gid followed by a array of property and value pairs. one array for each property
740     and value pair.
741    
742     block_port_macs property expects two arrays in place of value. First array is a list of
743     macs needs to be deleted from port exclusion list and second array is a list of
744     macs needs to be added into port exclusion list. MAC addresses should be in the following
745     format "AA:BB:CC:DD:EE:FF".
746     When no array given for block_port_macs property all the macs from port exclusion list
747     will get deleted.
748    
749     Example:
750    
751     > [1, "realm_advanced_settings_modify", "64424509927", [["cdp_enabled", "0"]]]
752     < [1, 1]
753    
754     > [1, "realm_advanced_settings_modify", "64424509927", [["block_port_macs",
755     ["11:00:0a:0b:11:22"], ["0a:11:22:44:0e:0b"]]]]
756     < [1, 1]
757    
758     =item "poller_info" - - information about pollers
759    
760     > [<id>, "poller_info", [<fields...>], [<pollers...>]]
761     < [<id>, 1, [ [<fields...>]... ]]
762    
763     Example:
764    
765     > [1, "poller_info", ["gid", "name", "description", "hostname"]]
766     < [1,1,[["64424509930","localhost","localhost","127.0.0.1"]]]
767    
768    
769     Requests information about the given pollers (or all pollers if specified as
770     C<null>). The following fields can be requested, and their contents will be
771     returned in the order specified in the C<fields> array:
772    
773     =over 4
774    
775     =item gid - the gid (id value) identifying the poller
776    
777     =item name - the user-specified name of the poller
778    
779     =item description - the user-specified description for this poller
780    
781     =item hostname - hostname/ip of this poller
782    
783     =item dns_max_outstanding - maximum number of dns queries for this poller
784    
785     =back
786    
787     =item "poller_modify" - adds and/or deletes pollers
788    
789     This request adds and/or deletes given pollers.
790    
791     > [<id>, "poller_modify", <realm-gid>, [<delete-gid>, ...],
792     [[<name>, <description>, <hostname>, <secret>], ...]]
793     < [<id>, 1]
794    
795     Two arrays followed by a realm gid. First array is a list of poller gids
796     needs to be deleted. Second array is a list of pollers needs to be added.
797     An array per poller should contain poller name, description, hostname and
798     secret password.
799    
800     Example:
801    
802     > [1, "poller_modify", "385611201213", ["98456723211"], [["test1",
803     "Test poller", "127.0.0.1", "test"]]]
804     < [1, 1]
805    
806     =item "poller_info_modify - edits the given poller
807    
808     This request edits the given poller with new values.
809    
810     > [<id>, "poller_info_modify", <poller-gid>, {<prop>:<value>,...}]
811     < [<id>, 1]
812    
813     A property hash followed by a poller gid. Keys expected in the hash
814     are name, description, hostname, secret and dns_max_outstanding.
815    
816     Example:
817    
818     > [1, "poller_info_modify", "6789345621", {"name":"test1",
819     "secret":"test123", "hostname":"localhost",
820     "dns_max_outstanding":"65"}]
821     < [1, 1]
822    
823     =item "poller_subnet_list" - list subnets attached to a given poller
824    
825     This request returns all subnets attached to a given poller.
826    
827     > [<id>, "poller_subnet_list", <poller-gid>]
828     < [<id>, 1, [ [<subnet>, <bits>, <ping-limit>, <flags>]... ]]
829    
830     The reply contains an array with all configured subnets. Each subnet
831     will contain the subnet address in textual form, the leading number of
832     significant bits in the subnet (0..32 for IPv4, 0..128 for IPv6), a ping
833     limit (in kbit/s) and a flags value (bit value C<1> indicates whether the
834     subnet is exclided (C<0>) or included (C<1>), bit value C<2> indicates
835     whether pings are enabled (C<2>) or not).
836    
837     Example:
838    
839     > [1, "poller_subnet_list", "64424509930"]
840     < [1,1,[["1.1.1.1",32,1000,1,2],["10.1.1.1",32,1000,0,0]]]
841    
842     =item "poller_subnet_list_modify" - modify subnets of a poller
843    
844     Removes and/or adds subnet entries.
845    
846     > [<id>, "poller_subnet_list_modify", <poller-gid>, [<remove-subnet>], [<add-subnet>...]]
847     < [<id>, 1]
848    
849     The two arrays after the poller-gid specify a list of subnet addresses to
850     remove (only exact matches wil be removed) and a list of subnet-entries to
851     be added afterwards. Each entry in the <add-subnet> list follows the same
852     format as returned by C<poller_subnet_list>.
853    
854     Example:
855    
856     > [ 1, "poller_subnet_list_modify", "64424509930",[["1.1.1.1",32,1000,1,2],
857     ["10.1.1.1",32,1000,0,0]], [["192.168.0.0", 16, 1200, 1,2]] ]
858     < [1, 1]
859    
860     =item "global_settings" - list global settings
861    
862     This request returns all global settings or specific settings.
863    
864     > [<id>, "global_settings"]
865     < [<id>, 1, [ [<property>, <value>]... ]]
866    
867     The reply contains an array with all configured properties and values. Each property
868     and value will be in textual form.
869    
870     valid properties are
871    
872     normalization_algorithm, snmp_parallel_requests, session_timeout, snmp_retries,
873     agni_verbose, domain, snmp_timeout, smtp_server, skip_access_points, max_history_length,
874     smtp_user, autoassign, skip_cisco_phones, skip_mitel_phones, max_log_length
875    
876     Example:
877    
878     > [1, "global_settings"]
879     < [1,1,[["normalization_algorithm","loopback highest-ip lowest-ip"],
880     ["snmp_parallel_requests","10"],["session_timeout","86400"],["snmp_retries","5"],
881     ["agni_verbose",null],["domain",""],["snmp_timeout","4"],["smtp_server",""],
882     ["skip_access_points","1"],["max_history_length","0"],["smtp_user",""],["autoassign","1"],["skip_cisco_phones","1"]]]
883    
884     > [1, "global_settings", ["normalization_algorithm", "session_timeout"]]
885     < [1,1,[["normalization_algorithm","loopback highest-ip lowest-ip"],["session_timeout","86400"]]]
886    
887     =item "global_settings_modify" - modify global settings
888    
889     This request modifies global settings. Each property modified with a new value given.
890    
891     > [<id>, "global_settings_modify", [ [<property>, <value>]... ]]
892     < [<id>, 1]
893    
894     one array for each property and value pair. Properties and values should be in
895     textual format.
896    
897     valid properties are
898    
899     normalization_algorithm, snmp_parallel_requests, session_timeout, snmp_retries,
900     agni_verbose, domain, snmp_timeout, smtp_server, skip_access_points, max_history_length,
901     smtp_user, autoassign, skip_cisco_phones, max_log_length, skip_mitel_phones, smtp_pass
902    
903     Example:
904    
905     > [1, "global_settings_modify", [["snmp_parallel_requests", "15"]]]
906     < [1, 1]
907    
908     =item "advanced_settings" - list advanced settings
909    
910     This request returns all advanced settings or specific settings.
911    
912     > [<id>, "advanced_settings"]
913     < [<id>, 1, [ [<property>, <value>]... ]]
914    
915     The reply contains an array with all configured properties and values. Each property
916     and value will be in textual form.
917    
918     valid properties are
919    
920     max_parallel_jobs, max_debug_scans, debug_level
921    
922     Example:
923    
924     > [1, "advanced_settings", ["max_parallel_jobs"]]
925     < [1,1,[["max_parallel_jobs","1000"]]]
926    
927     =item "advanced_settings_modify" - modify advanced settings
928    
929     This request modifies advanced settings. Each property modified with a new value given.
930    
931     > [<id>, "advanced_settings_modify", [ [<property>, <value>]...]]
932     < [<id>, 1]
933    
934     one array for each property and value pair. Properties and values should be in
935     textual format.
936    
937     Example:
938    
939     > [1, "advanced_settings_modify", [ ["max_parallel_jobs", "900"]]]
940     < [1, 1]
941    
942    
943     =item "security_misc_settings" - lists misellenous security settings
944    
945     This request returns all misellenous settings or specific settings.
946    
947     > [<id>, "security_misc_settings", [<property, ... ]]
948     < [<id>, 1, [<value>, ...] ]
949    
950     valid properties are
951    
952     login_banner enable_login_banner
953    
954     Example:
955    
956     > [1, "security_misc_settings", ["login_banner"]]
957     < [1,1,["This system is the property of ..."]]
958    
959     =item "security_misc_settings_modify" - modifies given misellenous property
960    
961     This request modifies given property with the given new value.
962    
963     > [<id>, "security_misc_settings_modify", {<property> : <value>, ... }]
964     < [<id>, 1]
965    
966     Example:
967    
968     > [1, "security_misc_settings_modify", {"login_banner" : "Its My Box."}]
969     < [1, 1]
970    
971     =item "security_certificate_list" - lists available certificates
972    
973     This request returns all or given properties of all certificates.
974    
975     > [<id>, "security_certificate_list", [<property>, ...] ]
976     < [<id>, 1, [ [<value>, ...] , ... ] ]
977    
978     Valid properties are
979    
980     name certificate
981    
982     Example:
983    
984     > [1, "security_certificate_list"]
985     < [1, 1, [["System Default",""],["custom", ,"-----BEGIN RSA PRIVATE KEY..."]]]
986    
987     =item "security_certificate_list_modify" - adds/deletes given certificates
988    
989     This request deletes and adds given certificates.
990    
991     > [<id>, "security_certificate_list_modify", [<delete-list>], [[<name>, <certificate>], ...]]
992     < [<id>, 1]
993    
994     delete-list contains list of certificate names.
995     add-list should have a name and certificate one array per certificate.
996    
997     Example:
998    
999     > [1, "security_certificate_list_modify", ["old_custom"], [["new_custom", "-----BEGIN RSA PRIVATE KEY..."]
1000     ]]
1001     < [1, 1]
1002    
1003     =item "security_certificate_assignment_list" - lists all assignable certificates
1004    
1005     This request returns all certificate name and their current status.
1006     one array per certicate will be used. current status shows whether it is assigned
1007     to C<apache> or C<api> or C<null> for not in use.
1008    
1009     > [<id>, "security_certificate_assignment_list"]
1010     < [<id>, 1, [ [<name>, <status>], ... ]]
1011    
1012     Example:
1013    
1014     > [1, "security_certificate_assignment_list"]
1015     > [1,1,[["System Default","apache"],["System Default","api"],["custome",null]]]
1016    
1017     =item "security_certificate_assign" - assigns given certificate to api or apache
1018    
1019     This request assigns given certificate to apache or api.
1020    
1021     > [<id>, "security_certificate_assign", [ [<name>, <assign>], ...] ]
1022     < [<id>, 1]
1023    
1024     Example:
1025    
1026     > [1, "security_certificate_assign", [["custom", "apache"], ["custom", "api"]]]
1027     < [1, 1]
1028    
1029     =item "security_authentication_method_list" - lists authentication methods and settings
1030    
1031     This request returns all or specified properties of all or specified authentication method.
1032     First array contains the list of properties and the second array contains the list of gids
1033     of methods. Result array will have one array per authentication method.
1034    
1035     Valid properties are
1036    
1037     name gid inuse settings
1038    
1039     > [<id>, "security_authentication_method_list", [<properties>, ...], [<method-gid>, ...]]
1040     < [<id>, 1, [ [<value>, ...], ...]]
1041    
1042     Example:
1043    
1044     > [1, "security_authentication_method_list", ["name"], ["90194313753", "90194313603"]]
1045     < [1,1,[["RADIUS"],["Active Directory (LDAPS)"]]]
1046    
1047     =item "security_authentication_modify" - modifies given authentication methods
1048    
1049     This request edits given authentication method.
1050     First argument is the authentication method gid.
1051     All new values should be mentioned in a hash.
1052    
1053     Valid properties are
1054    
1055     inuse server secret csecret domain ctrls certificate
1056    
1057     bit value C<inuse> will activate/inactivate the given authentication method.
1058     C<server> is the RADIUS server for RADIUS authentication method.
1059     C<secret> and C<csecret> are secret password and confirm secret password for RADIUS server.
1060     C<domain> is the domain name for LDAP and LDAPS authentication methods.
1061     C<ctrls> is the array of delete and add lists of domain controls.
1062     C<certificate> is the valid certificate name for LDAPS authentication method.
1063     C<timeout> is the value in seconds to be used when communicating with Active Directory servers.
1064    
1065     > [<id>, "security_authentication_modify", <method-gid>, {<property> : <value>,... }]
1066     < [<id>, 1]
1067    
1068     Example:
1069    
1070     > [1, "security_authentication_modify", "90194313753", {"inuse" : 1, "server" : "4test"}]
1071     < [1, 1]
1072    
1073     > [1, "security_authentication_modify", "90194313603", {"certificate" : "custom", "domain" : "new"
1074     "ctrls" : [ ["10.1.50.1"], ["10.1.50.2"] ]}]
1075     < [1, 1]
1076    
1077     =item "group_info" - lists group information
1078    
1079     This request returns all groups or specific groups. The request returns all
1080     fields or specific fields.
1081    
1082     > [<id>, "group_info", [<field1>, <field2>, ...], [<group-gid>, ...]]
1083     < [<id>, 1, [ [<value>, <value>, ...] , ...]
1084    
1085     The reply contains an array for each group with specified field values or all.
1086    
1087     Example:
1088    
1089     > [1, "group_info", ["name"]]
1090     < [1,1,[["helpme"],["Network Administrator"],["Network Operator"],["Super Admin"]]]
1091    
1092     =item "group_modify" - adds and/or deletes groups
1093    
1094     This request adds and/or deletes given groups.
1095    
1096     > [<id>, "group_modify", [<delete-gid>, ...], [[<name>, <description>], ...]]
1097     < [<id>, 1]
1098    
1099     Two arrays expected as input. First array is a list of group gids needs to be deleted.
1100     Second array is a list of groups needs to be added. An array per group should contain
1101     group name and description.
1102    
1103     Example:
1104    
1105     > [1, "group_modify", ["9845672231"], [["test1", "Test group"]]]
1106     < [1, 1]
1107    
1108     =item "group_settings" - lists permissions for a given group
1109    
1110     > [<id>, "group_settings", <group-gid>, [<role>, <role>, ...], [<realm-gid>, ...]]
1111     < [<id>, 1, [[[<system-role>, <permission>], ...],
1112     [[<realm-gid>, [[<realm-role>, <permission>], ...]], ...]]]
1113    
1114     The input should have a valid group gid in textual format. Two arrays followed by group gid
1115     are list of roles and list of realm gids. These two arrays are optional.
1116     The result contains two arrays. First array is for system specific roles. One array per role.
1117     Second array is for realm specific roles. One array per realm. First element of the array is
1118     realm-gid in textual format followed by an array of realm specific roles and their permission.
1119     Permission will be referred in bit value. bit value C<0> means NO Access, C<1> means
1120     Read Access and C<2> means Read/Write Access.
1121    
1122     Example:
1123    
1124     > [1, "group_settings", "98784248728"]
1125     < [1,1,[[["API",2],["Add Realms",2],["Advanced Settings",1],["Global Settings",2]]
1126     ,[["3865500631171652",[["Advanced Realm Settings",0],["Assign Devices",0]]]]]]
1127    
1128     > [1, "group_settings", "98784248728", ["Add Realms", "Assign Devices"]]
1129     < [1,1,[[["Add Realms",2]],[["3865500631171652",[["Assign Devices",0]]],
1130     ["3865500631171517",[["Assign Devices",0]]]]]]
1131    
1132    
1133     =item "group_settings_modify" - edits group properties and permissions
1134    
1135     > [<id>, "group_settings_modify", <group-gid>
1136     , {"name":<group-name>, "description":<group description>}
1137     , [[<system-role>, <permission>], ...], [[<realm-gid>,
1138     [[<realm-role>, <permission>], ...]], ...] ]
1139     < [<id>, 1]
1140    
1141     The input should have a valid group gid. A property hash followed by the group gid.
1142     The values of keys C<name> and C<description> are new group name and description.
1143     Two arrays followed by hash. First array is for system specific roles. Format of the
1144     array is same as output of C<group_settings> query. Second array is for realm specific roles.
1145     One array per realm. Format of this array is same as output of C<group_settings> query.
1146    
1147     valid system specific roles are
1148    
1149     "API", "Add Realms", "Advanced Settings", "Global Settings", "Group Management", "License",
1150     "Schedule Backup", "Security Settings", "System Utilities", "User Management", "View Log"
1151    
1152     valid realm specific roles are
1153    
1154     "Advanced Realm Settings", "Assign Devices", "Discovery Realm Settings", "Views",
1155     "Plugins", "Poller Settings", "Schedule Discovery","Schedule Poll","Schedule Report"
1156     ,"Schedule Sync"
1157    
1158     Example:
1159    
1160     > [1, "group_settings_modify", "98784248723", {"name":"TEST"},
1161     [["Add Realms",0]]], [["386550063117151",[["Poller Setting",1]]]]]
1162     < [1, 1]
1163    
1164    
1165     > [1, "group_settings_modify", "98784248723", {},
1166     [["Add Realms",0],["Global Settings",1]]]
1167     < [1, 1]
1168    
1169    
1170     =back
1171    
1172     =head1 AUTHOR
1173    
1174     Marc Lehmann <marc@nethype.de>.
1175