summaryrefslogtreecommitdiff
path: root/test/sip/sipsrv.h
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-04-03 17:35:05 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-04-03 17:35:05 +0200
commit31baf6937aee6f449a6675e102d6f0831bfb1fbe (patch)
treeb31e792b04b746497cb42df90dfb07ce8d0a7035 /test/sip/sipsrv.h
parent059b6a9f597419adc331ca7e1e2b40b090d907a1 (diff)
test: added test-case for authenticated register
Diffstat (limited to 'test/sip/sipsrv.h')
-rw-r--r--test/sip/sipsrv.h121
1 files changed, 121 insertions, 0 deletions
diff --git a/test/sip/sipsrv.h b/test/sip/sipsrv.h
new file mode 100644
index 0000000..4690ffe
--- /dev/null
+++ b/test/sip/sipsrv.h
@@ -0,0 +1,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);