summaryrefslogtreecommitdiff
path: root/test/sip/sipsrv.h
blob: 4690ffe70aa7815bd19cd9ec837028738ab37c38 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
 * @file mock/sipsrv.h Mock SIP server -- interface
 *
 * Copyright (C) 2010 - 2016 Creytiv.com
 */


struct auth;


/*
 * SIP Server
 */

struct sip_server {
	struct sip *sip;
	struct sip_lsnr *lsnr;
	bool auth_enabled;
	bool terminate;

	unsigned n_register_req;
	enum sip_transp tp_last;

	uint64_t secret;
	struct hash *ht_dom;
	struct hash *ht_aor;
};

int sip_server_alloc(struct sip_server **srvp);
int sip_server_uri(struct sip_server *srv, char *uri, size_t sz,
		   enum sip_transp tp);


/*
 * AoR
 */

struct aor {
	struct le he;
	struct list locl;
	char *uri;
};

int aor_create(struct sip_server *srv, struct aor **aorp,
	       const struct uri *uri);
int aor_find(struct sip_server *srv, struct aor **aorp,
	     const struct uri *uri);


/*
 * Auth
 */

struct auth {
	const struct sip_server *srv;
	char realm[256];
	bool stale;
};

int auth_print(struct re_printf *pf, const struct auth *auth);
int auth_chk_nonce(struct sip_server *srv,
		   const struct pl *nonce, uint32_t expires);
int auth_set_realm(struct auth *auth, const char *realm);


/*
 * Domain
 */

struct domain {
	struct le he;
	struct hash *ht_usr;
	char *name;
};


int domain_add(struct sip_server *srv, const char *name);
int domain_find(struct sip_server *srv, const struct uri *uri);
int domain_auth(struct sip_server *srv,
		const struct uri *uri, bool user_match,
		const struct sip_msg *msg, enum sip_hdrid hdrid,
		struct auth *auth);
struct domain *domain_lookup(struct sip_server *srv, const char *name);


/*
 * Location
 */

struct location {
	struct le le;
	struct sa src;
	struct uri duri;
	char *uri;
	char *callid;
	struct loctmp *tmp;
	uint64_t expires;
	uint32_t cseq;
	double q;
	bool rm;
};

int  location_update(struct list *locl, const struct sip_msg *msg,
		     const struct sip_addr *contact, uint32_t expires);
void location_commit(struct list *locl);
void location_rollback(struct list *locl);


/*
 * User
 */

struct user {
	struct le he;
	uint8_t ha1[MD5_SIZE];
	char *name;
};

int user_add(struct hash *ht, const char *username, const char *password,
	     const char *realm);
struct user *user_find(struct hash *ht, const struct pl *name);