Protocol Handler
A custom protocol handler is used to construct a ‘protocol layer stack’. The script takes a packet at a given layer and is responsible for
- consume N bytes at that layer
- tell Trisul framework what protocol the next layer is
An example
You can create a script to handle a new SYSLOG protocol which will then handle packets to UDP Port 514
Structure
Download a well documented skeleton script from here to copy and get started
Protocol Handler skeleton script
Table protocol_handler
name | type | description |
---|---|---|
table control | table | assign a name and GUID to this protocol |
function parselayer | function( layer | given a packet consume N bytes for this protocol and tell Trisul what the next protocol is |
Table control
The control table assigns a unique GUID to this protocol and a name. You can then use Access Points to connect this protocol to a lower layer.
name | type | description |
---|---|---|
guid | string | A unique guid that identifies this new protocol. Use trisulctl_probe testbench guid to generate a new GUID |
name | string | Name of the counter group. Keep it short < 15 chars |
description | string | optional |
host_protocol_guid | string | Which lower layer protocol do you want to attach to. To find the GUID for your host protocol such as UDP or IP see Common protocol GUIDs |
host_protocol_ports | array of numbers | array of port numbers of the host protocol to which you want to attach. These could be TCP/UDP prots, EtherTypes, IP protocol numbers, or other Access Points |
Sample control block
This is what a new DHCP protocol handler control
section would look like.
-- new protocol for DHCP
control = {
guid = "{E1BD4415-DED3-4D81-974A-3E23C8CE6F5B}", -- new protocol GUID we created
name = "DHCP", -- new protocol name
host_protocol_guid = '{14D7AB53-CC51-47e9-8814-9C06AAE60189}', -- GUID for UDP
host_protocol_ports = { 67,68 } -- we want UDP ports 67,68
}
LUA functions reference
The only function in this script type is called parselayer