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:
\begin{code}
void * mapi_read_results(int fd, int fid, int type)
void * mapi_read_results(int fd, int fid)
\end{code}
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}
\label{reading-packets}
......@@ -342,7 +338,7 @@ int main() {
sleep(10);
/* 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);
mapi_close_flow(fd);
......@@ -432,18 +428,17 @@ int main() {
if(mapi_connect(out_fd) < 0) {
printf("Could not connect to flow %d\n", out_fd);
exit(EXIT_FAILURE);
}
/* 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 */
sleep(1);
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
{
sleep(1);
res = mapi_read_results(fd,counter,MAPI_COPY);
res = mapi_read_results(fd,counter);
if(res)
printf("PKTS=%llu\n",*res);
else
......@@ -830,7 +825,7 @@ int main() {
while(loop--){
sleep(1);
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
mapi_connect(fd);
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);
sleep(1);
}
......
......@@ -24,7 +24,7 @@ MAPI \- Monitoring Application Programming Interface
.br
.BI "int mapi_loop(int " fd ", int " fid ", int " cnt ", mapi_handler);"
.br
.BI "void * mapi_read_results(int " fd ", int " fid ", int " copy ");"
.BI "void * mapi_read_results(int " fd ", int " fid ");"
.br
.BI "int mapi_set_authdata(int " fd ", const char *" public_key ", const char *" private_key ", const char *" credentials ");"
.br
......@@ -163,25 +163,15 @@ must have been previously applied to the flow, and the corresponding identifier
must be passed to
.BR mapi_loop() .
.sp
.BI "void * mapi_read_results(int " fd ", int " fid ", int " copy ");"
.BI "void * mapi_read_results(int " fd ", int " fid ");"
.br
.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
.BR TRUE ,
.B mapi_read_results()
returns a pointer (void *) to the memory where the results are stored.
When copy is
.BR FALSE ,
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()
again.
.sp
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