summaryrefslogtreecommitdiff
path: root/test/sport_usable.c
blob: 1f9ec6bb17c1e34d45933353442006954045a7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}