diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nSocket/include/dmm_pub_api.h | 6 | ||||
-rw-r--r-- | src/nSocket/include/nstack_dmm_api.h | 2 | ||||
-rw-r--r-- | src/nSocket/nstack/nstack_socket.c | 124 | ||||
-rw-r--r-- | src/nSocket/nstack_rd/nstack_rd_init.c | 1 | ||||
-rw-r--r-- | src/nSocket/nstack_rd/nstack_rd_ip.c | 6 |
5 files changed, 119 insertions, 20 deletions
diff --git a/src/nSocket/include/dmm_pub_api.h b/src/nSocket/include/dmm_pub_api.h new file mode 100644 index 0000000..cfc20af --- /dev/null +++ b/src/nSocket/include/dmm_pub_api.h @@ -0,0 +1,6 @@ + +#ifndef __PUBLIC_DMM_API +#define __PUBLIC_DMM_API +int nstack_run (void *loop); +int nstack_epoll_prewait (); +#endif diff --git a/src/nSocket/include/nstack_dmm_api.h b/src/nSocket/include/nstack_dmm_api.h index ab06650..7c93f86 100644 --- a/src/nSocket/include/nstack_dmm_api.h +++ b/src/nSocket/include/nstack_dmm_api.h @@ -68,6 +68,8 @@ typedef struct __nstack_extern_ops int (*stack_fd_check) (int s, int flag); /*check whether fd belong to stack, if belong, return 1, else return 0 */ int (*stack_alloc_fd) (); /*alloc a fd id for epoll */ int (*peak) (int s); /*used for stack-x , isource maybe no need */ + int (*run) (void *fun); /*used for stack-x , isource maybe no need */ + void (*ep_prewait) (); /*used for stack-x , isource maybe no need */ } nstack_extern_ops; /* diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c index 1b7a416..130d08f 100644 --- a/src/nSocket/nstack/nstack_socket.c +++ b/src/nSocket/nstack/nstack_socket.c @@ -144,12 +144,10 @@ int nstack_socket (int domain, int itype, int protocol) { int ret = -1; //tmp ret of a Single proctol mode. - int rdret = -1; //the final Return judge vale. int modInx; nstack_socket_ops *ops; int ret_fd = -1; int protoFD[NSTACK_MAX_MODULE_NUM]; - nstack_rd_key rdkey = { 0 }; int selectmod = -1; /*check whether module init finish or not */ @@ -187,21 +185,6 @@ nstack_socket (int domain, int itype, int protocol) nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (ret_fd); LOCK_FOR_EP (lock_info); - /*check wether select stack create success, if no return fail */ - rdkey.type = RD_DATA_TYPE_PROTO; - rdkey.proto_type = itype; - rdret = nstack_rd_get_stackid (&rdkey, &selectmod); - if ((0 != rdret) || (selectmod < 0) || (selectmod >= nstack_get_modNum ())) - { - NSSOC_LOGERR ("protocol:%d select stack fail", protocol); - selectmod = -1; - } - else - { - NSSOC_LOGINF ("Create socket of]select modName=%s", - nstack_get_module_name_by_idx (selectmod)); - } - /*create socket by calling select module or all module */ nstack_each_modOps (modInx, ops) { @@ -392,6 +375,26 @@ nstack_bind (int fd, const struct sockaddr *addr, socklen_t addrlen) nstack_get_module_name_by_idx (selectmod)); } + if (selectmod == -1) + { + rdkey.type = RD_DATA_TYPE_PROTO; + rdkey.proto_type = fdInf->type; + retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod < 0) + || (selectmod >= nstack_get_modNum ())) + { + NSSOC_LOGWAR + ("fd Can't select any module for]fd=%d,IP==%s using proto route", + fd, inet_ntoa ((iaddr->sin_addr))); + selectmod = -1; + } + else + { + NSSOC_LOGINF ("Bind socket of]select modName=%s", + nstack_get_module_name_by_idx (selectmod)); + } + } + retval = -1; nstack_each_modInx (modIdx) { @@ -905,6 +908,25 @@ nstack_connect (int fd, const struct sockaddr *addr, socklen_t addrlen) rdkey.type = RD_DATA_TYPE_IP; rdkey.ip_addr = iaddr->sin_addr.s_addr; retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod == -1)) + { + rdkey.type = RD_DATA_TYPE_PROTO; + rdkey.proto_type = fdInf->type; + retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod < 0) + || (selectmod >= nstack_get_modNum ())) + { + NSSOC_LOGINF ("fd=%d addr=%s Select module=%s", + fd, inet_ntoa (iaddr->sin_addr), + nstack_get_module_name_by_idx (selectmod)); + selectmod = -1; + } + else + { + NSSOC_LOGINF ("Connect socket of]select modName=%s", + nstack_get_module_name_by_idx (selectmod)); + } + } if (ns_success == retval && selectmod >= 0) { NSSOC_LOGINF ("fd=%d addr=%s Select module=%s", @@ -1390,6 +1412,25 @@ nstack_sendto (int fd, const void *buf, size_t len, int flags, rdkey.type = RD_DATA_TYPE_IP; rdkey.ip_addr = iaddr->sin_addr.s_addr; retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod == -1)) + { + rdkey.type = RD_DATA_TYPE_PROTO; + rdkey.proto_type = fdInf->type; + retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod < 0) + || (selectmod >= nstack_get_modNum ())) + { + NSSOC_LOGINF ("fd=%d addr=%s Select module=%s", + fd, inet_ntoa (iaddr->sin_addr), + nstack_get_module_name_by_idx (selectmod)); + selectmod = -1; + } + else + { + NSSOC_LOGINF ("sendto socket of]select modName=%s", + nstack_get_module_name_by_idx (selectmod)); + } + } if ((ns_success == retval) && (selectmod >= 0)) { NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s", @@ -1477,6 +1518,25 @@ nstack_sendmsg (int fd, const struct msghdr * msg, int flags) rdkey.type = RD_DATA_TYPE_IP; rdkey.ip_addr = iaddr->sin_addr.s_addr; retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod == -1)) + { + rdkey.type = RD_DATA_TYPE_PROTO; + rdkey.proto_type = fdInf->type; + retval = nstack_rd_get_stackid (&rdkey, &selectmod); + if ((0 != retval) || (selectmod < 0) + || (selectmod >= nstack_get_modNum ())) + { + NSSOC_LOGINF ("fd=%d addr=%s Select module=%s", + fd, inet_ntoa (iaddr->sin_addr), + nstack_get_module_name_by_idx (selectmod)); + selectmod = -1; + } + else + { + NSSOC_LOGINF ("Connect socket of]select modName=%s", + nstack_get_module_name_by_idx (selectmod)); + } + } if (ns_success == retval) { NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s", @@ -2812,3 +2872,33 @@ nstack_fork (void) dmm_write_unlock (get_fork_lock ()); return pid; } + +int +nstack_run (void *loop) +{ + int i; + + nstack_each_modInx (i) + { + if (nstack_extern_deal (i).run) + { + nstack_extern_deal (i).run (loop); + } + } + return 0; +} + +int +nstack_epoll_prewait () +{ + int i; + + nstack_each_modInx (i) + { + if (nstack_extern_deal (i).ep_prewait) + { + nstack_extern_deal (i).ep_prewait (); + } + } + return 0; +} diff --git a/src/nSocket/nstack_rd/nstack_rd_init.c b/src/nSocket/nstack_rd/nstack_rd_init.c index b3d4158..363b4b6 100644 --- a/src/nSocket/nstack_rd/nstack_rd_init.c +++ b/src/nSocket/nstack_rd/nstack_rd_init.c @@ -42,6 +42,7 @@ rd_stack_plane_map g_nstack_plane_info[] = { {"rsocket", "nstack-rsocket", -1}, {{RD_STACKX_NAME}, {RD_STACKX_PLANENAME}, -1}, {"vpp_hoststack", "nstack-vpp", -1}, + {"fstack", "nstack-fstack", -1} }; /* *INDENT-ON* */ diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.c b/src/nSocket/nstack_rd/nstack_rd_ip.c index 5297d4a..f0563a5 100644 --- a/src/nSocket/nstack_rd/nstack_rd_ip.c +++ b/src/nSocket/nstack_rd/nstack_rd_ip.c @@ -66,12 +66,12 @@ nstack_rd_ip_item_insert (nstack_rd_list * hlist, void *rditem) nstack_rd_node *tempdata = NULL; struct hlist_node *tempnode = NULL; struct hlist_node *tem = NULL; - unsigned int ip_addr = 0; - unsigned int ip_masklen = 0; - unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen); unsigned int tempip_addr = 0; unsigned int tempip_masklen = 0; rd_data_item *pitem = (rd_data_item *) rditem; + unsigned int ip_addr = pitem->ipdata.addr; + unsigned int ip_masklen = pitem->ipdata.masklen; + unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen); ip_masklen = pitem->ipdata.masklen; NSSOC_LOGDBG ("stackid:%d, ipaddr:%u.%u.%u.%u masklen:0x%x was inserted", |