Commit 0d4ec436 authored by 's avatar

Now functions not present in stdflib (e.g. dagflib:INTERFACE) can be applied over DiMAPI too.

devtype is returned when creating remote flow and is used when applying functions, no more
stdflib (1.3) is forced.


git-svn-id: file:///home/svn/mapi/trunk@1442 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent e3c7fdb9
...@@ -197,6 +197,7 @@ struct dmapiipcbuf { ...@@ -197,6 +197,7 @@ struct dmapiipcbuf {
typedef struct host_flow { typedef struct host_flow {
struct host *rhost; struct host *rhost;
char* dev; char* dev;
char *devtype;
int scope_fd; int scope_fd;
int fd; //fd of flow in the mapid of host int fd; //fd of flow in the mapid of host
int id; int id;
......
...@@ -499,6 +499,7 @@ static void delete_remote_flow(remote_flowdescr_t* rflow) ...@@ -499,6 +499,7 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
flist_destroy(hflow->functions); flist_destroy(hflow->functions);
free(hflow->functions); free(hflow->functions);
free(hflow->dev); free(hflow->dev);
free(hflow->devtype);
free(hflow->dbuf); free(hflow->dbuf);
if (hflow->pkt!=NULL) free(hflow->pkt); if (hflow->pkt!=NULL) free(hflow->pkt);
...@@ -545,6 +546,16 @@ static void delete_remote_flow(remote_flowdescr_t* rflow) ...@@ -545,6 +546,16 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
} }
#endif #endif
char *mapi_get_devtype_of_flow(int fd) {
flowdescr_t *tmpflow;
char *devtype;
tmpflow = flist_get(flowlist, fd);
devtype = strdup(tmpflow->devtype);
return devtype;
}
int mapi_create_flow(const char *dev) int mapi_create_flow(const char *dev)
//Create new flow //Create new flow
//dev=device that should be used //dev=device that should be used
...@@ -560,7 +571,7 @@ int mapi_create_flow(const char *dev) ...@@ -560,7 +571,7 @@ int mapi_create_flow(const char *dev)
remote_flowdescr_t *rflow; remote_flowdescr_t *rflow;
char *hostname=NULL, *s=NULL, *k=NULL; char *hostname=NULL, *s=NULL, *k=NULL;
struct host *h=NULL; struct host *h=NULL;
host_flow* hflow; host_flow* hflow = NULL;
char *devp; char *devp;
flist_node_t* fnode; flist_node_t* fnode;
unsigned int idgen=0; unsigned int idgen=0;
...@@ -738,6 +749,7 @@ int mapi_create_flow(const char *dev) ...@@ -738,6 +749,7 @@ int mapi_create_flow(const char *dev)
hflow=(host_flow*)fnode->data; hflow=(host_flow*)fnode->data;
if (hflow->dbuf->cmd == CREATE_FLOW_ACK) { if (hflow->dbuf->cmd == CREATE_FLOW_ACK) {
hflow->fd=*((int*)hflow->dbuf->data); hflow->fd=*((int*)hflow->dbuf->data);
hflow->devtype = strdup((char *)(((char *)hflow->dbuf->data) + sizeof(int)));
flist_remove(hflow->rhost->flows, hflow->dbuf->fd); flist_remove(hflow->rhost->flows, hflow->dbuf->fd);
flist_append(hflow->rhost->flows, hflow->fd, hflow); flist_append(hflow->rhost->flows, hflow->fd, hflow);
} }
...@@ -1521,8 +1533,7 @@ int mapi_apply_function(int fd, const char* funct, ...) ...@@ -1521,8 +1533,7 @@ int mapi_apply_function(int fd, const char* funct, ...)
#ifdef DIMAPI #ifdef DIMAPI
} }
if (is_remote) fdef=mapilh_get_function_def(funct,"1.3"); if (!is_remote) {
else
#endif #endif
//Get information about function //Get information about function
...@@ -1533,6 +1544,9 @@ int mapi_apply_function(int fd, const char* funct, ...) ...@@ -1533,6 +1544,9 @@ int mapi_apply_function(int fd, const char* funct, ...)
local_err = MAPI_FUNCTION_NOT_FOUND; local_err = MAPI_FUNCTION_NOT_FOUND;
return -1; return -1;
} }
#ifdef DIMAPI
}
#endif
#ifdef DIMAPI #ifdef DIMAPI
if(is_remote){//flow is remote if(is_remote){//flow is remote
...@@ -1540,6 +1554,14 @@ int mapi_apply_function(int fd, const char* funct, ...) ...@@ -1540,6 +1554,14 @@ int mapi_apply_function(int fd, const char* funct, ...)
for (fnode=flist_head(rflow->host_flowlist), i=1; fnode!=NULL; fnode=flist_next(fnode), i++) { for (fnode=flist_head(rflow->host_flowlist), i=1; fnode!=NULL; fnode=flist_next(fnode), i++) {
hflow=(host_flow*)fnode->data; hflow=(host_flow*)fnode->data;
fdef=mapilh_get_function_def(funct,hflow->devtype);
if(fdef==NULL) {
printf("ERROR: Could not find/match function %s [%s:%d]\n", funct, __FILE__, __LINE__);
local_err = MAPI_FUNCTION_NOT_FOUND;
return -1;
}
hflow->dbuf->cmd=APPLY_FUNCTION; hflow->dbuf->cmd=APPLY_FUNCTION;
hflow->dbuf->fd=hflow->fd; hflow->dbuf->fd=hflow->fd;
memcpy(hflow->dbuf->data, funct, strlen(funct)+1);//put function name in the buffer memcpy(hflow->dbuf->data, funct, strlen(funct)+1);//put function name in the buffer
...@@ -4348,8 +4370,7 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i ...@@ -4348,8 +4370,7 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i
#ifdef DIMAPI #ifdef DIMAPI
} }
if (is_remote) fdef=mapilh_get_function_def(funct,"1.3"); if (!is_remote) {
else
#endif #endif
//Get information about function //Get information about function
...@@ -4360,12 +4381,24 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i ...@@ -4360,12 +4381,24 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i
local_err = MAPI_FUNCTION_NOT_FOUND; local_err = MAPI_FUNCTION_NOT_FOUND;
return -1; return -1;
} }
#ifdef DIMAPI
}
#endif
#ifdef DIMAPI #ifdef DIMAPI
if(is_remote){//flow is remote if(is_remote){//flow is remote
for (fnode=flist_head(rflow->host_flowlist), i=1; fnode!=NULL; fnode=flist_next(fnode), i++) { for (fnode=flist_head(rflow->host_flowlist), i=1; fnode!=NULL; fnode=flist_next(fnode), i++) {
hflow=(host_flow*)fnode->data; hflow=(host_flow*)fnode->data;
fdef=mapilh_get_function_def(funct,hflow->devtype);
if(fdef==NULL) {
printf("ERROR: Could not find/match function %s [%s:%d]\n", funct, __FILE__, __LINE__);
local_err = MAPI_FUNCTION_NOT_FOUND;
return -1;
}
hflow->dbuf->cmd=APPLY_FUNCTION; hflow->dbuf->cmd=APPLY_FUNCTION;
hflow->dbuf->fd=hflow->fd; hflow->dbuf->fd=hflow->fd;
memcpy(hflow->dbuf->data, funct, strlen(funct)+1);//put function name in the buffer memcpy(hflow->dbuf->data, funct, strlen(funct)+1);//put function name in the buffer
......
...@@ -253,4 +253,7 @@ extern int mapi_get_next_function_info(int fd, int fid, mapi_function_info_t *in ...@@ -253,4 +253,7 @@ extern int mapi_get_next_function_info(int fd, int fid, mapi_function_info_t *in
//mapi stats //mapi stats
extern int mapi_stats(const char *dev, struct mapi_stat *stats); extern int mapi_stats(const char *dev, struct mapi_stat *stats);
// internal use only (mapi_create_flow does not give devtype directly)
extern char *mapi_get_devtype_of_flow(int id);
#endif #endif
...@@ -326,6 +326,7 @@ void *handle_request(void *arg) { ...@@ -326,6 +326,7 @@ void *handle_request(void *arg) {
mapi_function_info_t funct_info; mapi_function_info_t funct_info;
mapi_flow_info_t flow_info; mapi_flow_info_t flow_info;
mapi_device_info_t device_info; mapi_device_info_t device_info;
char *devtype = NULL;
#ifdef RECONNECT #ifdef RECONNECT
int ignore_flag = 0; int ignore_flag = 0;
#endif #endif
...@@ -435,12 +436,21 @@ void *handle_request(void *arg) { ...@@ -435,12 +436,21 @@ void *handle_request(void *arg) {
memcpy(dbuf->data, &errno, sizeof(int)); memcpy(dbuf->data, &errno, sizeof(int));
} }
else { else {
devtype = mapi_get_devtype_of_flow(mapid_result);
if(devtype != NULL) {
dbuf->cmd = CREATE_FLOW_ACK; dbuf->cmd = CREATE_FLOW_ACK;
memcpy(dbuf->data, &mapid_result, sizeof(int)); memcpy(dbuf->data, &mapid_result, sizeof(int));
memcpy(((char *)dbuf->data) + sizeof(int), devtype, strlen(devtype)+1);
active_flows = realloc(active_flows,(ac_fl_size+1)*sizeof(int)); active_flows = realloc(active_flows,(ac_fl_size+1)*sizeof(int));
active_flows[ac_fl_size++] = mapid_result; active_flows[ac_fl_size++] = mapid_result;
} }
dbuf->length = BASIC_SIZE+sizeof(int); else {
dbuf->cmd = ERROR_ACK;
mapi_read_error(&errno, errorstr);
memcpy(dbuf->data, &errno, sizeof(int));
}
}
dbuf->length = BASIC_SIZE+sizeof(int)+strlen(devtype)+1;
break; break;
case CLOSE_FLOW: case CLOSE_FLOW:
fprintf(stdout,"CLOSE_FLOW (%d)\n",dbuf->fd); fprintf(stdout,"CLOSE_FLOW (%d)\n",dbuf->fd);
......
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