Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
9a6e7d49
Commit
9a6e7d49
authored
Mar 14, 2006
by
Arne Øslebø
Browse files
removed change_args interface to MAPI functions
git-svn-id:
file:///home/svn/mapi/trunk@390
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
bbfc71d3
Changes
47
Hide whitespace changes
Inline
Side-by-side
anonymization/anonymize.c
View file @
9a6e7d49
...
...
@@ -1011,7 +1011,6 @@ static mapidflib_function_def_t finfo={
anonymize_init
,
//init
anonymize_process
,
//process
NULL
,
//get_result,
NULL
,
//change_args
anonymize_reset
,
//reset
anonymize_cleanup
,
//cleanup
NULL
,
//client_init
...
...
daglib/interface.c
View file @
9a6e7d49
...
...
@@ -69,7 +69,6 @@ static mapidflib_function_def_t finfo={
interface_init
,
//init
interface_process
,
//process
NULL
,
//get_result,
NULL
,
//change_args
NULL
,
//reset
NULL
,
//cleanup
NULL
,
//client_init
...
...
daglib/to_erf.c
View file @
9a6e7d49
...
...
@@ -106,7 +106,6 @@ static mapidflib_function_def_t finfo={
to_erf_init
,
to_erf_process
,
NULL
,
//get_result
NULL
,
//change_args
NULL
,
//reset
to_erf_cleanup
,
NULL
,
//client_init
...
...
errors.mapi
View file @
9a6e7d49
...
...
@@ -88,8 +88,10 @@
6154 = "Error getting current path"
#define MAPI_ERROR_FILE 6155
6155 = "Error opening file"
#define MAPI_ERROR_SEND_FD 6155
6155 = "Error sending file descriptor"
#define MAPI_ERROR_SEND_FD 6156
6156 = "Error sending file descriptor"
#define MAPI_DEVICE_INFO_ERR 6157
6149 = "Error accessing device information"
#define MFUNCT_INVALID_ARGUMENT 7000
7000 = "Invalid argument passed to function"
#define MFUNCT_INVALID_ARGUMENT_1 7001
...
...
funct_template.c
View file @
9a6e7d49
...
...
@@ -23,8 +23,8 @@ static int <funct_name>_init(mapidflib_function_instance_t *instance,
}
static
int
<
funct_name
>
_process
(
mapidflib_function_instance_t
*
instance
,
const
unsigned
char
*
dev_pkt
,
const
unsigned
char
*
link_pkt
,
unsigned
char
*
dev_pkt
,
unsigned
char
*
link_pkt
,
mapid_pkthdr_t
*
pkt_head
)
{
return
1
;
...
...
@@ -36,12 +36,6 @@ static int <funct_name>_get_result(mapidflib_function_instance_t* instance,
return
0
;
}
static
int
<
funct_name
>
_change_args
(
mapidflib_function_instance_t
*
instance
,
mapiFunctArg
*
fargs
)
{
return
0
;
}
static
int
<
funct_name
>
_reset
(
mapidflib_function_instance_t
*
instance
)
{
return
0
;
...
...
@@ -83,7 +77,6 @@ static mapidflib_function_def_t finfo={
<
funct_name
>
_init
,
//init
<
funct_name
>
_process
,
//process
<
funct_name
>
_get_result
,
//get_result,
<
funct_name
>
_change_args
,
//change_args
<
funct_name
>
_reset
,
//reset
<
funct_name
>
_cleanup
,
//cleanup
<
funct_name
>
_client_init
,
//client_init
...
...
ipfixlib/ipfixprobe.c
View file @
9a6e7d49
...
...
@@ -249,7 +249,6 @@ static mapidflib_function_def_t finfo={
ifp_process
,
ifp_get_result
,
NULL
,
NULL
,
ifp_cleanup
,
NULL
,
//client_init
ifp_client_read_result
,
...
...
mapi.c
View file @
9a6e7d49
...
...
@@ -53,13 +53,8 @@ static int local_err=0; /* occurence of a mapi.c error, translation of these err
static
int
numflows
=
0
;
// number of allocated (active) flows
static
int
totalflows
=
0
;
// number of flows so far (including closed flows)
static
char
libpath
[
256
];
static
int
offline_devices
;
static
int
availible_device_number
;
static
int
availible_offline_device_number
;
static
int
availible_library_number
;
static
int
availible_function_number
;
/*
//Structure used as a linked list to store information about
//registered functions
...
...
@@ -1797,20 +1792,9 @@ int mapi_get_function_info(int fd,int fid, mapi_function_info_t *info)
int
mapi_get_next_function_info
(
int
fd
,
int
fid
,
mapi_function_info_t
*
info
)
{
struct
mapiipcbuf
qbuf
;
flowdescr_t
*
flow
;
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
if
((
flow
=
flist_get
(
flowlist
,
fd
))
==
NULL
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d [%s:%d]
\n
"
,
fd
,
__FILE__
,
__LINE__
));
return
-
1
;
}
else
if
(
flow
->
error
!=
0
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d due to error #%d [%s:%d]
\n
"
,
fd
,
flow
->
error
,
__FILE__
,
__LINE__
));
return
-
1
;
}
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_NEXT_FUNCTION_INFO
;
...
...
@@ -1832,21 +1816,12 @@ int mapi_get_next_function_info(int fd,int fid, mapi_function_info_t *info)
int
mapi_get_flow_info
(
int
fd
,
mapi_flow_info_t
*
info
)
{
struct
mapiipcbuf
qbuf
;
flowdescr_t
*
flow
;
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
if
((
flow
=
flist_get
(
flowlist
,
fd
))
==
NULL
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d [%s:%d]
\n
"
,
fd
,
__FILE__
,
__LINE__
));
return
-
1
;
}
else
if
(
flow
->
error
!=
0
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d due to error #%d [%s:%d]
\n
"
,
fd
,
flow
->
error
,
__FILE__
,
__LINE__
));
return
-
1
;
}
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_FLOW_INFO
;
qbuf
.
fd
=
fd
;
...
...
@@ -1866,21 +1841,9 @@ int mapi_get_flow_info(int fd, mapi_flow_info_t *info)
int
mapi_get_next_flow_info
(
int
fd
,
mapi_flow_info_t
*
info
)
{
struct
mapiipcbuf
qbuf
;
flowdescr_t
*
flow
;
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
if
((
flow
=
flist_get
(
flowlist
,
fd
))
==
NULL
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d [%s:%d]
\n
"
,
fd
,
__FILE__
,
__LINE__
));
return
-
1
;
}
else
if
(
flow
->
error
!=
0
)
{
DEBUG_CMD
(
printf
(
"Invalid flow: %d due to error #%d [%s:%d]
\n
"
,
fd
,
flow
->
error
,
__FILE__
,
__LINE__
));
return
-
1
;
}
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_NEXT_FLOW_INFO
;
qbuf
.
fd
=
fd
;
...
...
@@ -1897,7 +1860,8 @@ int mapi_get_next_flow_info(int fd, mapi_flow_info_t *info)
return
MAPI_FLOW_INFO_ERR
;
}
int
/*int
mapi_load_library(const char* library)
{
struct mapiipcbuf qbuf;
...
...
@@ -1919,207 +1883,31 @@ mapi_load_library(const char* library)
}
else
return -1;
}
}*/
int
mapi_get_
availible_offli
ne_device
s
(
int
devi
cenumber
,
device_info_t
*
ret
)
int
mapi_get_ne
xt
_device
_info
(
int
devi
d
,
mapi_
device_info_t
*
info
)
{
struct
mapiipcbuf
qbuf
;
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
availible_offline_device_number
=
devicenumber
;
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_AVAILIBLE_OFFLINE_DEVICES
;
qbuf
.
fd
=
devicenumber
;
pthread_spin_lock
(
&
mapi_lock
);
mapiipc_write
(
&
qbuf
);
mapiipc_read
(
&
qbuf
);
pthread_spin_unlock
(
&
mapi_lock
);
if
(
qbuf
.
cmd
==
GET_AVAILIBLE_OFFLINE_DEVICES_ACK
)
{
memcpy
(
ret
,
&
qbuf
.
data
,
sizeof
(
device_info_t
));
return
0
;
}
else
return
-
10
;
}
int
mapi_get_next_availible_offline_device
(
device_info_t
*
ret
)
{
return
mapi_get_availible_offline_devices
(
++
availible_offline_device_number
,
ret
);
}
int
mapi_get_availible_devices
(
int
devicenumber
,
device_info_t
*
ret
)
{
struct
mapiipcbuf
qbuf
;
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
availible_device_number
=
devicenumber
;
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_AVAILIBLE_DEVICES
;
qbuf
.
fd
=
devicenumber
;
pthread_spin_lock
(
&
mapi_lock
);
mapiipc_write
(
&
qbuf
);
mapiipc_read
(
&
qbuf
);
pthread_spin_unlock
(
&
mapi_lock
);
if
(
qbuf
.
cmd
==
GET_AVAILIBLE_DEVICES_ACK
)
{
memcpy
(
ret
,
&
qbuf
.
data
,
sizeof
(
device_info_t
));
return
0
;
}
else
return
-
1
;
}
int
mapi_get_next_availible_device
(
device_info_t
*
ret
)
{
return
mapi_get_availible_devices
(
++
availible_device_number
,
ret
);
}
int
mapi_get_availible_libraries
(
int
libnumber
,
char
**
ret
)
{
struct
mapiipcbuf
qbuf
;
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
availible_library_number
=
libnumber
;
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_AVAILIBLE_LIBRARIES
;
qbuf
.
fd
=
libnumber
;
pthread_spin_lock
(
&
mapi_lock
);
mapiipc_write
(
&
qbuf
);
mapiipc_read
(
&
qbuf
);
pthread_spin_unlock
(
&
mapi_lock
);
if
(
qbuf
.
cmd
==
GET_AVAILIBLE_LIBRARIES_ACK
)
{
*
ret
=
strdup
((
char
*
)
qbuf
.
data
);
return
0
;
}
else
return
-
1
;
}
qbuf
.
cmd
=
GET_NEXT_DEVICE_INFO
;
qbuf
.
fd
=
devid
;
int
mapi_get_next_availible_library
(
char
**
ret
)
{
return
mapi_get_availible_libraries
(
++
availible_library_number
,
ret
);
}
int
mapi_get_availible_functions
(
int
libnumber
,
int
functnumber
,
mapi_function_def_mini_t
*
ret
)
{
struct
mapiipcbuf
qbuf
;
pthread_once
(
&
mapi_is_initialized
,
(
void
*
)
mapi_init
);
if
(
!
minit
)
{
DEBUG_CMD
(
printf
(
"Not initialized! [%s:%d]
\n
"
,
__FILE__
,
__LINE__
));
return
-
1
;
}
availible_function_number
=
functnumber
;
qbuf
.
mtype
=
1
;
qbuf
.
cmd
=
GET_AVAILIBLE_FUNCTIONS
;
qbuf
.
fd
=
libnumber
;
qbuf
.
fid
=
functnumber
;
pthread_spin_lock
(
&
mapi_lock
);
mapiipc_write
(
&
qbuf
);
mapiipc_read
(
&
qbuf
);
pthread_spin_unlock
(
&
mapi_lock
);
if
(
qbuf
.
cmd
==
GET_
AVAILIBLE_FUNCTIONS
_ACK
)
{
memcpy
(
ret
,
&
qbuf
.
data
,
sizeof
(
mapi_
function_def_mini
_t
));
if
(
qbuf
.
cmd
==
GET_
DEVICE_INFO
_ACK
)
{
memcpy
(
info
,
qbuf
.
data
,
sizeof
(
mapi_
device_info
_t
));
return
0
;
}
else
return
-
1
;
}
int
mapi_get_next_availible_function
(
int
libnumber
,
mapi_function_def_mini_t
*
ret
)
{
return
mapi_get_availible_functions
(
libnumber
,
++
availible_function_number
,
ret
);
}
else
return
MAPI_DEVICE_INFO_ERR
;
}
#ifdef WITH_ADMISSION_CONTROL
/*
...
...
mapi.h
View file @
9a6e7d49
...
...
@@ -94,9 +94,6 @@ typedef struct mapi_function_info {
unsigned
long
long
passed_pkts
;
//Number of packets that has passed the function
}
mapi_function_info_t
;
//Not needed. Applications should include sample.h
//#define PERIODIC 2
//#define PROBABILISTIC 3
/*Structure that contains device independant information about packets*/
struct
mapipkt
{
...
...
@@ -132,22 +129,26 @@ int agent_send_authdata(void *authdata);
#endif //DIMAPI
typedef
struct
deviceinformation
{
int
deviceid
;
int
active
;
mapi_offline_device_status_t
status
;
int
mother
;
char
devicename
[
512
];
char
description
[
512
];
}
device_info_t
;
typedef
struct
mapi_device_info
{
int
id
;
char
device
[
MAPI_STR_LENGTH
];
char
name
[
MAPI_STR_LENGTH
];
char
alias
[
MAPI_STR_LENGTH
];
char
description
[
1024
];
}
mapi_device_info_t
;
typedef
struct
mapidflib_function_def_mini
{
char
libname
[
512
];
//Name of library
char
name
[
512
];
//Name of function
char
descr
[
512
];
//Description of function
char
argdescr
[
128
];
//Description of function arguments
char
devtype
[
512
];
}
mapi_function_def_mini_t
;
typedef
struct
mapi_libfunct_info
{
char
libname
[
MAPI_STR_LENGTH
];
//Name of library
char
name
[
MAPI_STR_LENGTH
];
//Name of function
char
descr
[
1024
];
//Description of function
char
argdescr
[
MAPI_STR_LENGTH
];
//Description of function arguments
char
devtype
[
MAPI_STR_LENGTH
];
}
mapi_libfunct_info_t
;
typedef
struct
mapi_lib_info
{
char
libname
[
MAPI_STR_LENGTH
];
//Name of library
unsigned
int
functs
;
//Number of functions in the library
}
mapi_lib_info_t
;
//Prototype of the mapi_loop callback function
...
...
@@ -194,35 +195,30 @@ int mapi_read_error(int fd, int* err_no, char* errorstr);
int
mapi_set_authdata
(
int
fd
,
const
char
*
pub
,
const
char
*
priv
,
const
char
*
creds
);
//Load new library
int
mapi_load_library
(
const
char
*
library
);
//int mapi_load_library(char* library);
//Unload library
//int mapi_unload_library(char* library);
//Get information on hardware-devices
int
mapi_get_
availible_
device
s
(
int
devicenumber
,
device_info_t
*
ret
);
int
mapi_get_next_
availible_device
(
device_info_t
*
ret
);
int
mapi_get_device
_info
(
int
devicenumber
,
mapi_
device_info_t
*
info
);
int
mapi_get_next_
device_info
(
int
devicenumber
,
mapi_
device_info_t
*
info
);
//Get information on offline-devices
int
mapi_get_availible_offline_devices
(
int
,
device_info_t
*
ret
);
int
mapi_get_next_availible_offline_device
(
device_info_t
*
ret
);
//Get information on loaded libraries
int
mapi_get_
availible_libraries
(
int
,
char
**
ret
);
int
mapi_get_next_
availible_library
(
char
**
ret
);
//Get infromation on availible functions
int
mapi_get_
availible_functions
(
int
,
int
,
mapi_funct
ion_def_mini_t
*
);
int
mapi_get_next_availible_function
(
int
,
mapi_function_def_mini_t
*
);
int
mapi_get_
library_info
(
int
libnum
,
mapi_lib_info_t
*
info
);
int
mapi_get_next_
library_info
(
int
libnum
,
mapi_lib_info_t
*
info
);
int
mapi_get_libfunct_info
(
int
libnum
,
mapi_libfunct_info_t
*
info
);
int
mapi_get_
libfunct_next_info
(
int
libnum
,
mapi_
lib
funct
_info_t
*
info
);
//Get information about a flow
int
mapi_get_flow_info
(
int
fd
,
mapi_flow_info_t
*
info
);
//Get information about next flow with flow descriptor>fd
int
mapi_get_next_flow_info
(
int
fd
,
mapi_flow_info_t
*
info
);
//Get information about a function
int
mapi_get_function_info
(
int
fd
,
int
fid
,
mapi_function_info_t
*
info
);
//Get information about a function
//Get information about a function applied to a flow
int
mapi_get_function_info
(
int
fd
,
int
fid
,
mapi_function_info_t
*
info
);
//Get information about a function applied to a flow
int
mapi_get_next_function_info
(
int
fd
,
int
fid
,
mapi_function_info_t
*
info
);
#endif
mapid.c
View file @
9a6e7d49
...
...
@@ -141,7 +141,6 @@ int (*mapidrv_load_library) (char *lib);
int
(
*
mapidrv_add_device
)
(
mapi_offline_device_status_t
*
,
char
*
devname
,
int
file
,
int
devid
,
global_function_list_t
*
gflist
);
int
(
*
mapidrv_get_flow_info
)
(
int
devid
,
int
fd
,
mapi_flow_info_t
*
info
);
int
(
*
mapidrv_delete_device
)
(
int
devid
);
mapi_function_def_mini_t
*
(
*
mapidrv_get_function_info
)(
int
libnumber
,
int
functionnumber
);
unsigned
char
*
(
*
mapidrv_get_lib_name
)(
int
libnumber
);
...
...
@@ -480,7 +479,7 @@ cmd_load_library (char *lib, int pid, int sock)
static
void
cmd_get_lib
name
(
int
libnumber
,
int
pid
,
int
sock
)
cmd_get_lib
rary_info
(
int
libnumber
,
int
pid
,
int
sock
)
{
struct
mapiipcbuf
buf
;
...
...
@@ -490,7 +489,7 @@ cmd_get_libname(int libnumber,int pid, int sock)
strncpy
((
char
*
)
buf
.
data
,
(
char
*
)
mapidrv_get_lib_name
(
libnumber
),
sizeof
(
buf
.
data
));
buf
.
cmd
=
GET_
AVAILIBLE_LIBRARIES
_ACK
;
buf
.
cmd
=
GET_
LIBRARY_INFO
_ACK
;
}
else
{
...
...
@@ -501,156 +500,6 @@ cmd_get_libname(int libnumber,int pid, int sock)
mapiipc_daemon_write
((
struct
mapiipcbuf
*
)
&
buf
,
sock
);
}
static
void
cmd_get_function
(
int
libnumber
,
int
functionnumber
,
int
pid
,
int
sock
)
{
//returner en slags mapidflib_function_def_t, men uten funksjonspekerne.
struct
mapiipcbuf
buf
;
if
(
drvlist
!=
NULL
)
{
mapi_function_def_mini_t
*
ret
;
mapidrv_get_function_info
=
get_drv_funct
(
drvlist
->
handle
,
"mapidrv_get_function_info"
);
ret
=
mapidrv_get_function_info
(
libnumber
,
functionnumber
);
if
(
ret
!=
NULL
)
{
memcpy
(
&
buf
.
data
,
ret
,
sizeof
(
mapi_function_def_mini_t
));
buf
.
cmd
=
GET_AVAILIBLE_FUNCTIONS_ACK
;
free
(
ret
);
}
else
buf
.
cmd
=
ERROR_ACK
;
}
else
{
buf
.
cmd
=
ERROR_ACK
;
}
buf
.
mtype
=
pid
;
buf
.
fd
=
-
1
;
mapiipc_daemon_write
((
struct
mapiipcbuf
*
)
&
buf
,
sock
);
}
static
void
cmd_get_device_info
(
int
devicenumber
,
int
pid
,
int
sock
)
{
struct
mapiipcbuf
buf
;
mapidrv
*
drv
;
device_info_t
device
;
int
ok
=
0
;
for
(
drv
=
drvlist
;
drv
!=
NULL
;
drv
=
drv
->
next
)
{
if
(
drv
->
offline
)
continue
;
if
(
devicenumber
==
0
)
{
if
(
drv
->
description
!=
NULL
)
strncpy
(
device
.
description
,
drv
->
description
,
sizeof
(
device
.
description
));
device
.
deviceid
=
drv
->
devid
;
strncpy
(
device
.
devicename
,
drv
->
device
,
sizeof
(
device
.
devicename
));
device
.
active
=
drv
->
active
;
device
.
status
=
drv
->
offline_status
;
ok
=
1
;
break
;
}
devicenumber
--
;
}
if
(
ok
)
{
buf
.
cmd
=
GET_AVAILIBLE_DEVICES_ACK
;
}
else
buf
.
cmd
=
ERROR_ACK
;
buf
.
mtype
=
pid
;
buf
.
fd
=
-
1
;
memcpy
(
&
buf
.
data
,
&
device
,
sizeof
(
device_info_t
));
mapiipc_daemon_write
((
struct
mapiipcbuf
*
)
&
buf
,
sock
);
}
static
void
cmd_get_offline_device_info
(
int
devicenumber
,
int
pid
,
int
sock
)
{
struct
mapiipcbuf
buf
;
mapidrv
*
drv
;
device_info_t
device
;
int
ok
=
0
;
for
(
drv
=
drvlist
;
drv
!=
NULL
;
drv
=
drv
->
next
)
{
if
(
devicenumber
==
0
)
{
if
(
drv
->
description
!=
NULL
)
strncpy
(
device
.
description
,
drv
->
description
,
sizeof
(
device
.
description
));
else
sprintf
(
device
.
description
,
"No description"
);
device
.
deviceid
=
drv
->
devid
;
strncpy
(
device
.
devicename
,
drv
->
device
,
sizeof
(
device
.
devicename
));
device
.
active
=
drv
->
active
;
device
.
status
=
drv
->
offline_status
;
buf
.
cmd
=
GET_AVAILIBLE_OFFLINE_DEVICES_ACK
;
ok
=
1
;
break
;
}
devicenumber
--
;
}
if
(
!
ok
)
buf
.
cmd
=
ERROR_ACK
;
buf
.
mtype
=
pid
;