### Example: Run Zeek Docker Container with Mounted Parser Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md An example command for starting the Zeek Docker container, mounting the local parser directory to a path inside the container. ```bash docker run -t -i -P --rm -v $HOME/MyParser:/root/MyParser:rw --entrypoint /bin/bash ghcr.io/mmguero/zeek:master ``` -------------------------------- ### Example: Run Parser with Zeek on Pcap Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md An example command demonstrating how to run Zeek with the installed parser on a specific pcap file located inside the container. ```bash zeek -Cr /root/MyParser/example/test.pcapng local ``` -------------------------------- ### Example: Build Parser with Parsnip Backend Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md An example command demonstrating how to run the Parsnip backend script with specific paths. Replace the example paths with your actual input and output folder locations. ```bash python3 main.py ~/Downloads/parsnip/08f4789d-6915-4067-8939-4994c55acbae ~/MyParser ``` -------------------------------- ### Example: Initialize Git Repository for Parser Output Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md An example demonstrating how to initialize a git repository in the parser output directory using specific paths. ```bash cd ~/MyParser echo "*.log" > .gitignore git init . git add -A git commit -m "Initial Commit" ``` -------------------------------- ### Install Docker Prerequisites Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Updates the package list and installs the core Docker package using apt. This is the first step in Method 1 for installing Docker prerequisites on Ubuntu. ```bash sudo apt update sudo apt install docker.io ``` -------------------------------- ### Enable Rootless Docker Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs the `uidmap` package and runs the setup tool to configure Docker to run in rootless mode for the current user. This allows using Docker without requiring sudo for every command. ```bash sudo apt install uidmap dockerd-rootless-setuptool.sh install ``` -------------------------------- ### Install Docker Method 2 Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md A comprehensive script to install Docker using Method 2 on Ubuntu. It adds the Docker GPG key, sets up the stable repository, and installs the necessary Docker packages (docker-ce, docker-ce-cli, containerd.io, plugins). ```bash #!/bin/bash # Install Docker Key sudo apt update sudo apt install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to sources # Note: need to change VERSION_CODENAME to UBUNTU_CODENAME if running an Ubuntu derivative echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin ``` -------------------------------- ### Install Rustworkx System Package Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs the rustworkx Python library globally using pip3, overriding potential system package conflicts with the `--break-system-packages` flag. This is a specific step for Ubuntu 24.04 setup. ```bash sudo pip3 install rustworkx --break-system-packages ``` -------------------------------- ### Install Backend Prerequisites Ubuntu 22.04 Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs essential packages for the Parsnip backend on Ubuntu 22.04. Includes Python 3, pip, and development libraries for Graphviz, which is used for visualization. ```bash sudo apt install python3 python3-pip graphviz-dev ``` -------------------------------- ### Start GUI Web Server Script Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Executes the `start_webServer.sh` script located in the `parsnip/frontend` directory. This script is used to launch the Parsnip GUI, likely within a Docker container environment. ```bash ./start_webServer.sh ``` -------------------------------- ### Example Zeek Signature (Zeek) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example Zeek signature code snippet showing the structure of a dpd.sig file. This signature matches TCP traffic with a payload starting with at least two bytes and enables a specific parser. ```Zeek # Fix Me! signature dpd_parser_tcp { ip-proto == tcp payload /^[x00-xff]{2}/ enable "PARSER_TCP" } ``` -------------------------------- ### Install Parser using Zkg inside Docker Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs the mounted parser into the Zeek environment inside the Docker container using the zkg package manager. This command should be run from within the mounted parser directory inside the container. ```bash zkg install . ``` -------------------------------- ### Install Backend Prerequisites Ubuntu 24.04 Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs essential packages for the Parsnip backend on Ubuntu 24.04. This version specifies system packages for matplotlib, pygraphviz, and pydot in addition to Python 3, pip, and graphviz-dev. ```bash sudo apt install python3 python3-pip graphviz-dev python3-matplotlib python3-pygraphviz python3-pydot ``` -------------------------------- ### Install Backend Python Libraries Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Installs required Python libraries for the Parsnip backend using pip3. These libraries include rustworkx, matplotlib, pygraphviz, and pydot, likely used for graph processing and plotting. ```bash pip3 install rustworkx matplotlib pygraphviz pydot ``` -------------------------------- ### Defining Python Project Dependencies (requirements.txt) Source: https://github.com/cisagov/parsnip/blob/main/frontend/requirements.txt This snippet lists the core Python packages needed for the project. These dependencies are installed using the 'pip install -r requirements.txt' command. It includes Flask and related extensions for web development, and cachelib. ```requirements.txt # This file is used by pip to install required python packages # Usage: pip install -r requirements.txt # Explicit cachelib install to fix an issue with newer docker images cachelib # Flask Framework flask flask-wtf Flask-Session ``` -------------------------------- ### Run Parser with Zeek on Pcap Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Executes Zeek to process a pcap file using the installed parser. Replace 'pcap_path' with the path to the pcap file you want to analyze. The 'local' argument ensures the local site policy, including the installed parser, is loaded. ```bash zeek -Cr pcap_path local ``` -------------------------------- ### Run Zeek Docker Container with Mounted Parser Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Starts a Zeek Docker container with the generated parser output folder mounted as a volume. This allows testing the parser within an isolated Zeek environment. Replace 'output_folder' with the local path to your parser code and 'mount_folder' with the desired path inside the container. ```bash docker run -t -i -P --rm -v output_folder:mount_folder:rw --entrypoint /bin/bash ghcr.io/mmguero/zeek:master ``` -------------------------------- ### Run GUI Python Application Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Changes the current directory to `app` and then executes the main Python application script `app.py` using `python3`. This command starts the Parsnip frontend web server after the environment is set up by the previous script. ```bash cd app python3 app.py ``` -------------------------------- ### Configuring Parser Entry Point in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Identifies the initial object within the parser definition that corresponds to the start of a protocol packet. ```JSON "EntryPoint": "general.Message" ``` -------------------------------- ### Defining Parsnip Dependencies (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Examples demonstrating how to define dependencies for Parsnip objects or switches using JSON. Dependencies are values required for instantiation but not parsed by the structure itself. The examples show definitions for an enum type dependency and a basic integer type dependency. ```JSON { "name": "command", "type": "enum", "referenceType": "FunctionTypes", "scope": "general" }, { "name": "dataLength", "description": "Length of the data", "notes": "Protocol limits this to 12 bits overall", "type": "uint", "size": 16 } ``` -------------------------------- ### Configuring Signature File in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example JSON snippet showing the 'signatureFile' entry in the Parsnip general configuration file. The value is a Base64 encoded string representing the contents of a Zeek signature file (dpd.sig). ```JSON "signatureFile": "IyBGaXggTWUhCnNpZ25hdHVyZSBkcGRfcGFyc2VyX3RjcCB7CiAgaXAtcHJvdG8gPT0gdGNwCiAgcGF5bG9hZCAvXltceDAwLVx4ZmZdezJ9LwogIGVuYWJsZSAiUEFSU0VSX1RDUCIKfQ==" ``` -------------------------------- ### Configuring Protocol Ports in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example JSON snippet showing the 'Ports' entry in the Parsnip general configuration file. It defines an array of objects, each specifying a protocol ('tcp' or 'udp') and a port number associated with the protocol being parsed. ```JSON "Ports": [ { "protocol": "tcp", "port": 8080 }, { "protocol": "tcp", "port": 8880 } ] ``` -------------------------------- ### Defining Parsnip Fields (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Examples illustrating how to define fields within Parsnip objects or actions using JSON. Fields define the content of a structure and are parsed in the order listed. The examples show definitions for a basic integer type field and an enum type field. ```JSON { "name": "pollingAddressDevice", "description": "Polling Address of Device", "type": "uint", "size": 8, "notes": "refer to the Data Link Layer Specification" }, { "name": "loopCurrentMode", "description": "Loop Current Mode", "type": "enum", "referenceType": "LoopCurrentModeCodes", "scope": "general", "notes": "refer to Common Table 16, Loop Current Modes" } ``` -------------------------------- ### Configuring Conversion File in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example JSON snippet showing the 'conversionFile' entry in the Parsnip general configuration file. The value is a Base64 encoded string representing the contents of a C++ file used for custom type conversions. ```JSON "conversionFile": "Ly8gUHV0IHNvbWV0aGluZyBwcm9mb3VuZCBoZXJlLi4uCi8vIFB1dCBzb21ldGhpbmcgdXNlZnVsIGhlcmUuLi4=" ``` -------------------------------- ### Parsnip Enumeration Example (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet provides an example of how to define an enumeration named 'WriteProtectCodes' within the 'Structures' section of a Parsnip definition. It demonstrates the use of mandatory fields like 'name', 'size', and 'fields', as well as optional fields like 'reference' and 'notes', showing how individual enumeration fields ('NO', 'YES', etc.) are defined with 'name', 'loggingValue', and 'value'. ```JSON "Structures": { "Enums": [ { "name": "WriteProtectCodes", "reference": "Common Table Specification TS20183 version 26.0 Table 7", "notes": "", "size": 8, "fields": [ { "name": "NO", "loggingValue": "No", "value": 0, "notes": "" }, { "name": "YES", "loggingValue": "Yes", "value": 1, "notes": "" }, { "name": "NOTUSED", "loggingValue": "Not Used", "value": 250, "notes": "" }, { "name": "NONE", "loggingValue": "None", "value": 251, "notes": "" }, { "name": "UNKNOWN", "loggingValue": "Unknown", "value": 252, "notes": "" }, { "name": "SPECIAL", "loggingValue": "Special", "value": 253, "notes": "" } ] } ] } ``` -------------------------------- ### Example C++ Conversion Function (C++) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example C++ code snippet showing the structure of a conversion file function. This function is intended to convert raw bytes (hilti::rt::Bytes) into a specific type (here, std::string) for custom field types in the parser. ```C++ #include #include #include #include #include #include namespace ETHERCAT_CONVERSION { std::string packedBytesConversion(const hilti::rt::Bytes &data) { std::string returnValue; // TODO: Useful stuff return returnValue; } } ``` -------------------------------- ### Defining a Byte Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet provides an example of how to define a field intended to store raw byte data within the Parsnip framework. It illustrates setting the 'type' property to "byte" and specifying the size of the field in bits using the 'size' property. The example defines a field named 'variableName' that holds 64 bits (8 bytes) of data. ```JSON { "name": "variableName", "description": "", "type": "byte", "size": 64 } ``` -------------------------------- ### Defining a Choice Structure in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet demonstrates how to define a 'Choice' or 'Switch' structure in Parsnip. It shows the use of 'dependsOn' and 'additionalDependsOn' fields to determine which 'action' from the 'options' array should be executed based on the values of dependent fields. The example defines a switch named 'Command8Switch' that selects an action based on 'commandNumber', 'byteCount', and 'messageType'. ```JSON "Structures": { "Switches": [ { "name": "Command8Switch", "dependsOn": { "name": "commandNumber", "type": "uint", "size": 8 }, "additionalDependsOn": [ { "name": "byteCount", "type": "uint", "size": 8 }, { "name": "messageType", "type": "enum", "referenceType": "MessageType", "scope": "general" } ], "options": [ { "value": 0, "action": { "name": "readUniqueIdentifier", "type": "object", "referenceType": "ReadUniqueIdentifier", "inputs": [ { "source": "byteCount" }, { "source": "messageType" } ] } }, { "value": 1, "action": { "name": "readPrimaryVariable", "type": "object", "referenceType": "ReadPrimaryVariable", "inputs": [ { "source": "byteCount" }, { "source": "messageType" } ] } } ] } ] } ``` -------------------------------- ### Defining a Bitfield Structure in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This snippet provides a JSON example demonstrating how to define a bitfield named 'Delimiter' within the 'Structures' section of a Parsnip configuration. It shows the structure's size, endianness, and an array of fields, each specifying its name, description, type, and the bits it occupies. ```JSON "Structures": { "Bitfields": [ { "name": "Delimiter", "reference": "", "notes": "", "size": 8, "endianness": "big", "fields": [ { "name": "addressType", "description": "Address Type", "notes": "", "type": "enum", "referenceType": "AddressType", "scope": "general", "bits": "7" }, { "name": "expansionBytes", "description": "", "notes": "", "type": "uint", "bits": "5..6" }, { "name": "physicalLayerType", "description": "", "notes": "", "type": "enum", "referenceType": "PhysicalLayerType", "scope": "general", "bits": "3..4" }, { "name": "frameType", "description": "", "notes": "", "type": "enum", "referenceType": "FrameType", "scope": "general", "bits": "0..2" } ] } ] } ``` -------------------------------- ### Define Bitfield Structure in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet provides an example of defining a bitfield structure in Parsnip configuration. It sets the "type" to "bits" and includes "referenceType" and "scope" properties to link to the bitfield definition. ```JSON { "name": "delimiter", "description": "", "notes": "", "type": "bits", "referenceType": "Delimiter", "scope": "general" } ``` -------------------------------- ### Defining Custom Field Types in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Example JSON snippet showing the 'CustomFieldTypes' entry in the Parsnip general configuration file. It defines an array of objects, each specifying a custom type name, the C++ function used for conversion, and the expected return type. ```JSON "CustomFieldTypes": [ { "name": "PackedBytes", "interpretingFunction": "packedBytesConversion", "returnType": "string" } ] ``` -------------------------------- ### Define Object Fields in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet shows how to define object fields within another structure in Parsnip configuration. It sets the "type" to "object" and includes the "referenceType" property to link to the object definition. The second example shows how to define inputs for the object. ```JSON [ { "name": "header", "description": "Protocol Header", "notes": "", "type": "object", "referenceType": "Header" }, { "name": "body", "description": "Protocol Body", "notes": "", "type": "object", "referenceType": "Body", "inputs": [ { "source": "self.header.messageID" }, { "source": "self.header.messageType.messageType" } ] } ] ``` -------------------------------- ### Define List (Array) Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet provides an example of defining a list (array) field in Parsnip configuration. It sets the "type" to "list", specifies the "elementType", "size", and includes an "until" condition to determine when to stop processing list items. ```JSON { "name": "data", "description": "", "notes": "", "type": "list", "elementType": "uint", "size": 8, "until": { "conditionType": "COUNT", "indicator": "mailboxSize", "minus": 10 } } ``` -------------------------------- ### Defining a Float Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet shows the structure for defining a field that stores a floating-point number in Parsnip. It demonstrates setting the 'type' property to "float" and specifying the size of the float in bits (either 32 or 64) using the 'size' property. The example defines a field named 'Name' that holds a 32-bit float value. ```JSON { "type": "float", "description": "Description", "name": "Name", "size": 32 } ``` -------------------------------- ### Initialize Git Repository for Parser Output Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Initializes a new git repository in the output folder containing the generated parser code. This is required for using the zkg utility. It adds a .gitignore for log files and commits the initial state. ```bash cd output_folder echo "*.log" > .gitignore git init . git add -A git commit -m "Initial Commit" ``` -------------------------------- ### Build Parser with Parsnip Backend Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Executes the Parsnip backend script to compile the intermediate language files into a functional parser. Requires Python 3 and the Parsnip backend dependencies. Replace 'input_folder' with the path to the unzipped Parsnip IL files and 'output_folder' with the desired location for the generated parser code. ```bash python3 main.py input_folder output_folder ``` -------------------------------- ### Configuring Protocol Summary in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Provides a concise, single-line description of the protocol for quick reference. ```JSON "protocolShortDescription": "HART-IP is the IP extension of the HART protocol." ``` -------------------------------- ### Add User to Docker Group Bash Source: https://github.com/cisagov/parsnip/blob/main/docs/parsnip.md Adds the current user to the 'docker' group, allowing non-root execution of Docker commands. Requires logging out and back in or restarting the system to take effect. ```bash sudo usermod -a -G docker $USER ``` -------------------------------- ### Providing Inputs to Parsnip Reference Types (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Demonstrates how to configure inputs for Parsnip reference types. For 'switch' types, 'input' and 'additionalInputs' are used, while 'object' types use an 'inputs' array. Shows referencing other fields with "self." and using an optional "minus" value. ```JSON { "name": "command", "description": "Command Data", "type": "switch", "referenceType": "Command16Switch", "input": { "source": "self.commandNumber" }, "additionalInputs": [ { "source": "self.byteCount" }, { "source": "messageType" } ] }, { "name": "packetContents", "description": "Device-Specific Status", "notes": "refer to appropriate device-specific document for detailed information", "type": "object", "referenceType": "ReadAdditionalDeviceStatusContents", "inputs": [ { "source": "self.byteCount", "minus": 2 }, {\n "source": "messageType" } ] } ``` -------------------------------- ### Configuring Conditional Fields in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Illustrates the use of the optional 'conditional' field in Parsnip configurations. Shows how to define conditions based on an 'indicator' field, 'operator', and 'value', including a simple object condition and an 'and' array condition. ```JSON { "name": "slot0DeviceVariableCode", "description": "Slot 0: Device Variable Code", "conditional": { "indicator": "byteCount", "operator": ">=", "value": 1 }, "type": "uint", "size": 8 }, { "name": "filenameData", "description": "", "notes": "", "type": "object", "referenceType": "FilenameValue", "scope": "general", "conditional": { "and": [ { "indicator": "dataLength", "operator": ">", "value": 14 }, { "indicator": "dataLength", "operator": "<", "value": 526 } ] } } ``` -------------------------------- ### Configuring Parsnip Version in JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Specifies the version of the Parsnip syntax being used. This helps ensure compatibility and correct processing by the backend. ```JSON "ParsnipVersion": "1.0" ``` -------------------------------- ### Defining List Termination Conditions with 'until' in Parsnip (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Shows how to use the 'until' field for list types to specify termination conditions. Demonstrates the "COUNT" condition with an 'indicator' and optional 'minus', and the "ENDOFDATA" condition. ```JSON { "name": "data", "type": "list", "elementType": "uint", "size": 8, "until": { "conditionType": "COUNT", "indicator": "dataLength", "minus": 2 } }, { "name": "commands", "type": "list", "elementType": "object", "referenceType": "CommandPDU", "scope": "general", "until": { "conditionType": "ENDOFDATA" } } ``` -------------------------------- ### Defining a Switch Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet demonstrates the structure for defining a field as a 'switch' in Parsnip. It specifies the field name, description, sets the type to 'switch', links to a specific switch structure via 'referenceType', and defines the primary input source for the switch logic as well as any additional inputs required by the switch cases. ```JSON { "name": "command", "description": "Command Data", "type": "switch", "referenceType": "Command8Switch", "input": { "source": "self.commandNumber" }, "additionalInputs": [ { "source": "self.byteCount" }, { "source": "messageType" } ] } ``` -------------------------------- ### Configuring Protocol Description in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Offers a more detailed description of the protocol, which can span multiple lines using the newline character '\n'. ```JSON "protocolLongDescription": "HART-IP is the IP extension of the HART protocol.\nIt is a hybrid analog+digital industrial automation open protocol." ``` -------------------------------- ### Configuring Protocol Name in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Defines the name of the protocol being parsed. The name should consist only of letters and underscores. ```JSON "Protocol": "HART_IP" ``` -------------------------------- ### Configuring Uses UDP in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Specifies whether the protocol is built upon the UDP transport layer. ```JSON "usesUDP": true ``` -------------------------------- ### Configuring Uses TCP in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Specifies whether the protocol is built upon the TCP transport layer. ```JSON "usesTCP": true ``` -------------------------------- ### Parsnip Object Definition - ReadPrimaryVariable (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet defines a 'ReadPrimaryVariable' object, showcasing the use of optional properties like 'reference', 'scope', and 'dependsOn'. The 'dependsOn' array specifies external inputs required by the object. The 'fields' array defines the object's data elements, including their name, description, type, size, and reference type. ```JSON "Structures": { "Objects": [ { "name": "ReadPrimaryVariable", "reference": "Universal Command specification TS20127 version 7.2 Section 6.2", "notes": "", "logIndependently": false, "scope":"universal_commands", "dependsOn": [ { "name": "byteCount", "type": "uint", "size": 8 }, { "name": "messageType", "type": "enum", "referenceType": "MessageType" } ], "fields": [ { "name": "primaryVariableUnits", "description": "Primary Variable Units", "type": "enum", "size": 8, "referenceType": "EngineeringUnitCodes" }, { "name": "primaryVariable", "description": "Primary Variable", "type": "float", "size": 32 } ] } ] } ``` -------------------------------- ### Configuring Uses Layer 2 in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Indicates whether the protocol operates directly over Ethernet (true) rather than relying on TCP or UDP (false). ```JSON "usesLayer2": false ``` -------------------------------- ### Parsnip Object Definition - Message (JSON) Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet defines a 'Message' object within the 'Structures' block. It illustrates how an object contains an array of 'fields', which can be of type 'object' and reference other defined objects ('Header', 'Body'). It also shows how 'inputs' can be specified for a field, referencing values from the parent object's fields. ```JSON "Structures": { "Objects": [ { "name": "Message", "reference": "", "notes": "", "logIndependently": false, "fields": [ { "name": "header", "description": "Protocol Header", "notes": "", "type": "object", "referenceType": "Header" }, { "name": "body", "description": "Protocol Body", "notes": "", "type": "object", "referenceType": "Body", "inputs": [ { "source": "self.header.messageID" }, { "source": "self.header.messageType.messageType" } ] } ] } ] } ``` -------------------------------- ### Configuring Ethernet Protocol Number in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md Specifies the Ethernet Protocol Number used by the protocol, applicable only when 'usesLayer2' is set to true. ```JSON "ethernetProtocolNumber": 34980 ``` -------------------------------- ### Define Signed Integer Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet demonstrates how to define a signed integer field in Parsnip configuration. It involves setting the "type" to "int" and defining the field's size in bits using the "size" property. ```JSON { "name": "Name", "description": "Description", "type": "int", "size": 16 } ``` -------------------------------- ### Define IPv6 Address Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet demonstrates how to define an IPv6 address field in Parsnip configuration. It involves setting the "type" to "addr" and the "size" to either 64 or 128 bits. ```JSON { "name": "Name", "description": "Description", "type": "addr", "size": 64 } ``` -------------------------------- ### Define IPv4 Address Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet shows how to define an IPv4 address field in Parsnip configuration. It requires setting the "type" to "addr" and the "size" to 32 bits. ```JSON { "name": "Name", "description": "Description", "type": "addr", "size": 32 } ``` -------------------------------- ### Define Void Type in Parsnip Switch Option JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet illustrates the use of the "void" type within the options of a switch statement in Parsnip configuration. It signifies a case that is meaningful but does not introduce any additional fields. ```JSON "options":[ { "value": "SESSION_CLOSE", "action": { "name": "sessionClose", "type": "void" } } ] ``` -------------------------------- ### Define Unsigned Integer Field in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet shows how to define an unsigned integer field in Parsnip configuration. It requires setting the "type" to "uint" and specifying the field's size in bits using the "size" property. ```JSON { "name": "Name", "description": "Description", "type": "uint", "size": 16 } ``` -------------------------------- ### Define Enumeration Structure in Parsnip JSON Source: https://github.com/cisagov/parsnip/blob/main/docs/syntax.md This JSON snippet shows the configuration for defining an enumeration structure in Parsnip. It sets the "type" to "enum" and includes "referenceType" and "scope" properties to link to the enumeration definition. ```JSON { "name": "writeProtectCode", "description": "Write Protect Code. The Write Protect Code must return 251, None, when write protect is not implemented by a device.", "type": "enum", "referenceType": "WriteProtectCodes", "scope": "general", "notes": "see Common Table 7, Write Protect Codes" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.