Commit 65d3461a authored by 's avatar
Browse files

Bugs fixes

git-svn-id: file:///home/svn/mapi/trunk@376 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 8af134dc
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
#include <sys/time.h> #include <sys/time.h>
#include "mapi.h" #include "mapi.h"
#include "mapiipc.h" #include "mapiipc.h"
#include "parseconf.h"
#define MAXPENDING 500 /* Maximum outstanding connection requests */ #define MAXPENDING 500 /* Maximum outstanding connection requests */
#define PORT 2233 #define CONF_FILE "./mapi.conf:%s/.mapi.conf:/etc/mapi.conf"
//TEMPORARY //TEMPORARY
typedef struct fhlp_sem { typedef struct fhlp_sem {
...@@ -37,6 +40,7 @@ void print_table(int a[], int size){ ...@@ -37,6 +40,7 @@ void print_table(int a[], int size){
//END OF TEMPORARY //END OF TEMPORARY
pthread_mutex_t lock; pthread_mutex_t lock;
int service_count; int service_count;
int dimapi_port;
void *handle_request(void *); void *handle_request(void *);
int die(char *msg); int die(char *msg);
...@@ -54,6 +58,22 @@ int main(int argc, char **argv) { ...@@ -54,6 +58,22 @@ int main(int argc, char **argv) {
struct sockaddr_in clnt_addr; struct sockaddr_in clnt_addr;
pthread_t chld_thr; pthread_t chld_thr;
char* mapi_conf;
mapi_conf = malloc(sizeof(CONF_FILE)-2+strlen(getenv("HOME")));
sprintf(mapi_conf,CONF_FILE,getenv("HOME"));
if (pc_load (mapi_conf))
{
dimapi_port = atoi( pc_get_param (pc_get_category(""), "dimapi_port") );
}
else
{
printf("Error: cannot load mapi.conf file.\n");
exit(1);
}
free(mapi_conf);
pc_close();
if ((serv_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) if ((serv_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
die("Unexpected error on socket()"); die("Unexpected error on socket()");
...@@ -62,7 +82,7 @@ int main(int argc, char **argv) { ...@@ -62,7 +82,7 @@ int main(int argc, char **argv) {
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(PORT); serv_addr.sin_port = htons(dimapi_port);
/* DANGEROUS, but useful for debugging, so leave it for now */ /* DANGEROUS, but useful for debugging, so leave it for now */
if (setsockopt(serv_sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { if (setsockopt(serv_sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
......
No preview for this file type
...@@ -1226,6 +1226,24 @@ Functions ...@@ -1226,6 +1226,24 @@ Functions
Type of results: none. Type of results: none.
TO_BUFFER
Stores the packets of a network flow in a buffer for further
reading using the mapi_get_next_pkt() function. When it applied
to a network flow, every subsequent call to mapi_get_next_pkt()
returns the next packet of the flow that was stored in the
buffer. mapi_read_results() does not return any results for
this function.
Type of results: struct mapipkt* (from mapi_get_next_pkt).
struct mapipkt {
unsigned long long ts;
unsigned short ifindex;
unsigned caplen;
unsigned wlen;
unsigned char pkt;
};
SAMPLE (int value, int mode) SAMPLE (int value, int mode)
Samples packets from a network flow. In DETERMINISTIC mode, all Samples packets from a network flow. In DETERMINISTIC mode, all
but one out of every value packets are discarded and never sent but one out of every value packets are discarded and never sent
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#ifdef DIMAPI #ifdef DIMAPI
#include <signal.h> #include <signal.h>
#include <semaphore.h> #include <semaphore.h>
#define TEST_PORT 2233
#endif #endif
#define TIME_S 4294967296 #define TIME_S 4294967296
...@@ -84,6 +83,7 @@ static int hostcmp(void *h1, void *h2); ...@@ -84,6 +83,7 @@ static int hostcmp(void *h1, void *h2);
void delete_remote_flow(remote_flowdescr_t* rflow); void delete_remote_flow(remote_flowdescr_t* rflow);
flist_t *hostlist=NULL;//list containing all remote hosts used so far flist_t *hostlist=NULL;//list containing all remote hosts used so far
extern flist_t *remote_flowlist; extern flist_t *remote_flowlist;
int dimapi_port;
typedef struct function_data { typedef struct function_data {
int fid; int fid;
...@@ -161,10 +161,11 @@ static void init() ...@@ -161,10 +161,11 @@ static void init()
{ {
path = pc_get_param (pc_get_category(""), "libpath"); path = pc_get_param (pc_get_category(""), "libpath");
libs = pc_get_param (pc_get_category(""), "libs"); libs = pc_get_param (pc_get_category(""), "libs");
dimapi_port = atoi( pc_get_param (pc_get_category(""), "dimapi_port") );
} }
else else
{ {
printf("Error: cannot find libpath. Check mapi.conf file.\n"); printf("Error: cannot load mapi.conf file.\n");
exit(1); exit(1);
} }
#endif #endif
...@@ -440,7 +441,7 @@ int mapi_create_flow(char *dev) ...@@ -440,7 +441,7 @@ int mapi_create_flow(char *dev)
h = (struct host *)malloc(sizeof(struct host)); h = (struct host *)malloc(sizeof(struct host));
h->hostname = strdup(hostname); h->hostname = strdup(hostname);
printf("New host %s\n",hostname); printf("New host %s\n",hostname);
h->port = TEST_PORT; h->port = dimapi_port;
h->flows = (flist_t *)malloc(sizeof(flist_t)); h->flows = (flist_t *)malloc(sizeof(flist_t));
flist_init(h->flows); flist_init(h->flows);
h->num_flows=0; h->num_flows=0;
......
...@@ -5,6 +5,8 @@ drvpath=@libdir@ ...@@ -5,6 +5,8 @@ drvpath=@libdir@
debug=2 debug=2
dimapi_port=2233
[driver] [driver]
device=eth0 device=eth0
driver=mapinicdrv.so driver=mapinicdrv.so
......
...@@ -88,6 +88,28 @@ If \fIstr\fP is not found in the payload, the packet will be discarded. ...@@ -88,6 +88,28 @@ If \fIstr\fP is not found in the payload, the packet will be discarded.
Type of results: \fBnone\fP. Type of results: \fBnone\fP.
.\"-------------------------------------------------------- .\"--------------------------------------------------------
.IP "\fBTO_BUFFER\fP"
Stores the packets of a network flow in a buffer for further reading using the
.B mapi_get_next_pkt()
function.
When it applied to a network flow, every subsequent call to
.B mapi_get_next_pkt()
returns the next packet of the flow that was stored in the buffer.
.B mapi_read_results()
does not return any results for this function.
Type of results: \fBstruct mapipkt*\fP (from mapi_get_next_pkt).
.nf
struct mapipkt {
unsigned long long ts;
unsigned short ifindex;
unsigned caplen;
unsigned wlen;
unsigned char pkt;
};
.fi
.\"--------------------------------------------------------
.IP "\fBSAMPLE\fP (int \fIvalue\fP, int \fImode\fP)" .IP "\fBSAMPLE\fP (int \fIvalue\fP, int \fImode\fP)"
Samples packets from a network flow. Samples packets from a network flow.
In \fBDETERMINISTIC\fP \fImode\fP, all but one out of every In \fBDETERMINISTIC\fP \fImode\fP, all but one out of every
......
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