Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.832 diff -u -r1.832 chan_sip.c --- channels/chan_sip.c 31 Aug 2005 19:53:38 -0000 1.832 +++ channels/chan_sip.c 1 Sep 2005 11:47:11 -0000 @@ -1507,16 +1507,16 @@ } /*--- realtime_update_peer: Update peer object in realtime storage ---*/ -static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, int expirey) +static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, int expiry) { char port[10] = ""; char ipaddr[20] = ""; char regseconds[20] = "0"; - if (expirey) { /* Registration */ + if (expiry) { /* Registration */ time_t nowtime; time(&nowtime); - nowtime += expirey; + nowtime += expiry; snprintf(regseconds, sizeof(regseconds), "%ld", nowtime); /* Expiration time */ ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr); snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port)); @@ -9937,7 +9937,7 @@ { int gotdest; int res = 0; - int firststate = 0; + int firststate = -2; if (p->initreq.headers) { /* We already have a dialog */ @@ -10056,13 +10056,6 @@ } if (p->subscribed != NONE) p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p); - firststate = ast_extension_state(NULL, p->context, p->exten); - if (firststate < 0) { - ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context); - transmit_response(p, "404 Not found", req); - ast_set_flag(p, SIP_NEEDDESTROY); - return 0; - } } } @@ -10074,8 +10067,7 @@ ast_set_flag(p, SIP_NEEDDESTROY); return 0; } - /* TODO: Do we need this any longer? And what exactly to remove? */ - /* The next line can be removed if the SNOM200 Expires bug is fixed */ + /* The next 4 lines can be removed if the SNOM Expires bug is fixed */ if (p->subscribed == DIALOG_INFO_XML) { if (p->expiry > max_expiry) p->expiry = max_expiry; @@ -10086,8 +10078,16 @@ if (p->autokillid > -1) sip_cancel_destroy(p); /* Remove subscription expiry for renewals */ sip_scheddestroy(p, (p->expiry + 10) * 1000); /* Set timer for destruction of call at expiration */ - transmit_state_notify(p, firststate, 1, 1); /* Send first notification */ - append_history(p, "Subscribestatus", "active"); + + if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) { + ast_log(LOG_ERROR, "Got SUBSCRIBE for extensions without hint. Please add hint to %s in context %s\n", p->exten, p->context); + transmit_response(p, "404 Not found", req); + ast_set_flag(p, SIP_NEEDDESTROY); + return 0; + } else { + transmit_state_notify(p, firststate, 1, 1); /* Send first notification */ + append_history(p, "Subscribestatus", (char (*))ast_extension_state2str(firststate)); + } } return 1; } Index: configs/sip.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/sip.conf.sample,v retrieving revision 1.67 diff -u -r1.67 sip.conf.sample --- configs/sip.conf.sample 30 Aug 2005 21:26:33 -0000 1.67 +++ configs/sip.conf.sample 1 Sep 2005 11:47:11 -0000 @@ -48,6 +48,9 @@ ;maxexpirey=3600 ; Max length of incoming registration we allow ;defaultexpirey=120 ; Default length of incoming/outoing registration ;notifymimetype=text/plain ; Allow overriding of mime type in MWI NOTIFY +;notifyringing=no ; Sent ringing (yes) or inuse (no) as state in + ; NOTIFY messages when observed extension is + ; in state RINGING_AND_INUSE (defaults to "yes") ;checkmwi=10 ; Default time between mailbox checks for peers ;vmexten=voicemail ; dialplan extension to reach mailbox sets the ; Message-Account in the MWI notify message @@ -213,6 +216,7 @@ ; User config options: Peer configuration: ; -------------------- ------------------- ; context context +; subscribecontext subscribecontext ; permit permit ; deny deny ; secret secret @@ -232,10 +236,10 @@ ; useclientcode useclientcode ; accountcode accountcode ; setvar setvar -; callerid callerid -; amaflags amaflags -; call-limit call-limit -; restrictcid restrictcid +; callerid callerid +; amaflags amaflags +; call-limit call-limit +; restrictcid restrictcid ; mailbox ; username ; template @@ -323,6 +327,7 @@ ;[snom] ;type=friend ; Friends place calls and receive calls ;context=from-sip ; Context for incoming calls from this user +;subscribecontext=mygroup ; context for subscriptions (hints) ;secret=blah ;language=de ; Use German prompts for this user ;host=dynamic ; This peer register with us Index: include/asterisk/pbx.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/pbx.h,v retrieving revision 1.52 diff -u -r1.52 pbx.h --- include/asterisk/pbx.h 30 Aug 2005 18:32:09 -0000 1.52 +++ include/asterisk/pbx.h 1 Sep 2005 11:47:11 -0000 @@ -45,22 +45,14 @@ /*! Extension states */ enum ast_extension_states { - /*! Extension removed */ - AST_EXTENSION_REMOVED = -2, - /*! Extension hint removed */ - AST_EXTENSION_DEACTIVATED = -1, - /*! No device INUSE or BUSY */ - AST_EXTENSION_NOT_INUSE = 0, - /*! One or more devices INUSE */ - AST_EXTENSION_INUSE = 1 << 0, - /*! All devices BUSY */ - AST_EXTENSION_BUSY = 1 << 1, - /*! All devices UNAVAILABLE/UNREGISTERED */ - AST_EXTENSION_UNAVAILABLE = 1 << 2, - /*! All devices RINGING */ - AST_EXTENSION_RINGING = 1 << 3, + AST_EXTENSION_REMOVED = -2, /*! Extension removed */ + AST_EXTENSION_DEACTIVATED = -1, /*! Extension hint removed */ + AST_EXTENSION_NOT_INUSE = 0, /*! No device INUSE or BUSY */ + AST_EXTENSION_INUSE = 1 << 0, /*! One or more devices INUSE */ + AST_EXTENSION_BUSY = 1 << 1, /*! All devices BUSY */ + AST_EXTENSION_UNAVAILABLE = 1 << 2, /*! All devices UNAVAILABLE/UNREGISTERED */ + AST_EXTENSION_RINGING = 1 << 3, /*! All devices RINGING */ }; - static const struct cfextension_states { int extension_state;