diff options
Diffstat (limited to 'test/sport_usable.c')
| -rw-r--r-- | test/sport_usable.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/sport_usable.c b/test/sport_usable.c new file mode 100644 index 0000000..1f9ec6b --- /dev/null +++ b/test/sport_usable.c @@ -0,0 +1,45 @@ +#include <stdio.h> + +#define TOT_ACC_GW_NUM (10) +#define THIS_ACC_GW_ID (5) +#define THREAD_NUM (8) + +/* for test */ +static int flwd_act_ip_get_usable_sport(int tid, unsigned short *begin_port, + unsigned short *usable_count) +{ + unsigned short this_gateway_begin_port; + unsigned short this_thread_usable_tot_count; + unsigned short this_gateway_usable_tot_count; + + this_gateway_usable_tot_count = + 64511 / TOT_ACC_GW_NUM; + + this_gateway_begin_port = + this_gateway_usable_tot_count * (THIS_ACC_GW_ID-1) + 1025; + + this_thread_usable_tot_count = + this_gateway_usable_tot_count / THREAD_NUM; + + *usable_count = + this_gateway_usable_tot_count / THREAD_NUM; + + *begin_port = this_gateway_begin_port + (*usable_count) * tid; + + return 0; +} + +int main(void) +{ + int i; + unsigned short begin_port; + unsigned short usable_count; + + for(i =0; i < THREAD_NUM; i++){ + flwd_act_ip_get_usable_sport(i, &begin_port, &usable_count); + printf("thread:%d, begin:%u, count:%u\n", i, begin_port, usable_count); + } + return 0; +} + + |
