summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/baresip.h3
-rw-r--r--src/account.c47
-rw-r--r--test/account.c3
3 files changed, 49 insertions, 4 deletions
diff --git a/include/baresip.h b/include/baresip.h
index 8514f21..08ea908 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -59,6 +59,9 @@ uint32_t account_ptime(const struct account *acc);
enum answermode account_answermode(const struct account *acc);
const char *account_auth_user(const struct account *acc);
const char *account_outbound(const struct account *acc, unsigned ix);
+const char *account_stun_user(const struct account *acc);
+const char *account_stun_pass(const struct account *acc);
+const char *account_stun_host(const struct account *acc);
/*
diff --git a/src/account.c b/src/account.c
index 40875f5..0e84eef 100644
--- a/src/account.c
+++ b/src/account.c
@@ -383,11 +383,11 @@ int account_alloc(struct account **accp, const char *sipaddr)
goto out;
}
- if (acc->mnatid) {
- err = stunsrv_decode(acc, &acc->laddr);
- if (err)
- goto out;
+ err = stunsrv_decode(acc, &acc->laddr);
+ if (err)
+ goto out;
+ if (acc->mnatid) {
acc->mnat = mnat_find(baresip_mnatl(), acc->mnatid);
if (!acc->mnat) {
warning("account: medianat not found: `%s'\n",
@@ -543,6 +543,45 @@ uint32_t account_ptime(const struct account *acc)
}
+/**
+ * Get the STUN username of an account
+ *
+ * @param acc User-Agent account
+ *
+ * @return STUN username
+ */
+const char *account_stun_user(const struct account *acc)
+{
+ return acc ? acc->stun_user : NULL;
+}
+
+
+/**
+ * Get the STUN password of an account
+ *
+ * @param acc User-Agent account
+ *
+ * @return STUN password
+ */
+const char *account_stun_pass(const struct account *acc)
+{
+ return acc ? acc->stun_pass : NULL;
+}
+
+
+/**
+ * Get the STUN hostname of an account
+ *
+ * @param acc User-Agent account
+ *
+ * @return STUN hostname
+ */
+const char *account_stun_host(const struct account *acc)
+{
+ return acc ? acc->stun_host : NULL;
+}
+
+
static const char *answermode_str(enum answermode mode)
{
switch (mode) {
diff --git a/test/account.c b/test/account.c
index 6b37a6c..3ba2f53 100644
--- a/test/account.c
+++ b/test/account.c
@@ -57,6 +57,9 @@ int test_account(void)
ASSERT_EQ(10, account_ptime(acc));
ASSERT_EQ(600, account_regint(acc));
ASSERT_EQ(700, account_pubint(acc));
+ ASSERT_STREQ("stun_user", account_stun_user(acc));
+ ASSERT_STREQ("stun_pass", account_stun_pass(acc));
+ ASSERT_STREQ("stunserver.org", account_stun_host(acc));
out:
mem_deref(acc);