mtcp_define_event 3 2017-08-28 "Linux" "mOS Library Functions Manual"
NAME
mtcp_define_event - define a user-defined event function
SYNOPSIS
#include <mos_api.h> "int mtcp_define_event(event_t " event ", filter_t " filter ", struct filter_arg * " arg " );
DESCRIPTION
mtcp_define_event () creates a new user-defined event (UDE) with a base event
"event" and a filter function
"filter" with a filter argument
"arg" .
More specifically, a UDE is defined as a based event and a boolean
filter function that determines the event condition. When the base
event for a UDE is raised, mOS triggers the UDE only when the filter
function is evaluated to be true.
"event" argument is a typedef'ed uint64_t integer. It can be either a built-in
event or a user-defined event. mOS provides the following
built-in events that a user can employ:
| Events |
| Type:Description |
| MOS_ON_PKT_IN: |
| Packet arrival. |
| MOS_ON_CONN_START: |
| Connection initiation (the first SYN packet). |
| MOS_ON_REXMIT: |
| TCP packet retransmission. |
| MOS_ON_TCP_STATE_CHANGE: |
| TCP state transition. |
| MOS_ON_CONN_END: |
| Connection termination. |
| MOS_ON_CONN_NEW_DATA: |
| New flow data. |
| MOS_ON_ORPHAN: |
| Out-of-flow (or non-TCP) packet arrival. |
| MOS_ON_ERROR: |
| Error report (e.g. receive buffer full (see |
| mtcp_peek())). T}
.TE
A typical usage of mtcp_define_event() is illustrated below:
/*************************************************/
// creates a passive monitoring socket with its scope
s = mtcp_socket(m, AF_INET, MOS_SOCK_MONITOR_STREAM, 0);
ft.stream_syn_filter = "dst net 216.58 and dst port 80";
mtcp_bind_monitor_filter(m, s, &ft);
// defines a user-defined event that detects an HTTP request
hev = mtcp_define_event(MOS_ON_CONN_NEW_DATA, IsHTTPRequest, NULL);
/*************************************************/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" RETURN VALUE Returns 0 on success; -1 on failure.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".SH CONFORMING TO """"POSIX.1-2001. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ERRORS 15
"EINVAL" The socket descriptor,
"sockid" is invalid.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" AUTHORS mOS development team <[email protected]>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" SEE ALSO mtcp_socket (), mtcp_bind_monitor_filter (), mtcp_register_callback () """"""""""""""""""""""""""""""""""""""""""""""""""""" COLOPHON This page is part of mOS release 0.3
"docs" section. A description of the project, and information
about reporting bugs, can be found at
\%http://mos.kaist.edu/.
""""""""""""""""""""""""""""""""""""""""""""""""""""" |