-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsession.c
52 lines (43 loc) · 902 Bytes
/
session.c
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
46
47
48
49
50
51
52
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <syslog.h>
#include "uthash.h"
#include "session.h"
#include "version.h"
#include "debug.h"
#include "frame.h"
uint32_t *sid_index = NULL;
// need free
uint32_t *init_sid_index()
{
if (NULL == sid_index) {
sid_index = (uint32_t *) calloc(1, sizeof(uint32_t));
if (NULL == sid_index)
return sid_index;
#ifdef CLIENT_V
*sid_index = 1;
#elif SERVER
*sid_index = 0;
#endif
}
*sid_index += 2; // xfrp client session id start from 3
return sid_index;
}
uint32_t get_current_sid_index()
{
if (NULL == sid_index) {
return *init_sid_index();
}
return *sid_index;
}
uint32_t new_sid()
{
if (NULL == sid_index) {
init_sid_index();
return get_current_sid_index();
}
*sid_index += 2;
return *sid_index;
}