ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
stomp.h File Reference

The STOMP 1.2 frame codec: the sec 9 grammar, built and parsed over caller buffers. More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

The STOMP 1.2 frame codec: the sec 9 grammar, built and parsed over caller buffers.

STOMP 1.2 is a community specification published at https://stomp.github.io/stomp-specification-1.2.html. It is not an IETF document and carries no RFC number; every citation here names that specification and its section.

Sec 9 Augmented BNF gives the frame:

frame       = command EOL *( header EOL ) EOL *OCTET NULL *( EOL )
header      = header-name ":" header-value
header-name = 1*<any OCTET except CR or LF or ":">
EOL         = [CR] LF

Sec 4 states the octets: a command terminated by an EOL, "an OPTIONAL carriage return (octet 13) followed by a REQUIRED line feed (octet 10)", then zero or more header entries in <key>:<value> format, then "a blank line (i.e. an extra EOL)" ending the headers and beginning the body. Sec 6 names the client commands, sec 7 the server commands.

Sec 4.3.1: a content-length header "is an octet count for the length of the message body. If a content-length header is included, this number of octets MUST be read, regardless of whether or not there are NULL octets in the body. The frame still needs to be terminated with a NULL octet." With no such header the body runs to the first NULL.

Sec 4.1 Value Encoding escapes four octets inside a header-name or header-value: \r is CR, \n is LF, \c is colon, \\ is backslash. An undefined escape sequence "MUST be treated as a fatal protocol error", so an unescape reports zero octets on one.

Sec 4.4 Repeated Header Entries: "only the first header entry SHOULD be used as the value of header entry" - the entry a lookup reports.

Sec 5.4 Heart-beating: a sender with no frame to send "MUST send an end-of-line (EOL)", and sec 9 trails a frame with *( EOL ). A parse steps over those octets ahead of a command and counts them in consumed.

The parser copies nothing: the command, every header-name and header-value, and the body are slices into the caller's buffer, and a header-value arrives still escaped. The builder escapes every header-name and header-value it writes; sec 4.1 exempts the CONNECT and CONNECTED frames from escaping for STOMP 1.0 compatibility.

The module exports one symbol, Stomp. Everything in stomp.c has internal linkage.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file stomp.h.