Skip to content

Protocol

Mihir Lad edited this page Jul 7, 2020 · 2 revisions

Protocol

All IPC packets must contain a specific message header that contains the IPC magic string, the message size, and the message type.

Here is the definition for the message header:

...
#define IPC_MAGIC "DWM-IPC"
#define IPC_MAGIC_ARR { 'D', 'W', 'M', '-', 'I', 'P', 'C' }
#define IPC_MAGIC_LEN 7 // Not including null char

typedef struct dwm_ipc_header {
  uint8_t magic[IPC_MAGIC_LEN];
  uint32_t size;
  uint8_t type;
  ...
} __attribute((packed)) dwm_ipc_header_t;

As you can see, the header is 12 bytes long. the first 7 bytes of the header is the non-null-terminated string: DWM-IPC. The next 4 bytes represent the size of the following message. The size should not include the size of the header. The next byte indicates the message type. The integers representing each message type can be found in ipc.h.

Here is a sample message header in hex format:

44 57 4D 2D  | D W M -
49 50 43 1E  | I P C .
00 00 00 04  | . . . .

 44 57 4D 2D 49 50 43 1E 00 00 00 04
|____________________|___________|__|
 magic (DWM-IPC)      size (30)   type (4)

After the IPC header, the payload/message should follow in JSON format. To view all the implemented message types and formats, view the Messages wiki page

Clone this wiki locally