Commit 6fb6f402 authored by 's avatar

mapi tutorial and man pages update


git-svn-id: file:///home/svn/mapi/trunk@684 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent b570fa18
......@@ -12,6 +12,12 @@ MAPI \- Monitoring Application Programming Interface
.br
.BI "int mapi_create_offline_flow(char *" path ", int " format ");"
.br
.BI "char* mapi_create_offline_device(const char *" path", int " format "); "
.br
.BI "int mapi_start_offline_device(const char *" dev ");"
.br
.BI "int mapi_delete_offline_device(char *" dev ");"
.br
.BI "int mapi_close_flow(int " fd ");"
.br
.BI "int mapi_authenticate(int " fd ", char* " username ", char* " password ", char* " vo ");"
......@@ -92,6 +98,53 @@ Upon successful creation,
returns a unique flow descriptor for the newly
created flow, or -1 if there is an error.
.sp
.BI "char* mapi_create_offline_device(const char *" path", int " format "); "
.br
.B mapi_create_offline_device()
is used to create a device that reads packets from a trace file.
It creates a new network flow that consists of the packets from the trace file.
It returns the device name that should be used in
.B mapi_start_offline_device.
.IR path
specifies the name of the trace file to open.
The format of the captured packets is specified by the
.IR format
parameter:
.RS 4
.TP 4
.B MFF_TCPDUMP
.BR tcpdump (8)
- libpcap format
.TP 4
.B MFF_DAG_ERF
ERF Type 2 Ethernet Variable Length Record format used by the DAG card
family
.RE
.sp
In case of errors, it returns NULL.
.sp
.BI "int mapi_start_offline_device(const char *" dev ");"
.br
.B mapi_start_offline_device
starts reading packets from the trace file
that has been opened through
.B mapi_create_offline_device().
.IR dev
is the device name that corresponds to the tracefile, and has been returned
from
.B mapi_create_offline_device.
Upon success, it returns 0. Otherwise, in error cases, it returns -1.
.sp
.BI "int mapi_delete_offline_device(char *" dev ");"
.br
Deletes the device that reads packets from a trace file and has been opened through
.B mapi_create_offline_device().
.IR dev
is the device name that corresponds to the tracefile, and has been returned
from
.B mapi_create_offline_device.
Upon success, it returns 0. Otherwise, in error cases, it returns -1.
.sp
.BI "int mapi_close_flow(int " fd ");"
.br
.B mapi_close_flow()
......
......@@ -46,7 +46,7 @@ that contain covert GNUTELLA traffic.
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include "mapi.h"
#include <mapi.h>
static void die();
int fd;
......@@ -55,6 +55,7 @@ int main(int argc,char *argv[]) {
int counter;
unsigned long long *total_packets;
mapi_results_t *result;
signal(SIGINT, die);
signal(SIGQUIT, die);
......@@ -69,7 +70,8 @@ int main(int argc,char *argv[]) {
mapi_connect(fd);
while(1) {
total_packets = mapi_read_results(fd, counter, MAPI_REF);
result = mapi_read_results(fd, counter, MAPI_REF);
total_packets = (unsigned long long*)result->res;
printf("total_packets: %lld\\n", *total_packets);
sleep(1);
}
......
No preview for this file type
......@@ -541,12 +541,12 @@ int main() {
sleep(1);
result1 = (unsigned long long *)mapi_read_results(
result1 = mapi_read_results(
in_fd, in_fid);
result2 = (unsigned long long *)mapi_read_results(
result2 = mapi_read_results(
out_fd, out_fid);
in_cnt = result1->res;
out_cnt = results2->res;
out_cnt = result2->res;
printf("incoming: %.2f Mbit/s (%llu bytes)\n",
(*in_cnt-in_prev)*8/1000000.0, (*in_cnt-in_prev));
......@@ -795,9 +795,11 @@ and fixed checksum field.
static int fd;
static void die(int d);
int main(int argc,char **argv)
{
int counter, loop = 10, int connect_status;
int counter, loop = 10, connect_status;
mapi_results_t *dres;
signal(SIGINT,die);
......@@ -825,7 +827,7 @@ int main(int argc,char **argv)
connect_status = mapi_connect(fd);
if(connect_status < 0)
{
printf("mapi_connect has failed.\n")
printf("mapi_connect has failed.\n");
die(0);
}
......@@ -852,12 +854,12 @@ int main(int argc,char **argv)
\end{Verbatim}
The user creates a flow (line 19) and then applies the packet counter
function (line 26). He then proceeds to authenticate himself as the
creator of the flow. This is done with the {\tt mapi\_authenticate} function (line 29).
The user creates a flow (line 21) and then applies the packet counter
function (line 28). He then proceeds to authenticate himself as the
creator of the flow. This is done with the {\tt mapi\_authenticate} function (line 31).
The user is verified to belong in the VO specified, and then the
password is checked for matching. When the user connect to
the flow (line 36), the mapi daemon further checks if the flow is authenticated
the flow (line 38), the mapi daemon further checks if the flow is authenticated
If it does not, an error is returned to the user.
\subsection{Using DiMAPI}
......@@ -880,8 +882,8 @@ int main() {
int fid;
mapi_results_t *dres;
unsigned long long *count, *total_count=0;
int i;
unsigned long long *count, total_count=0;
int i, loop;
int number_of_sensors;
signal(SIGINT, terminate);
......@@ -926,9 +928,9 @@ int main() {
dres = mapi_read_results(fd, fid);
for (i=0; i<number_of_sensors; i++) {
count = *( (unsigned long long*) dres[i]->res );
printf("web pkts in host %d: %llu\n",i, count);
total_count += count;
count = (unsigned long long*) dres[i].res;
printf("web pkts in host %d: %llu\n",i, *count);
total_count += *count;
}
printf("Total web packets: %llu\n",total_count);
}
......@@ -952,7 +954,7 @@ number of the monitoring hosts that should give results,
one \textit{mapi\_results\_t} instance (in a table) per every monitoring sensor
(in our example this will be equal to three).
The actual result of the \textit{PKR\_COUNTER} function
for the monitoring sensor \textit{i} is retrieved from \textit{dres[i]-$>$res} field.
for the monitoring sensor \textit{i} is retrieved from \textit{dres[i].res} field.
Finally, we close the network flow in order to free all the
resources allocated in every monitoring sensor.
......
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