Module libafl_bolts::llmp

source ·
Expand description

A library for low level message passing

To send new messages, the clients place a new message at the end of their client_out_mem. If the current map is filled up, they place an end of page (EOP) msg and alloc a new ShMem. Once the broker mapped this same page, it flags it as safe for unmapping.

[client0]        [client1]    ...    [clientN]
  |                  |                 /
[client0_out] [client1_out] ... [clientN_out]
  |                 /                /
  |________________/                /
  |________________________________/
 \|/
[broker]

After the broker received a new message for clientN, (clientN_out->current_id != last_message->message_id) the broker will copy the message content to its own, centralized page.

The clients periodically check (current_broadcast_shmem->current_id != last_message->message_id) for new incoming messages. If the page is filled up, the broker instead creates a new page and places an end of page (EOP) message in its queue. The EOP buf contains the new description to access the shared map. The clients then switch over to read from that new current map.

[broker]
  |
[current_broadcast_shmem]
  |
  |___________________________________
  |_________________                  \
  |                 \                  \
  |                  |                  |
 \|/                \|/                \|/
[client0]        [client1]    ...    [clientN]

In the future, if we would need zero copy, the current_broadcast_shmem could instead list the client_out_shmem ID an offset for each message. In that case, the clients also need to create a new ShMem each time their bufs are filled up.

To use, you will have to create a broker using LlmpBroker::new(). Then, create some LlmpClients in other threads and register them with the main thread using LlmpBroker::register_client. Finally, call LlmpBroker::loop_forever().

For broker2broker communication, all messages are forwarded via network sockets.

Check out the llmp_test example in ./examples, or build it with cargo run --example llmp_test.

Structs§

Enums§

Constants§

Functions§

  • Receive one message of u32 len and [u8; len] bytes
  • Send one message as u32 len and [u8;len] bytes