Skip to content

Relayer architecture

palesius edited this page Nov 11, 2013 · 1 revision

###Overview The relayer thread runs in a loop, reading packets, filtering them, then writing them. It will 1st attempt to read a packet from the endpoint, then will attempt to read a packet from the injection queue. It will then run the packet through each filter in order until the filter flag is cleared on the packet. It will finally write the packet out to the receiving endpoint unless the transmit flag was cleared on the packet. Pseudocode below:

while(running) {
    packet=read_from_EP();
    if packet {
        for each filter in filters {
            if (!packet->filter) then {break;}
            filter->process(packet);
        }
        if (packet->transmit) then {write_to_EP();}
    }
    packet=read_from_queue();
    if packet {
        for each filter in filters {
            if (!packet->filter) then {break;}
            filter->process(packet);
        }
        if (packet->transmit) then {write_to_EP();}
    }
}
Clone this wiki locally