Skip to content

Commit

Permalink
Documentation: Move IPC endpoint documentation to manpage section 4
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinesfilmroellchen authored and linusg committed Jul 11, 2022
1 parent 9660f5d commit 1419732
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Documentation/FileFormats.md → Base/usr/share/man/man4/ipc.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Serenity Formats
## Name

This document summarizes all non-standard file formats, data formats, and mime-types used by Serenity.
ipc - Unix socket Inter Process Communication protocols

## Inter Process Communication (through Unix sockets)
## Synopsis

The various services each have their own formats, all very similar, and automatically implemented through LibIPC. The specifics depend on the corresponding source `.ipc` file.
IPC endpoints are provided as Unix sockets in `/tmp/portal`. All services have their own formats, automatically implemented through LibIPC.

The format can be identified by the format magic, which is derived in [`Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp`](../Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp)
from the service-endpoint name, e.g. "ClipboardClient" (which hashes to 4008793515) or "ClipboardServer" (which hashes to 1329211611).
## Description

The specifics of each service's format depend on the corresponding source `.ipc` file.

The format can be identified by the format magic, which is derived in [`Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp`](../../../../../Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp) from the service-endpoint name, e.g. "ClipboardClient" (which hashes to 4008793515) or "ClipboardServer" (which hashes to 1329211611).

In general, communication works by packets, which might have been sent in response to other packets. Everything is host endianness. Each packet consists of:
- a 32-bit message size (see `Connection::try_parse_messages` in [`Userland/Libraries/LibIPC/Connection.h`](../Userland/Libraries/LibIPC/Connection.h))
- a 32-bit message size (see `Connection::try_parse_messages` in [`Userland/Libraries/LibIPC/Connection.h`](../../../../../Userland/Libraries/LibIPC/Connection.h))
- the 32-bit endpoint magic (note that responses use the endpoint of the requesting packet, so the Clipboard server might use the endpoint magic 4008793515 to signal that this packet is a response)
- the 32-bit message ID within that endpoint (sequentially assigned, starting at 1)
- the data of that message itself (e.g. see `Messages::ClipboardServer::SetClipboardData::{en,de}code` in `Build/*/Userland/Services/Clipboard/ClipboardServerEndpoint.h`).

## See Also

- [ipc(5)](help:https://man/5/ipc) (IPC file format documentation)
1 change: 1 addition & 0 deletions Base/usr/share/man/man5/ipc.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ The format is loosely inspired by C++ headers.
## See Also

- [`Meta/Lagom/Tools/CodeGenerators/IPCCompiler/`](../../../../../Meta/Lagom/Tools/CodeGenerators/IPCCompiler/).
- [ipc(4)](help:https://man/4/ipc) (IPC Unix socket documentation)

0 comments on commit 1419732

Please sign in to comment.