[options="header",cols="^1,^h,3a"]
|=================
| Error Code | Message | Meaning
-| -32700 | Parse Error | Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
+| -32700 | Parse Error | Invalid JSON was received by the server. An error occurred on the server while parsing the JSON input.
| -32600 | Invalid Request | The JSON sent is not a valid Request object.
| -32601 | Method not found | The method does not exist / is not available
| -32603 | Invalid params | Invalid method parameter(s)
== Data Bases and Data Structures used in Scapy Server
=== Protocol Field Description
-This data sturcture contains the name of the field, its type and the default value assigned. +
+This data structure contains the name of the field, its type and the default value assigned. +
+
Has the following structure: +
=== Offsets Dictionary and Offset Entry
-==== The *"Offset Entry"* data sturcture contains the offset of a field within the *layer*, and its size. +
+==== The *"Offset Entry"* data structure contains the offset of a field within the *layer*, and it's size. +
(both measured in Bytes)
+
+
*Example:* +
This is the 'src' field for the 'IP' protocol: +
-the offset within the layer is 16 bytes, and the size of the field is 4 bytes (as defined in the IP spec)
+The offset within the layer is 16 bytes, and the size of the field is 4 bytes (as defined in the IP spec)
[source,bash]
----
'dst': [16, 4]
----
-Each layer has a 'global_offset' key. this key represents the *offset of the layer within the packet*. +
-In the example above, the IP layer starts at offset 0, and the field src is at offset 12 within the packet. +
+Each layer has a 'global_offset' key. This key represents the *offset of the layer within the packet*. +
+In the example above, the IP layer starts at offset 0, and the field 'src' is at offset 12 within the packet. +
In the general case, a field's offset within the *packet* is calculated this way: +
'global_offset' + 'field_offset'
=== Protocol Dictionary
The protocol dictionary contains the names for all supported protocols and layers for building packets. +
-Each entry in this data base has the following format: +
+Each entry in this database has the following format: +
'Protocol Name' : 'Protocol Field Description' +
+
=== Fields Dictionary
The fields dictionary contains mapping between a field's name and its regular expression, +
-Which has the following structure: +
+which has the following structure: +
(field name, field RegEx) +
Example: this is the Regex for the 'MACField' protocol
----
== RPC Commands
-The following RPC commands are supported. please refer to data bases section for elaboration on given data bases
+The following RPC commands are supported. Please refer to databases section for elaboration for each database.
=== Supported Methods
* *Name* - supported_methods
* *Description* - returns the list of all supported methods by Scapy Server and their parameters
-* *Parameters* - a single empty string ('') will return *ALL* supported methods. +
+* *Parameters* - the parameter ('all') will return *ALL* supported methods. +
other string delivered as parameter will return True/False if the string matches a supported method name
-* *Result* - according to input: empty string will return list of supported methods, otherwise will return True/False as mentioned
+* *Result* - according to input: 'all' string will return list of supported methods, otherwise will return True/False as mentioned. +
+ The returned dictionary describes for each method it's number of parameters followed by a list of their names.
*Example:*
"jsonrpc": "2.0",
"id": "1",
"method": "supported_methods",
- "params": [""]
+ "params": ["all"]
}
'Result':
----
-=== Check if DataBase is updated
+=== Check if Database is updated
* *Name* - 'check_update'
* *Description* - checks if both protocol database and fields database are up to date according to md5 comparison
-* *Paramters* - md5 of database, md5 of fields
+* *Parameters* - md5 of database, md5 of fields
* *Result* - upon failure: error code -32098 (see link:trex_scapy_rpc_server.html#_error_codes[RPC server error codes]) +
followed by a message: "Fields DB is not up to date" or "Protocol DB is not up to date" +
upon success: return 'true' as result (see below) +