Commit 79d984bb authored by 's avatar
Browse files

Documentation updated

git-svn-id: file:///home/svn/mapi/trunk@365 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 2a2adbf9
No preview for this file type
......@@ -176,18 +176,14 @@ The user who is interested in reading the results will read the
data structure using:
void * mapi_read_results(int fd, int fid, int type)
void * mapi_read_results(int fd, int fid)
The above call receives the results computed by the function
denoted by the function descriptor {\tt fid},
which has been applied to the network flow {\tt fd}.
When {\tt type} is set to {\tt MAPI\_REF}, it returns a
pointer to the memory where the results are stored. Thus, the
application may read future values by dereferencing this pointer,
without having to invoke {\tt mapi\_read\_results()} again.
Otherwise, if {\tt type} is set to {\tt MAPI\_COPY},
it returns a pointer to a copy of the results.
It returns a pointer to a copy of the results.
\subsection{Reading packets from a flow}
......@@ -342,7 +338,7 @@ int main() {
/* read the results of the applied PKT_COUNTER function */
cnt = (unsigned long long *)mapi_read_results(fd, fid, MAPI_COPY);
cnt = (unsigned long long *)mapi_read_results(fd, fid);
printf("pkts:%llu\n", *cnt);
......@@ -432,18 +428,17 @@ int main() {
if(mapi_connect(out_fd) < 0) {
printf("Could not connect to flow %d\n", out_fd);
/* get reference to the memory where the results are stored */
in_cnt = (unsigned long long *)mapi_read_results(
in_fd, in_fid, MAPI_REF);
out_cnt = (unsigned long long *)mapi_read_results(
out_fd, out_fid, MAPI_REF);
while(1) { /* forever, report the load */
in_cnt = (unsigned long long *)mapi_read_results(
in_fd, in_fid);
out_cnt = (unsigned long long *)mapi_read_results(
out_fd, out_fid);
printf("incoming: %.2f Mbit/s (%llu bytes)\n",
(*in_cnt-in_prev)*8/1000000.0, (*in_cnt-in_prev));
printf("outgoing: %.2f Mbit/s (%llu bytes)\n\n",
......@@ -739,7 +734,7 @@ int main(int argc,char **argv)
while( loop-- ) //count the packets
res = mapi_read_results(fd,counter,MAPI_COPY);
res = mapi_read_results(fd,counter);
......@@ -830,7 +825,7 @@ int main() {
dres = (struct dmapi_results*) mapi_read_results(fd, fid, MAPI_COPY);
dres = (struct dmapi_results*) mapi_read_results(fd, fid);
for (i=0; i<dres->cnt; i++) {
count = *( (unsigned long long*) dres->res[i].result );
......@@ -841,7 +836,7 @@ int main() {
cnt = (unsigned long long *) mapi_read_results(fd, fid, MAPI_COPY);
cnt = (unsigned long long *) mapi_read_results(fd, fid);
printf("pkts:%llu\n", *cnt);
return 0;
......@@ -1413,7 +1408,7 @@ Examples
while(1) {
total_packets = mapi_read_results(fd, counter, MAPI_REF);
total_packets = mapi_read_results(fd, counter);
printf("total_packets: %lld\n", *total_packets);
......@@ -24,7 +24,7 @@ MAPI \- Monitoring Application Programming Interface
.BI "int mapi_loop(int " fd ", int " fid ", int " cnt ", mapi_handler);"
.BI "void * mapi_read_results(int " fd ", int " fid ", int " copy ");"
.BI "void * mapi_read_results(int " fd ", int " fid ");"
.BI "int mapi_set_authdata(int " fd ", const char *" public_key ", const char *" private_key ", const char *" credentials ");"
......@@ -163,25 +163,15 @@ must have been previously applied to the flow, and the corresponding identifier
must be passed to
.BR mapi_loop() .
.BI "void * mapi_read_results(int " fd ", int " fid ", int " copy ");"
.BI "void * mapi_read_results(int " fd ", int " fid ");"
.B mapi_read_results()
receives the results of the function denoted by
.I fid
applied to the flow with flow descriptor
.IR fd .
When copy is
.B mapi_read_results()
returns a pointer (void *) to the memory where the results are stored.
When copy is
then the pointer points to a memory region shared between
the MAPI daemon and the application. This is the exact region where the
daemon writes the results of the function. Thus, the application may access
future results through the same pointer without having to invoke
.B mapi_read_results()
In case that we use more than one monitoring sensors,
.B mapi_read_results()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment