[asterisk-commits] branch oej/sipregister r8848 - in
/team/oej/sipregister: channels/ configs/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 31 06:59:20 MST 2006
Author: oej
Date: Sat Jan 28 16:40:53 2006
New Revision: 8848
URL: http://svn.digium.com/view/asterisk?rev=8848&view=rev
Log:
- Change register= line in peer to a yes/no option
- Add link to registry from peer, so we can stop registration when deleting peer
- In the future, we might want to unregister as well
- Todo: Fix deletion of registry when peer is going away
Modified:
team/oej/sipregister/channels/chan_sip.c
team/oej/sipregister/configs/sip.conf.sample
Modified: team/oej/sipregister/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/channels/chan_sip.c?rev=8848&r1=8847&r2=8848&view=diff
==============================================================================
--- team/oej/sipregister/channels/chan_sip.c (original)
+++ team/oej/sipregister/channels/chan_sip.c Sat Jan 28 16:40:53 2006
@@ -586,6 +586,7 @@
#define SIP_PAGE2_DEBUG (3 << 5)
#define SIP_PAGE2_DEBUG_CONFIG (1 << 5)
#define SIP_PAGE2_DEBUG_CONSOLE (1 << 6)
+#define SIP_PAGE2_PEER_REGISTER (1 << 7) /* Whether we register or not */
/* SIP packet flags */
#define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */
@@ -810,6 +811,7 @@
struct sockaddr_in defaddr; /*!< Default IP address, used until registration */
struct ast_ha *ha; /*!< Access control list */
struct ast_variable *chanvars; /*!< Variables to set for channel created by user */
+ struct sip_registry *registry; /*!< If this peer registers with outside service */
int lastmsg;
};
@@ -1669,6 +1671,11 @@
peer->auth = (struct sip_auth *) NULL;
if (peer->dnsmgr)
ast_dnsmgr_release(peer->dnsmgr);
+ if (peer->registry) {
+ /* OEJ - NEeds to do a proper OBJECT dereference and delinking here */
+ //
+ //sip_registry_destroy(peer->registry);
+ }
free(peer);
}
@@ -2112,6 +2119,8 @@
ast_sched_del(sched, reg->expire);
if (reg->timeout > -1)
ast_sched_del(sched, reg->timeout);
+ if (reg->peer)
+ reg->peer->registry = NULL;
ast_string_field_free_all(reg);
regobjs--;
free(reg);
@@ -3300,7 +3309,7 @@
/*! \brief Parse register=> line in sip.conf and add to registry */
static int sip_register(const char *value, int lineno,
- const struct sip_peer *peer)
+ struct sip_peer *peer)
{
struct sip_registry *reg;
char username[256];
@@ -3356,8 +3365,10 @@
ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry entry\n");
return -1;
}
- if (peer)
+ if (peer) {
reg->peer = (struct sip_peer * ) peer; /* Save SIP peer binding for incoming calls */
+ peer->registry = reg;
+ }
if (ast_string_field_init(reg)) {
ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry strings\n");
@@ -12376,7 +12387,10 @@
peer->maxms = 0;
}
} else if (!strcasecmp(v->name, "register")) {
- register_lineno = v->lineno;
+ if (ast_true(v->value)) {
+ ast_set_flag((&peer->flags_page2), SIP_PAGE2_PEER_REGISTER);
+ register_lineno = v->lineno;
+ }
}
/* else if (strcasecmp(v->name,"type"))
* ast_log(LOG_WARNING, "Ignoring %s\n", v->name);
@@ -12399,8 +12413,11 @@
reg_source_db(peer);
ASTOBJ_UNMARK(peer);
ast_free_ha(oldha);
- if (register_lineno > 0)
+
+ /* Start registration if needed */
+ if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_PEER_REGISTER))
sip_register(NULL, register_lineno, peer);
+
return peer;
}
Modified: team/oej/sipregister/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/configs/sip.conf.sample?rev=8848&r1=8847&r2=8848&view=diff
==============================================================================
--- team/oej/sipregister/configs/sip.conf.sample (original)
+++ team/oej/sipregister/configs/sip.conf.sample Sat Jan 28 16:40:53 2006
@@ -308,11 +308,11 @@
;[sip_proxy]
; For incoming calls only. Example: FWD (Free World Dialup)
-; We match on IP address of the proxy for incoming calls
-; since we can not match on username (caller id)
;type=peer
;context=from-fwd
;host=fwd.pulver.com
+;regexten=300 ; Extension to place incoming calls to
+;register=yes ; Enable registration for this service
;[sip_proxy-out]
;type=peer ; we only want to call out, not be called
More information about the asterisk-commits
mailing list