Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- asterisk-1.6.2.10/channels/chan_sip.c.orig 2010-07-24 19:24:31.000000000 -0400
- +++ asterisk-1.6.2.10/channels/chan_sip.c 2010-07-24 19:24:20.000000000 -0400
- @@ -331,6 +331,25 @@
- <para>Always returns <literal>0</literal>.</para>
- </description>
- </application>
- + <application name="SIPCalledRPID" language="en_US">
- + <synopsis>
- + Set the RPID header for Called Party Identification
- + </synopsis>
- + <syntax>
- + <parameter name="Name" required="true" />
- + <parameter name="Number" required="true" />
- + </syntax>
- + <description>
- + <para>Sets the Remote-Party-ID header information to be sent to a call
- + originator on further progress through this extension. Many SIP
- + phones use this header to display the name and number of the party
- + which has been called from the telephone.</para>
- + <para>This progress may be updated throughout the call progress whenever
- + Asterisk sends a new 180 Ringing, 183 Call Progress, or 200 OK response
- + to the calling channel.</para>
- + <para>Always returns <literal>0</literal>.</para>
- + </description>
- + </application>
- <function name="SIP_HEADER" language="en_US">
- <synopsis>
- Gets the specified SIP header.
- @@ -1552,6 +1571,7 @@
- int method; /*!< SIP method that opened this dialog */
- AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(callid); /*!< Global CallID */
- + AST_STRING_FIELD(calledid); /*!< Called Party RPID Header String */
- AST_STRING_FIELD(randdata); /*!< Random data */
- AST_STRING_FIELD(accountcode); /*!< Account code */
- AST_STRING_FIELD(realm); /*!< Authorization realm */
- @@ -2279,6 +2299,7 @@
- static int transmit_response_using_temp(ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg);
- static int transmit_response(struct sip_pvt *p, const char *msg, const struct sip_request *req);
- static int transmit_response_reliable(struct sip_pvt *p, const char *msg, const struct sip_request *req);
- +static int transmit_response_with_calledrpid(struct sip_pvt *p, char *msg, struct sip_request *req);
- static int transmit_response_with_date(struct sip_pvt *p, const char *msg, const struct sip_request *req);
- static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable, int oldsdp);
- static int transmit_response_with_unsupported(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *unsupported);
- @@ -6531,8 +6552,12 @@
- p->invitestate = INV_EARLY_MEDIA;
- if (!ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) ||
- (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) {
- - /* Send 180 ringing if out-of-band seems reasonable */
- - transmit_provisional_response(p, "180 Ringing", &p->initreq, 0);
- + /* Send 180 ringing if out-of-band seems reasonable */
- + if (!ast_strlen_zero(p->calledid)) {
- + transmit_response_with_calledrpid(p, "180 Ringing", &p->initreq);
- + } else {
- + transmit_provisional_response(p, "180 Ringing", &p->initreq, 0);
- + }
- ast_set_flag(&p->flags[0], SIP_RINGING);
- if (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) != SIP_PROG_INBAND_YES)
- break;
- @@ -9795,6 +9820,15 @@
- add_header(req, "Date", tmpdat);
- }
- +/*! \brief transmit_response_with_calledrpid: Transmit response, no retransmits */
- +static int transmit_response_with_calledrpid(struct sip_pvt *p, char *msg, struct sip_request *req)
- +{
- + struct sip_request resp;
- + respprep(&resp, p, msg, req);
- + add_header(&resp, "Remote-Party-ID", p->calledid);
- + return send_response(p, &resp, XMIT_UNRELIABLE, 0);
- +}
- +
- /*! \brief Append date and content length before transmitting response */
- static int transmit_response_with_date(struct sip_pvt *p, const char *msg, const struct sip_request *req)
- {
- @@ -10498,6 +10532,9 @@
- return -1;
- }
- respprep(&resp, p, msg, req);
- + if (!ast_strlen_zero(p->calledid)) {
- + add_header(&resp, "Remote-Party-ID", p->calledid);
- + }
- if (p->rtp) {
- if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- ast_debug(1, "Setting framing from config on incoming call\n");
- @@ -25532,6 +25569,7 @@
- static char *app_dtmfmode = "SIPDtmfMode";
- static char *app_sipaddheader = "SIPAddHeader";
- static char *app_sipremoveheader = "SIPRemoveHeader";
- +static char *app_sipcalledrpid = "SIPCalledRPID";
- /*! \brief Set the DTMFmode for an outbound SIP call (application) */
- static int sip_dtmfmode(struct ast_channel *chan, void *data)
- @@ -25662,6 +25700,46 @@
- return 0;
- }
- +/*! \brief Set the value of the RPID header for called party identification */
- +static int sip_calledrpid(struct ast_channel *chan, void *data)
- +{
- + struct sip_pvt *p;
- + AST_DECLARE_APP_ARGS(args,
- + AST_APP_ARG(name);
- + AST_APP_ARG(number);
- + );
- + const char *fromdomain;
- + char rpid[256];
- +
- + if (ast_strlen_zero(data)) {
- + ast_log(LOG_WARNING, "This application requires the arguments: Name, Number\n");
- + return 0;
- + }
- +
- + AST_STANDARD_APP_ARGS(args, data);
- +
- + if (ast_strlen_zero(args.name) || ast_strlen_zero(args.number)) {
- + ast_log(LOG_WARNING, "One or more arguments are invalid: Name, Number\n");
- + return 0;
- + }
- +
- + ast_channel_lock(chan);
- +
- + if (chan->tech != &sip_tech) {
- + ast_log(LOG_WARNING, "This application is only useful for calls originated from SIP UA's\n");
- + ast_channel_unlock(chan);
- + return 0;
- + }
- +
- + p = chan->tech_pvt;
- + fromdomain = S_OR(p->fromdomain, ast_inet_ntoa(p->ourip.sin_addr));
- + sprintf(rpid, "\"%s\" <sip:%s@%s>;party=called;id-type=subscriber;screen=yes;privacy=off", args.name, args.number, fromdomain);
- + ast_string_field_set(p, calledid, rpid);
- +
- + ast_channel_unlock(chan);
- + return 0;
- +}
- +
- /*! \brief Transfer call before connect with a 302 redirect
- \note Called by the transfer() dialplan application through the sip_transfer()
- pbx interface function if the call is in ringing state
- @@ -25947,6 +26025,7 @@
- ast_register_application_xml(app_dtmfmode, sip_dtmfmode);
- ast_register_application_xml(app_sipaddheader, sip_addheader);
- ast_register_application_xml(app_sipremoveheader, sip_removeheader);
- + ast_register_application_xml(app_sipcalledrpid, sip_calledrpid);
- /* Register dialplan functions */
- ast_custom_function_register(&sip_header_function);
- @@ -26010,6 +26089,7 @@
- ast_unregister_application(app_dtmfmode);
- ast_unregister_application(app_sipaddheader);
- ast_unregister_application(app_sipremoveheader);
- + ast_unregister_application(app_sipcalledrpid);
- /* Unregister CLI commands */
- ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
Advertisement
Add Comment
Please, Sign In to add comment