KENSv3
KAIST Educational Network System
Classes | Public Types | Static Public Attributes | Protected Member Functions | Friends | List of all members
E::SystemCallInterface Class Referenceabstract

If you want to handle system call events of the Host, you should inherit this class. This class provides file descriptor management, and blocking behavior of system calls. More...

#include <E_Host.hpp>

Inheritance diagram for E::SystemCallInterface:
E::TCPAssignment

Classes

class  SystemCallParameter
 

Public Types

enum  SystemCall {
  SOCKET , CLOSE , READ , WRITE ,
  CONNECT , LISTEN , ACCEPT , BIND ,
  GETSOCKNAME , GETPEERNAME , NSLEEP , GETTIMEOFDAY
}
 

Static Public Attributes

static constexpr int AF_INET = 2
 
static constexpr int IPPROTO_TCP = 6
 
static constexpr int IPPROTO_UDP = 17
 
static constexpr int max_param = 3
 

Protected Member Functions

 SystemCallInterface (int domain, int protocol, Host &host)
 Multiple SystemCallInterface may be installed to a Host. They are distinguished by their Domain and Protocol. The interface is automatically registered to the Host when created. More...
 
virtual void systemCallback (UUID syscallUUID, int pid, const SystemCallParameter &param)=0
 When a system call is invoked by an application, this callback function is automatically called. To handle system call events, override this function. More...
 
virtual void returnSystemCall (UUID syscallUUID, int val) final
 Unblocks a blocked system call with return value. More...
 
virtual int createFileDescriptor (int processID) final
 Create a file descriptor for a certain process. The created file descriptor is automatically bound to the domain and protocol of this module. Proper system call request using this file descriptor will be passed to the SystemCallInterface which created the file descriptor. More...
 
virtual void removeFileDescriptor (int processID, int fd) final
 Close a file descriptor. Closed file descriptor becomes invalid and loses connection between this SystemCallInterface. Any system call request on invalid file descriptor will fail. More...
 

Friends

class Host
 

Detailed Description

If you want to handle system call events of the Host, you should inherit this class. This class provides file descriptor management, and blocking behavior of system calls.

Constructor & Destructor Documentation

◆ SystemCallInterface()

E::SystemCallInterface::SystemCallInterface ( int  domain,
int  protocol,
Host host 
)
protected

Multiple SystemCallInterface may be installed to a Host. They are distinguished by their Domain and Protocol. The interface is automatically registered to the Host when created.

Parameters
domainAddress domain (e.g. AF_INET).
protocolProtocl to use (e.g. IPPROTO_TCP).
hostHost to be registered.

Member Function Documentation

◆ createFileDescriptor()

int E::SystemCallInterface::createFileDescriptor ( int  processID)
finalprotectedvirtual

Create a file descriptor for a certain process. The created file descriptor is automatically bound to the domain and protocol of this module. Proper system call request using this file descriptor will be passed to the SystemCallInterface which created the file descriptor.

Parameters
processIDCreate a file descriptor for this process.
Returns
Created file descriptor.
Note
You cannot override this function.

◆ removeFileDescriptor()

void E::SystemCallInterface::removeFileDescriptor ( int  processID,
int  fd 
)
finalprotectedvirtual

Close a file descriptor. Closed file descriptor becomes invalid and loses connection between this SystemCallInterface. Any system call request on invalid file descriptor will fail.

Parameters
processIDPID of the file descriptor owner.
fdFile descriptor to be closed.
Note
You cannot override this function.

◆ returnSystemCall()

void E::SystemCallInterface::returnSystemCall ( UUID  syscallUUID,
int  val 
)
finalprotectedvirtual

Unblocks a blocked system call with return value.

Parameters
syscallUUIDUnique ID for the system call to be unblocked.
valreturn value of the system call.
Note
You cannot override this function.
See also
returnSystemCall

◆ systemCallback()

virtual void E::SystemCallInterface::systemCallback ( UUID  syscallUUID,
int  pid,
const SystemCallParameter param 
)
protectedpure virtual

When a system call is invoked by an application, this callback function is automatically called. To handle system call events, override this function.

Note
IMPORTANT: Every system call automatically blocks the caller application. Every system call should be unblocked manually. For simple non-blocking functions, just call the unblocking utility at the end of the handler.
Parameters
syscallUUIDUnique ID for this system call request.
pidProcess who raised this system call request.
paramParameters given this system call.
See also
returnSystemCall

Implemented in E::TCPAssignment.


The documentation for this class was generated from the following files: