EMANE  1.2.1
File Descriptor Service

The FileDescriptorServiceProvider is used by NEM layer components to register file descriptors for servicing by the NEM layer functor queue.

Registering a File Descriptor

FileDescriptorServiceProvider::addFileDescriptor is a template method that associates a callable and a type, either read or write, with a file descriptor.

pPlatformService_->fileDescriptorService().addFileDescriptor(pTunTap_->get_handle(),
FileDescriptorServiceProvider::DescriptorType::READ,
std::bind(&VirtualTransport::readDevice,
this,
std::placeholders::_1));

The FileDescriptorServiceProvider is accessed via the PlatformServiceProvider. All components are given a reference to the PlatformServiceProvider when they are constructed.

Servicing A File Descriptor

The NEMQueuedLayer uses epoll with level-triggered events to service registered file descriptors using their associated callables.

Unregistering a File Descriptor

A file descriptor can be removed from processing by using FileDescriptorServiceProvider::removeFileDescriptor.

pPlatformService_->fileDescriptorService().removeFileDescriptor(pTunTap_->get_handle());