
This patch introduces the first piece of support for the concept of "socket drivers": services that implement one or more socket protocol families. The latter are also known as "domains", as per the first parameter of the socket(2) API. More specifically, this patch adds the basic infrastructure for specifying that a particular service is the socket driver for a set of domains. Unlike major number mappings for block and character drivers, socket domain mappings are static. For that reason, they are specified in system.conf files, using the "domain" keyword. Such a keyword is to be followed by one or more protocol families, without their "PF_" prefix. For example, a service with the line "domain INET INET6;" will be mapped as the socket driver responsible for the AF_INET and AF_INET6 protocol families. This patch implements only the infrastructure for creating such mappings; the actual mapping will be implemented in VFS in a later patch. The infrastructure is implemented in service(8), RS, and VFS. For now there is a hardcoded limit of eight domains per socket driver. This may sound like a lot, but the upcoming new LWIP service will already use four of those. Also, it is allowed for a service to be both a block/character driver and a socket driver at the same time, which is a requirement for the new LWIP service. Change-Id: I93352d488fc6c481e7079248082895d388c39f2d
25 lines
655 B
C
25 lines
655 B
C
#include "syslib.h"
|
|
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
int
|
|
mapdriver(const char * label, devmajor_t major, const int * domains,
|
|
int ndomains)
|
|
{
|
|
message m;
|
|
int i;
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
m.m_lsys_vfs_mapdriver.label = (vir_bytes)label;
|
|
m.m_lsys_vfs_mapdriver.labellen = strlen(label) + 1;
|
|
m.m_lsys_vfs_mapdriver.major = major;
|
|
m.m_lsys_vfs_mapdriver.ndomains = ndomains;
|
|
if (ndomains > (int)__arraycount(m.m_lsys_vfs_mapdriver.domains))
|
|
ndomains = (int)__arraycount(m.m_lsys_vfs_mapdriver.domains);
|
|
for (i = 0; i < ndomains; i++)
|
|
m.m_lsys_vfs_mapdriver.domains[i] = domains[i];
|
|
|
|
return _taskcall(VFS_PROC_NR, VFS_MAPDRIVER, &m);
|
|
}
|