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 {
typedef struct host_flow {
struct host *rhost;
char* dev;
char *devtype;
int scope_fd;
int fd; //fd of flow in the mapid of host
int id;
......
......@@ -499,6 +499,7 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
flist_destroy(hflow->functions);
free(hflow->functions);
free(hflow->dev);
free(hflow->devtype);
free(hflow->dbuf);
if (hflow->pkt!=NULL) free(hflow->pkt);
......@@ -545,6 +546,16 @@ static void delete_remote_flow(remote_flowdescr_t* rflow)
}
#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)
//Create new flow
//dev=device that should be used
......@@ -560,7 +571,7 @@ int mapi_create_flow(const char *dev)
remote_flowdescr_t *rflow;
char *hostname=NULL, *s=NULL, *k=NULL;
struct host *h=NULL;
host_flow* hflow;
host_flow* hflow = NULL;
char *devp;
flist_node_t* fnode;
unsigned int idgen=0;
......@@ -738,6 +749,7 @@ int mapi_create_flow(const char *dev)
hflow=(host_flow*)fnode->data;
if (hflow->dbuf->cmd == CREATE_FLOW_ACK) {
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_append(hflow->rhost->flows, hflow->fd, hflow);
}
......@@ -1521,8 +1533,7 @@ int mapi_apply_function(int fd, const char* funct, ...)
#ifdef DIMAPI
}
if (is_remote) fdef=mapilh_get_function_def(funct,"1.3");
else
if (!is_remote) {
#endif
//Get information about function
......@@ -1533,6 +1544,9 @@ int mapi_apply_function(int fd, const char* funct, ...)
local_err = MAPI_FUNCTION_NOT_FOUND;
return -1;
}
#ifdef DIMAPI
}
#endif
#ifdef DIMAPI
if(is_remote){//flow is remote
......@@ -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++) {
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->fd=hflow->fd;
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
#ifdef DIMAPI
}
if (is_remote) fdef=mapilh_get_function_def(funct,"1.3");
else
if (!is_remote) {
#endif
//Get information about function
......@@ -4360,12 +4381,24 @@ int mapi_apply_function_array(int fd, const char* funct, char** args, unsigned i
local_err = MAPI_FUNCTION_NOT_FOUND;
return -1;
}
#ifdef DIMAPI
}
#endif
#ifdef DIMAPI
if(is_remote){//flow is remote
for (fnode=flist_head(rflow->host_flowlist), i=1; fnode!=NULL; fnode=flist_next(fnode), i++) {
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->fd=hflow->fd;
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
//mapi 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
......@@ -326,6 +326,7 @@ void *handle_request(void *arg) {
mapi_function_info_t funct_info;
mapi_flow_info_t flow_info;
mapi_device_info_t device_info;
char *devtype = NULL;
#ifdef RECONNECT
int ignore_flag = 0;
#endif
......@@ -435,12 +436,21 @@ void *handle_request(void *arg) {
memcpy(dbuf->data, &errno, sizeof(int));
}
else {
devtype = mapi_get_devtype_of_flow(mapid_result);
if(devtype != NULL) {
dbuf->cmd = CREATE_FLOW_ACK;
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[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;
case CLOSE_FLOW:
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