From libpri-commits at lists.digium.com Thu Jul 2 12:13:19 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 02 Jul 2009 17:13:19 -0000 Subject: [libpri-commits] tilghman: branch group/issue10217 r934 - /team/group/issue10217/ Message-ID: Author: tilghman Date: Thu Jul 2 12:13:15 2009 New Revision: 934 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=934 Log: Merged revisions 907,914,919-921 via svnmerge from https://origsvn.digium.com/svn/libpri/branches/1.4 ........ r907 | seanbright | 2009-06-25 13:53:38 -0500 (Thu, 25 Jun 2009) | 17 lines Add support for sending Reverse Charging Indication IE on ISDN PRI. Add the ability to transmit a Reverse Charging Indication IE during a SETUP message. In passing, re-work some of the receive logic to be forwards compatible with new RCI values that may be added in the future. Also removed the PRI_REVERSECHARGE_SUPPORT define that I added on the last commit since we can just check for PRI_REVERSECHARGE_NONE or _REQUESTED on the Asterisk side to determine support for this. Special thanks to rmudgett who could have written this in half the time he spent reviewing it, but instead talked me through it. Much appreciated! (issue #13760) Reported by: mrgabu Review: https://reviewboard.asterisk.org/r/292/ ........ r914 | rmudgett | 2009-06-26 13:37:15 -0500 (Fri, 26 Jun 2009) | 1 line Added printf format attribute to pri_message() and pri_error() and fixed some detected errors. ........ r919 | rmudgett | 2009-06-26 14:41:56 -0500 (Fri, 26 Jun 2009) | 1 line Doxygenify the timer comments. ........ r920 | rmudgett | 2009-06-26 14:43:13 -0500 (Fri, 26 Jun 2009) | 1 line Eliminate local version of PRI_MAX_TIMERS. ........ r921 | rmudgett | 2009-06-26 14:50:19 -0500 (Fri, 26 Jun 2009) | 6 lines Fix potential buffer overflow in pri_dump_info_str(). * Created pri_snprintf() to prevent buffer overflow in pri_dump_info_str(). * Extracted timer name to timer number table from pri_timer2idx() so pri_dump_info_str() can use it. ........ Modified: team/group/issue10217/ (props changed) team/group/issue10217/libpri.h team/group/issue10217/pri.c team/group/issue10217/pri_internal.h team/group/issue10217/q931.c Propchange: team/group/issue10217/ ------------------------------------------------------------------------------ automerge = * Propchange: team/group/issue10217/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Thu Jul 2 12:13:15 2009 @@ -1,1 +1,1 @@ -/branches/1.4:1-901 +/branches/1.4:1-933 Modified: team/group/issue10217/libpri.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue10217/libpri.h?view=diff&rev=934&r1=933&r2=934 ============================================================================== --- team/group/issue10217/libpri.h (original) +++ team/group/issue10217/libpri.h Thu Jul 2 12:13:15 2009 @@ -182,6 +182,10 @@ #define PRES_NUMBER_NOT_AVAILABLE \ (PRI_PRES_UNAVAILABLE | PRI_PRES_NETWORK_NUMBER) + +/* Reverse Charging Indication */ +#define PRI_REVERSECHARGE_NONE -1 +#define PRI_REVERSECHARGE_REQUESTED 1 /* Causes for disconnection */ #define PRI_CAUSE_UNALLOCATED 1 @@ -770,6 +774,7 @@ #define PRI_USER_USER_TX /* Set the user user field. Warning! don't send binary data accross this field */ void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars); +void pri_sr_set_reversecharge(struct pri_sr *sr, int requested); void pri_call_set_useruser(q931_call *sr, const char *userchars); @@ -836,7 +841,6 @@ #define PRI_REDIRECTING_REASON #define PRI_AOC_UNITS #define PRI_ANI -#define PRI_REVERSECHARGE_SUPPORT /* Send notification */ int pri_notify(struct pri *pri, q931_call *c, int channel, int info); @@ -849,32 +853,32 @@ int pri_get_timer(struct pri *pri, int timer); int pri_timer2idx(const char *timer_name); -/* New configurable timers and counters must be added to the end of the list */ +/*! New configurable timers and counters must be added to the end of the list */ enum PRI_TIMERS_AND_COUNTERS { - PRI_TIMER_N200, /* Maximum numer of Q.921 retransmissions */ - PRI_TIMER_N201, /* Maximum numer of octets in an information field */ - PRI_TIMER_N202, /* Maximum numer of transmissions of the TEI identity request message */ - PRI_TIMER_K, /* Maximum number of outstanding I-frames */ - - PRI_TIMER_T200, /* Time between SABME's */ - PRI_TIMER_T201, /* Minimum time between retransmissions of the TEI Identity check messages */ - PRI_TIMER_T202, /* Minimum time between transmission of TEI Identity request messages */ - PRI_TIMER_T203, /* Maximum time without exchanging packets */ + PRI_TIMER_N200, /*!< Maximum numer of Q.921 retransmissions */ + PRI_TIMER_N201, /*!< Maximum numer of octets in an information field */ + PRI_TIMER_N202, /*!< Maximum numer of transmissions of the TEI identity request message */ + PRI_TIMER_K, /*!< Maximum number of outstanding I-frames */ + + PRI_TIMER_T200, /*!< Time between SABME's */ + PRI_TIMER_T201, /*!< Minimum time between retransmissions of the TEI Identity check messages */ + PRI_TIMER_T202, /*!< Minimum time between transmission of TEI Identity request messages */ + PRI_TIMER_T203, /*!< Maximum time without exchanging packets */ PRI_TIMER_T300, - PRI_TIMER_T301, /* Maximum time to respond to an ALERT */ + PRI_TIMER_T301, /*!< Maximum time to respond to an ALERT */ PRI_TIMER_T302, - PRI_TIMER_T303, /* Maximum time to wait after sending a SETUP without a response */ + PRI_TIMER_T303, /*!< Maximum time to wait after sending a SETUP without a response */ PRI_TIMER_T304, - PRI_TIMER_T305, /* Wait for DISCONNECT acknowledge */ + PRI_TIMER_T305, /*!< Wait for DISCONNECT acknowledge */ PRI_TIMER_T306, PRI_TIMER_T307, - PRI_TIMER_T308, /* Wait for RELEASE acknowledge */ - PRI_TIMER_T309, /* Time active calls can tollerate data link layer being down before clearing. */ - PRI_TIMER_T310, /* Maximum time between receiving a CALL_PROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */ - PRI_TIMER_T313, /* Wait for CONNECT acknowledge, CPE side only */ + PRI_TIMER_T308, /*!< Wait for RELEASE acknowledge */ + PRI_TIMER_T309, /*!< Time active calls can tollerate data link layer being down before clearing. */ + PRI_TIMER_T310, /*!< Maximum time between receiving a CALL_PROCEEDING and receiving a ALERT/CONNECT/DISCONNECT/PROGRESS */ + PRI_TIMER_T313, /*!< Wait for CONNECT acknowledge, CPE side only */ PRI_TIMER_T314, - PRI_TIMER_T316, /* Maximum time between transmitting a RESTART and receiving a RESTART ACK */ + PRI_TIMER_T316, /*!< Maximum time between transmitting a RESTART and receiving a RESTART ACK */ PRI_TIMER_T317, PRI_TIMER_T318, PRI_TIMER_T319, @@ -882,8 +886,8 @@ PRI_TIMER_T321, PRI_TIMER_T322, - PRI_TIMER_TM20, /* Maximum time awaiting XID response */ - PRI_TIMER_NM20, /* Number of XID retransmits */ + PRI_TIMER_TM20, /*!< Maximum time awaiting XID response */ + PRI_TIMER_NM20, /*!< Number of XID retransmits */ /* Must be last in the enum list */ _PRI_MAX_TIMERS, Modified: team/group/issue10217/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue10217/pri.c?view=diff&rev=934&r1=933&r2=934 ============================================================================== --- team/group/issue10217/pri.c (original) +++ team/group/issue10217/pri.c Thu Jul 2 12:13:15 2009 @@ -42,6 +42,52 @@ #include "pri_facility.h" #include "pri_q921.h" #include "pri_q931.h" + +#define PRI_BIT(a_bit) (1UL << (a_bit)) +#define PRI_ALL_SWITCHES 0xFFFFFFFF + +struct pri_timer_table { + const char *name; + enum PRI_TIMERS_AND_COUNTERS number; + unsigned long used_by; +}; + +/*! + * \note Sort the timer table entries in the order of the timer name so + * pri_dump_info_str() can display them in a consitent order. + */ +static const struct pri_timer_table pri_timer[] = { +/* *INDENT-OFF* */ + /* timer name timer number used by switches */ + { "N200", PRI_TIMER_N200, PRI_ALL_SWITCHES }, + { "N201", PRI_TIMER_N201, PRI_ALL_SWITCHES }, + { "N202", PRI_TIMER_N202, PRI_ALL_SWITCHES }, + { "K", PRI_TIMER_K, PRI_ALL_SWITCHES }, + { "T200", PRI_TIMER_T200, PRI_ALL_SWITCHES }, + { "T202", PRI_TIMER_T202, PRI_ALL_SWITCHES }, + { "T203", PRI_TIMER_T203, PRI_ALL_SWITCHES }, + { "T300", PRI_TIMER_T300, PRI_ALL_SWITCHES }, + { "T301", PRI_TIMER_T301, PRI_ALL_SWITCHES }, + { "T302", PRI_TIMER_T302, PRI_ALL_SWITCHES }, + { "T303", PRI_TIMER_T303, PRI_ALL_SWITCHES }, + { "T304", PRI_TIMER_T304, PRI_ALL_SWITCHES }, + { "T305", PRI_TIMER_T305, PRI_ALL_SWITCHES }, + { "T306", PRI_TIMER_T306, PRI_ALL_SWITCHES }, + { "T307", PRI_TIMER_T307, PRI_ALL_SWITCHES }, + { "T308", PRI_TIMER_T308, PRI_ALL_SWITCHES }, + { "T309", PRI_TIMER_T309, PRI_ALL_SWITCHES }, + { "T310", PRI_TIMER_T310, PRI_ALL_SWITCHES }, + { "T313", PRI_TIMER_T313, PRI_ALL_SWITCHES }, + { "T314", PRI_TIMER_T314, PRI_ALL_SWITCHES }, + { "T316", PRI_TIMER_T316, PRI_ALL_SWITCHES }, + { "T317", PRI_TIMER_T317, PRI_ALL_SWITCHES }, + { "T318", PRI_TIMER_T318, PRI_ALL_SWITCHES }, + { "T319", PRI_TIMER_T319, PRI_ALL_SWITCHES }, + { "T320", PRI_TIMER_T320, PRI_ALL_SWITCHES }, + { "T321", PRI_TIMER_T321, PRI_ALL_SWITCHES }, + { "T322", PRI_TIMER_T322, PRI_ALL_SWITCHES }, +/* *INDENT-ON* */ +}; char *pri_node2str(int node) { @@ -93,17 +139,17 @@ } /* Set timer values to standard defaults. Time is in ms. */ - ctrl->timers[PRI_TIMER_N200] = 3; /* Max numer of Q.921 retransmissions */ - ctrl->timers[PRI_TIMER_N202] = 3; /* Max numer of transmissions of the TEI identity request message */ - ctrl->timers[PRI_TIMER_K] = 7; /* Max number of outstanding I-frames */ - ctrl->timers[PRI_TIMER_T200] = 1000; /* Time between SABME's */ - ctrl->timers[PRI_TIMER_T202] = 10000; /* Min time between transmission of TEI Identity request messages */ - ctrl->timers[PRI_TIMER_T203] = 10000; /* Max time without exchanging packets */ - ctrl->timers[PRI_TIMER_T305] = 30000; /* Wait for DISCONNECT acknowledge */ - ctrl->timers[PRI_TIMER_T308] = 4000; /* Wait for RELEASE acknowledge */ - ctrl->timers[PRI_TIMER_T313] = 4000; /* Wait for CONNECT acknowledge, CPE side only */ - ctrl->timers[PRI_TIMER_TM20] = 2500; /* Max time awaiting XID response - Q.921 Appendix IV */ - ctrl->timers[PRI_TIMER_NM20] = 3; /* Number of XID retransmits - Q.921 Appendix IV */ + ctrl->timers[PRI_TIMER_N200] = 3; /* Max numer of Q.921 retransmissions */ + ctrl->timers[PRI_TIMER_N202] = 3; /* Max numer of transmissions of the TEI identity request message */ + ctrl->timers[PRI_TIMER_K] = 7; /* Max number of outstanding I-frames */ + ctrl->timers[PRI_TIMER_T200] = 1000; /* Time between SABME's */ + ctrl->timers[PRI_TIMER_T202] = 10 * 1000; /* Min time between transmission of TEI Identity request messages */ + ctrl->timers[PRI_TIMER_T203] = 10 * 1000; /* Max time without exchanging packets */ + ctrl->timers[PRI_TIMER_T305] = 30 * 1000; /* Wait for DISCONNECT acknowledge */ + ctrl->timers[PRI_TIMER_T308] = 4 * 1000; /* Wait for RELEASE acknowledge */ + ctrl->timers[PRI_TIMER_T313] = 4 * 1000; /* Wait for CONNECT acknowledge, CPE side only */ + ctrl->timers[PRI_TIMER_TM20] = 2500; /* Max time awaiting XID response - Q.921 Appendix IV */ + ctrl->timers[PRI_TIMER_NM20] = 3; /* Number of XID retransmits - Q.921 Appendix IV */ /* Set any switch specific override default values */ switch (switchtype) { @@ -139,48 +185,13 @@ int pri_timer2idx(const char *timer_name) { - static const struct { - const char *name; - int number; - } timer[] = { -/* *INDENT-OFF* */ - { "N200", PRI_TIMER_N200 }, - { "N201", PRI_TIMER_N201 }, - { "N202", PRI_TIMER_N202 }, - { "K", PRI_TIMER_K }, - { "T200", PRI_TIMER_T200 }, - { "T202", PRI_TIMER_T202 }, - { "T203", PRI_TIMER_T203 }, - { "T300", PRI_TIMER_T300 }, - { "T301", PRI_TIMER_T301 }, - { "T302", PRI_TIMER_T302 }, - { "T303", PRI_TIMER_T303 }, - { "T304", PRI_TIMER_T304 }, - { "T305", PRI_TIMER_T305 }, - { "T306", PRI_TIMER_T306 }, - { "T307", PRI_TIMER_T307 }, - { "T308", PRI_TIMER_T308 }, - { "T309", PRI_TIMER_T309 }, - { "T310", PRI_TIMER_T310 }, - { "T313", PRI_TIMER_T313 }, - { "T314", PRI_TIMER_T314 }, - { "T316", PRI_TIMER_T316 }, - { "T317", PRI_TIMER_T317 }, - { "T318", PRI_TIMER_T318 }, - { "T319", PRI_TIMER_T319 }, - { "T320", PRI_TIMER_T320 }, - { "T321", PRI_TIMER_T321 }, - { "T322", PRI_TIMER_T322 }, -/* *INDENT-ON* */ - }; - unsigned idx; - int timer_number; + enum PRI_TIMERS_AND_COUNTERS timer_number; timer_number = -1; - for (idx = 0; idx < ARRAY_LEN(timer); ++idx) { - if (!strcasecmp(timer_name, timer[idx].name)) { - timer_number = timer[idx].number; + for (idx = 0; idx < ARRAY_LEN(pri_timer); ++idx) { + if (!strcasecmp(timer_name, pri_timer[idx].name)) { + timer_number = pri_timer[idx].number; break; } } @@ -692,7 +703,7 @@ static void pri_sr_init(struct pri_sr *req) { memset(req, 0, sizeof(struct pri_sr)); - + req->reversecharge = PRI_REVERSECHARGE_NONE; } int pri_sr_set_connection_call_independent(struct pri_sr *req) @@ -846,49 +857,102 @@ return pri->fd; } -char *pri_dump_info_str(struct pri *pri) -{ - char buf[4096]; - int len = 0; +/*! + * \internal + * \brief Append snprintf output to the given buffer. + * + * \param buf Buffer currently filling. + * \param buf_used Offset into buffer where to put new stuff. + * \param buf_size Actual buffer size of buf. + * \param format printf format string. + * + * \return Total buffer space used. + */ +static size_t pri_snprintf(char *buf, size_t buf_used, size_t buf_size, const char *format, ...) __attribute__((format(printf, 4, 5))); +static size_t pri_snprintf(char *buf, size_t buf_used, size_t buf_size, const char *format, ...) +{ + va_list args; + + if (buf_used < buf_size) { + va_start(args, format); + buf_used += vsnprintf(buf + buf_used, buf_size - buf_used, format, args); + va_end(args); + } + if (buf_size < buf_used) { + buf_used = buf_size + 1; + } + return buf_used; +} + +char *pri_dump_info_str(struct pri *ctrl) +{ + char *buf; + size_t buf_size; + size_t used; #ifdef LIBPRI_COUNTERS struct q921_frame *f; - int q921outstanding = 0; + unsigned q921outstanding; #endif - if (!pri) + unsigned idx; + unsigned long switch_bit; + + if (!ctrl) { return NULL; + } + + buf_size = 4096; /* This should be bigger than we will ever need. */ + buf = malloc(buf_size); + if (!buf) { + return NULL; + } /* Might be nice to format these a little better */ - len += sprintf(buf + len, "Switchtype: %s\n", pri_switch2str(pri->switchtype)); - len += sprintf(buf + len, "Type: %s\n", pri_node2str(pri->localtype)); + used = 0; + used = pri_snprintf(buf, used, buf_size, "Switchtype: %s\n", + pri_switch2str(ctrl->switchtype)); + used = pri_snprintf(buf, used, buf_size, "Type: %s\n", pri_node2str(ctrl->localtype)); #ifdef LIBPRI_COUNTERS /* Remember that Q921 Counters include Q931 packets (and any retransmissions) */ - len += sprintf(buf + len, "Q931 RX: %d\n", pri->q931_rxcount); - len += sprintf(buf + len, "Q931 TX: %d\n", pri->q931_txcount); - len += sprintf(buf + len, "Q921 RX: %d\n", pri->q921_rxcount); - len += sprintf(buf + len, "Q921 TX: %d\n", pri->q921_txcount); - f = pri->txqueue; + used = pri_snprintf(buf, used, buf_size, "Q931 RX: %d\n", ctrl->q931_rxcount); + used = pri_snprintf(buf, used, buf_size, "Q931 TX: %d\n", ctrl->q931_txcount); + used = pri_snprintf(buf, used, buf_size, "Q921 RX: %d\n", ctrl->q921_rxcount); + used = pri_snprintf(buf, used, buf_size, "Q921 TX: %d\n", ctrl->q921_txcount); + q921outstanding = 0; + f = ctrl->txqueue; while (f) { q921outstanding++; f = f->next; } - len += sprintf(buf + len, "Q921 Outstanding: %d\n", q921outstanding); + used = pri_snprintf(buf, used, buf_size, "Q921 Outstanding: %u\n", q921outstanding); #endif - len += sprintf(buf + len, "Window Length: %d/%d\n", pri->windowlen, pri->window); - len += sprintf(buf + len, "Sentrej: %d\n", pri->sentrej); - len += sprintf(buf + len, "SolicitFbit: %d\n", pri->solicitfbit); - len += sprintf(buf + len, "Retrans: %d\n", pri->retrans); - len += sprintf(buf + len, "Busy: %d\n", pri->busy); - len += sprintf(buf + len, "Overlap Dial: %d\n", pri->overlapdial); - len += sprintf(buf + len, "Logical Channel Mapping: %d\n", pri->chan_mapping_logical); - len += sprintf(buf + len, "T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]); - len += sprintf(buf + len, "T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]); - len += sprintf(buf + len, "T305 Timer: %d\n", pri->timers[PRI_TIMER_T305]); - len += sprintf(buf + len, "T308 Timer: %d\n", pri->timers[PRI_TIMER_T308]); - len += sprintf(buf + len, "T309 Timer: %d\n", pri->timers[PRI_TIMER_T309]); - len += sprintf(buf + len, "T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]); - len += sprintf(buf + len, "N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]); - - return strdup(buf); + used = pri_snprintf(buf, used, buf_size, "Window Length: %d/%d\n", ctrl->windowlen, + ctrl->window); + used = pri_snprintf(buf, used, buf_size, "Sentrej: %d\n", ctrl->sentrej); + used = pri_snprintf(buf, used, buf_size, "SolicitFbit: %d\n", ctrl->solicitfbit); + used = pri_snprintf(buf, used, buf_size, "Retrans: %d\n", ctrl->retrans); + used = pri_snprintf(buf, used, buf_size, "Busy: %d\n", ctrl->busy); + used = pri_snprintf(buf, used, buf_size, "Overlap Dial: %d\n", ctrl->overlapdial); + used = pri_snprintf(buf, used, buf_size, "Logical Channel Mapping: %d\n", + ctrl->chan_mapping_logical); + used = pri_snprintf(buf, used, buf_size, "Timer and counter settings:\n"); + switch_bit = PRI_BIT(ctrl->switchtype); + for (idx = 0; idx < ARRAY_LEN(pri_timer); ++idx) { + if (pri_timer[idx].used_by & switch_bit) { + enum PRI_TIMERS_AND_COUNTERS tmr; + + tmr = pri_timer[idx].number; + if (0 <= ctrl->timers[tmr] || tmr == PRI_TIMER_T309) { + used = pri_snprintf(buf, used, buf_size, " %s: %d\n", + pri_timer[idx].name, ctrl->timers[tmr]); + } + } + } + + if (buf_size < used) { + pri_message(ctrl, + "pri_dump_info_str(): Produced output exceeded buffer capacity. (Truncated)\n"); + } + return buf; } int pri_get_crv(struct pri *pri, q931_call *call, int *callmode) @@ -972,3 +1036,8 @@ sr->redirectingreason = reason; return 0; } + +void pri_sr_set_reversecharge(struct pri_sr *sr, int requested) +{ + sr->reversecharge = requested; +} Modified: team/group/issue10217/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue10217/pri_internal.h?view=diff&rev=934&r1=933&r2=934 ============================================================================== --- team/group/issue10217/pri_internal.h (original) +++ team/group/issue10217/pri_internal.h Thu Jul 2 12:13:15 2009 @@ -48,10 +48,8 @@ enum q931_state; enum q931_mode; -/* No more than 128 scheduled events */ +/*! Maximum number of scheduled events active at the same time. */ #define MAX_SCHED 128 - -#define MAX_TIMERS 32 /*! \brief D channel controller structure */ struct pri { @@ -100,7 +98,7 @@ int ri; int t200_timer; /* T-200 retransmission timer */ /* All ISDN Timer values */ - int timers[MAX_TIMERS]; + int timers[PRI_MAX_TIMERS]; /* Used by scheduler */ struct timeval tv; @@ -156,6 +154,7 @@ int justsignalling; const char *useruserinfo; int transferable; + int reversecharge; struct pri_lowlayercompat llc[4]; }; @@ -280,7 +279,10 @@ q931_call *bridged_call; /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */ int changestatus; /* SERVICE message changestatus */ - int reversecharge; /* Reverse charging indication */ + int reversecharge; /* Reverse charging indication: + -1 - No reverse charging + 1 - Reverse charging + 0,2-7 - Reserved for future use */ }; extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data); @@ -291,9 +293,8 @@ extern pri_event *pri_mkerror(struct pri *pri, char *errstr); -extern void pri_message(struct pri *pri, char *fmt, ...); - -extern void pri_error(struct pri *pri, char *fmt, ...); +void pri_message(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3))); +void pri_error(struct pri *ctrl, char *fmt, ...) __attribute__((format(printf, 2, 3))); void libpri_copy_string(char *dst, const char *src, size_t size); Modified: team/group/issue10217/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue10217/q931.c?view=diff&rev=934&r1=933&r2=934 ============================================================================== --- team/group/issue10217/q931.c (original) +++ team/group/issue10217/q931.c Thu Jul 2 12:13:15 2009 @@ -1029,7 +1029,8 @@ (data & 0x04)?1:0, (data & 0x02)?1:0); } else { - pri_message(ctrl, "%c Unknown octet 5b: 0x%x\n", data ); + pri_message(ctrl, "%c Unknown octet 5b: 0x%x\n", + prefix, data); } pos++; } @@ -2335,12 +2336,13 @@ type = ie->data[0] & 0x1F; pri_message(ctrl, "%c Generic Digits (len=%02d): Encoding %s Type %s\n", prefix, len, gdencoding2str(encoding), gdtype2str(type)); if (encoding == 3) { /* Binary */ - pri_message(ctrl, "%c Don't know how to handle binary encoding\n"); + pri_message(ctrl, "%c Don't know how to handle binary encoding\n", + prefix); return; } if (len == 3) /* No number information */ return; - pri_message(ctrl, "%c Digits: "); + pri_message(ctrl, "%c Digits: ", prefix); value = 0; for(idx = 3; idx < len; ++idx) { switch(encoding) { @@ -2519,6 +2521,15 @@ return 0; } +static int transmit_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order) +{ + if (call->reversecharge != PRI_REVERSECHARGE_NONE) { + ie->data[0] = 0x80 | (call->reversecharge & 0x7); + return 3; + } + return 0; +} + static struct ie ies[] = { /* Codeset 0 - Common */ { 1, NATIONAL_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status }, @@ -2535,7 +2546,7 @@ { 1, Q931_BINARY_PARAMETERS, "Packet-layer Binary Parameters" }, { 1, Q931_WINDOW_SIZE, "Packet-layer Window Size" }, { 1, Q931_CLOSED_USER_GROUP, "Closed User Group" }, - { 1, Q931_REVERSE_CHARGE_INDIC, "Reverse Charging Indication", dump_reverse_charging_indication, receive_reverse_charging_indication }, + { 1, Q931_REVERSE_CHARGE_INDIC, "Reverse Charging Indication", dump_reverse_charging_indication, receive_reverse_charging_indication, transmit_reverse_charging_indication }, { 0, Q931_REPEAT_INDIC, "Repeat Indicator", dump_repeat_indicator, receive_repeat_indicator, transmit_repeat_indicator }, { 1, Q931_CALLING_PARTY_NUMBER, "Calling Party Number", dump_calling_party_number, receive_calling_party_number, transmit_calling_party_number }, { 1, Q931_CALLING_PARTY_SUBADDR, "Calling Party Subaddress", dump_calling_party_subaddr, receive_calling_party_subaddr }, @@ -3484,8 +3495,8 @@ } static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY, - Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER, Q931_SENDING_COMPLETE, - Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 }; + Q931_REVERSE_CHARGE_INDIC, Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER, + Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 }; static int llc_setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY, Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER, Q931_REPEAT_INDIC, Q931_LOW_LAYER_COMPAT, Q931_SENDING_COMPLETE, @@ -3586,6 +3597,8 @@ c->progressmask = PRI_PROG_CALLER_NOT_ISDN; else c->progressmask = 0; + + c->reversecharge = req->reversecharge; pri_call_add_standard_apdus(ctrl, c); @@ -3830,6 +3843,7 @@ c->complete = 0; c->nonisdn = 0; c->aoc_units = -1; + c->reversecharge = -1; /* Fall through */ case Q931_CONNECT: case Q931_ALERTING: From libpri-commits at lists.digium.com Thu Jul 2 14:09:47 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 02 Jul 2009 19:09:47 -0000 Subject: [libpri-commits] sruffell: tag 1.4.10.1 r935 - /tags/1.4.10.1/.version Message-ID: Author: sruffell Date: Thu Jul 2 14:09:43 2009 New Revision: 935 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=935 Log: Update the .version file to 1.4.10.1 Modified: tags/1.4.10.1/.version Modified: tags/1.4.10.1/.version URL: http://svn.asterisk.org/svn-view/libpri/tags/1.4.10.1/.version?view=diff&rev=935&r1=934&r2=935 ============================================================================== --- tags/1.4.10.1/.version (original) +++ tags/1.4.10.1/.version Thu Jul 2 14:09:43 2009 @@ -1,1 +1,1 @@ -1.4.10 +1.4.10.1 From libpri-commits at lists.digium.com Thu Jul 2 14:15:04 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 02 Jul 2009 19:15:04 -0000 Subject: [libpri-commits] sruffell: tag 1.4.10.1 r936 - /tags/1.4.10.1/ChangeLog Message-ID: Author: sruffell Date: Thu Jul 2 14:15:01 2009 New Revision: 936 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=936 Log: Limiting last entry to 80 columns Modified: tags/1.4.10.1/ChangeLog Modified: tags/1.4.10.1/ChangeLog URL: http://svn.asterisk.org/svn-view/libpri/tags/1.4.10.1/ChangeLog?view=diff&rev=936&r1=935&r2=936 ============================================================================== --- tags/1.4.10.1/ChangeLog (original) +++ tags/1.4.10.1/ChangeLog Thu Jul 2 14:15:01 2009 @@ -1,27 +1,36 @@ 2009-04-18 Matthew Fredrickson * libpri 1.4.10.1 released. Includes a fix for a regression found in - the last few revisions of libpri, but fixed in revision 859 of - branches/1.4. The summary is as follows: - - * q921.c: There are two changes in this commit that are bug fixes for various Q.921 issues found in internal testing. - - Both were exposed/introduced by the TBR4 compliance patch for bug #12861, in changing how retransmissions and in how - the transmission queue was maintained. TX-RX message flow and acknowledgement was severely restricted, - since the patch changed the behavior so that pending untransmitted frames would not actually be send until - the next RR was received in normal circumstances, or REJ when a reject frame was received. On busy links, - this can severly limit the amount of useful traffic that is sent, and can slow down message transmission. - - Until someone can point out where in Q.921 it is mandated for us to wait for RR frames to start sending - untransmitted messages, the first change is to allow us to send untransmitted frames when we receive new - I frames as well, with updated N(R). - - The other bug fixed is a situation caused by the restricted traffic flow, if an outside process tries to send - an I-frame asynchronous to an RR frame, when the transmit window was previously closed and then opened up but - an RR has not been received yet. A bug was found with the integration of the old transmit code with the new reject - handling code which caused the new frame to be sent immediately, regardless if there were any pending untransmitted - I-frames in the queue to be sent and causing an out of order I-frame to be sent to the other side. This bug is - also fixed in this patch. + the last few revisions of libpri, but fixed in revision 859 of + branches/1.4. The summary is as follows: + + * q921.c: There are two changes in this commit that are bug fixes for + various Q.921 issues found in internal testing. + + Both were exposed/introduced by the TBR4 compliance patch for bug + #12861, in changing how retransmissions and in how the transmission + queue was maintained. TX-RX message flow and acknowledgement was + severely restricted, since the patch changed the behavior so that + pending untransmitted frames would not actually be send until the + next RR was received in normal circumstances, or REJ when a reject + frame was received. On busy links, this can severly limit the + amount of useful traffic that is sent, and can slow down message + transmission. + + Until someone can point out where in Q.921 it is mandated for us to + wait for RR frames to start sending untransmitted messages, the + first change is to allow us to send untransmitted frames when we + receive new I frames as well, with updated N(R). + + The other bug fixed is a situation caused by the restricted traffic + flow, if an outside process tries to send an I-frame asynchronous to + an RR frame, when the transmit window was previously closed and then + opened up but an RR has not been received yet. A bug was found with + the integration of the old transmit code with the new reject + handling code which caused the new frame to be sent immediately, + regardless if there were any pending untransmitted I-frames in the + queue to be sent and causing an out of order I-frame to be sent to + the other side. This bug is also fixed in this patch. 2009-04-18 Matthew Fredrickson From libpri-commits at lists.digium.com Thu Jul 9 15:31:06 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 09 Jul 2009 20:31:06 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r937 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Thu Jul 9 15:31:04 2009 New Revision: 937 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=937 Log: (empty) Added: team/mattf/libpri-1.4-ntptmp/ - copied from r936, branches/1.4/ From libpri-commits at lists.digium.com Thu Jul 9 15:32:33 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 09 Jul 2009 20:32:33 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r938 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Thu Jul 9 15:32:29 2009 New Revision: 938 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=938 Log: Add initial support for PTMP in NT mode. Modified: team/mattf/libpri-1.4-ntptmp/Makefile team/mattf/libpri-1.4-ntptmp/pri_q921.h team/mattf/libpri-1.4-ntptmp/q921.c team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/Makefile URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/Makefile?view=diff&rev=938&r1=937&r2=938 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/Makefile (original) +++ team/mattf/libpri-1.4-ntptmp/Makefile Thu Jul 9 15:32:29 2009 @@ -138,7 +138,7 @@ ifneq (${OSARCH},SunOS) install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir) - if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi +# if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi ( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so) install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir) if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi Modified: team/mattf/libpri-1.4-ntptmp/pri_q921.h URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_q921.h?view=diff&rev=938&r1=937&r2=938 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri_q921.h (original) +++ team/mattf/libpri-1.4-ntptmp/pri_q921.h Thu Jul 9 15:32:29 2009 @@ -192,6 +192,8 @@ extern int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr); +extern int q921_transmit_uiframe(struct pri *pri, void *buf, int len); + extern pri_event *q921_dchannel_up(struct pri *pri); extern pri_event *q921_dchannel_down(struct pri *pri); Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=938&r1=937&r2=938 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Thu Jul 9 15:32:29 2009 @@ -27,6 +27,7 @@ * terms granted here. */ +#include #include #include #include @@ -480,6 +481,45 @@ pri_error(pri, "T200 counter expired, nothing to send...\n"); pri->t200_timer = 0; } +} + +int q921_transmit_uiframe(struct pri *pri, void *buf, int len) +{ + uint8_t ubuf[512]; + q921_h *h = (void *)&ubuf[0]; + + if (len >= 512) { + pri_error(pri, "Requested to send UI frame larger than 512 bytes!\n"); + return -1; + } + + memset(ubuf, 0, sizeof(ubuf)); + h->h.sapi = 0; + h->h.ea1 = 0; + h->h.ea2 = 1; + h->h.tei = pri->tei; + h->u.m3 = 0; + h->u.m2 = 0; + h->u.p_f = 0; /* Poll bit set */ + h->u.ft = Q921_FRAMETYPE_U; + + switch(pri->localtype) { + case PRI_NETWORK: + h->h.c_r = 1; + break; + case PRI_CPE: + h->h.c_r = 0; + break; + default: + pri_error(pri, "Don't know how to U/A on a type %d node\n", pri->localtype); + return -1; + } + + memcpy(h->u.data, buf, len); + + q921_transmit(pri, h, len + 3); + + return 0; } int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr) Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=938&r1=937&r2=938 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Thu Jul 9 15:32:29 2009 @@ -2675,9 +2675,25 @@ *mhb = mh; } +static int inline PRI_NT_PTMP(struct pri *ctrl) +{ + return (((ctrl)->localtype == PRI_NETWORK) && ((ctrl)->tei == Q921_TEI_GROUP)); +} + static int q931_xmit(struct pri *ctrl, q931_h *h, int len, int cr) { - q921_transmit_iframe(ctrl, h, len, cr); + /* + * For NT-PTMP mode, we need to check the following: + * MODE = NT-PTMP + * MESSAGE = SETUP + * + * If those are true, we need to send the SETUP in a UI frame + * instead of an I-frame. + */ + if (PRI_NT_PTMP(ctrl)) + q921_transmit_uiframe(ctrl, h, len); + else + q921_transmit_iframe(ctrl, h, len, cr); /* The transmit operation might dump the q921 header, so logging the q931 message body after the transmit puts the sections of the message in the right order in the log */ From libpri-commits at lists.digium.com Thu Jul 9 15:33:49 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 09 Jul 2009 20:33:49 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r939 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Thu Jul 9 15:33:46 2009 New Revision: 939 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=939 Log: Add automerge support Modified: team/mattf/libpri-1.4-ntptmp/ (props changed) Propchange: team/mattf/libpri-1.4-ntptmp/ ------------------------------------------------------------------------------ svnmerge-integrated = /branches/1.4:1-936 From libpri-commits at lists.digium.com Thu Jul 9 16:55:34 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 09 Jul 2009 21:55:34 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r940 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Thu Jul 9 16:55:31 2009 New Revision: 940 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=940 Log: Make sure we cannot send the DS1 indicator for BRI, also, stop using semi-persistent layer 2 links Modified: team/mattf/libpri-1.4-ntptmp/q921.c team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=940&r1=939&r2=940 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Thu Jul 9 16:55:31 2009 @@ -604,10 +604,11 @@ pri->t203_timer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T200], t200_expire, pri); } else { if (pri->debug & PRI_DEBUG_Q921_DUMP) - pri_message(pri, "T203 counter expired in weird state %d\n", pri->q921_state); + pri_message(pri, "T203 counter expired in weird state %d on pri with sapi %d and tei %d\n", pri->q921_state, pri->sapi, pri->tei); pri->t203_timer = 0; } } + static pri_event *q921_handle_iframe(struct pri *pri, q921_i *i, int len) { int res; @@ -1183,7 +1184,6 @@ /* Acknowledge */ q921_send_ua(pri, h->u.p_f); ev = q921_dchannel_down(pri); - q921_restart(pri, 0); return ev; case 3: if (h->u.m2 == 3) { Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=940&r1=939&r2=940 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Thu Jul 9 16:55:31 2009 @@ -393,7 +393,7 @@ return 0; } - if (((ctrl->switchtype != PRI_SWITCH_QSIG) && (call->ds1no > 0)) || call->ds1explicit) { + if (!ctrl->bri && (((ctrl->switchtype != PRI_SWITCH_QSIG) && (call->ds1no > 0)) || call->ds1explicit)) { /* Note that we are specifying the identifier */ ie->data[pos++] |= 0x40; /* We need to use the Channel Identifier Present thingy. Just specify it and we're done */ From libpri-commits at lists.digium.com Fri Jul 17 16:49:05 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Fri, 17 Jul 2009 21:49:05 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r941 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Fri Jul 17 16:49:00 2009 New Revision: 941 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=941 Log: Add support for checking mode validity when receiving TEI management messages Modified: team/mattf/libpri-1.4-ntptmp/pri.c team/mattf/libpri-1.4-ntptmp/pri_internal.h team/mattf/libpri-1.4-ntptmp/q921.c team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri.c?view=diff&rev=941&r1=940&r2=941 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri.c (original) +++ team/mattf/libpri-1.4-ntptmp/pri.c Fri Jul 17 16:49:00 2009 @@ -223,7 +223,7 @@ /* Pass in the master for this function */ void __pri_free_tei(struct pri * p) { - free (p); + free(p); } struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri) Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_internal.h?view=diff&rev=941&r1=940&r2=941 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri_internal.h (original) +++ team/mattf/libpri-1.4-ntptmp/pri_internal.h Fri Jul 17 16:49:00 2009 @@ -32,6 +32,7 @@ #include #include +#include "pri_q921.h" #define ARRAY_LEN(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -294,4 +295,21 @@ void __pri_free_tei(struct pri *p); +static inline int BRI_NT_PTMP(struct pri *ctrl) +{ + while (ctrl->master) + ctrl = ctrl->master; + + return ctrl->bri && (((ctrl)->localtype == PRI_NETWORK) && ((ctrl)->tei == Q921_TEI_GROUP)); +} + +static inline int BRI_TE_PTMP(struct pri *ctrl) +{ + while (ctrl->master) + ctrl = ctrl->master; + + return ctrl->bri && (((ctrl)->localtype == PRI_CPE) && ((ctrl)->tei == Q921_TEI_GROUP)); +} + + #endif Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=941&r1=940&r2=941 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Fri Jul 17 16:49:00 2009 @@ -912,6 +912,12 @@ int ri; struct pri *sub; int tei; + + if (!BRI_NT_PTMP(pri) && !BRI_TE_PTMP(pri)) { + pri_error(pri, "Received MDL/TEI managemement message, but configured for mode other than PTMP!\n"); + return NULL; + } + if (pri->debug & PRI_DEBUG_Q921_STATE) pri_message(pri, "Received MDL message\n"); if (h->data[0] != 0x0f) { @@ -926,17 +932,19 @@ tei = (h->data[4] >> 1); switch(h->data[3]) { case Q921_TEI_IDENTITY_REQUEST: + if (!BRI_NT_PTMP(pri)) { + return NULL; + } + if (tei != 127) { pri_error(pri, "Received TEI identity request with invalid TEI %d\n", tei); q921_send_tei(pri, Q921_TEI_IDENTITY_DENIED, ri, tei, 1); } - /* Go to master */ - for (sub = pri; sub->master; sub = sub->master); tei = 64; -/*! \todo XXX Error: The following loop never terminates! */ - while(sub->subchannel) { - if(sub->subchannel->tei == tei) + while (sub->subchannel) { + if (sub->subchannel->tei == tei) ++tei; + sub = sub->subchannel; } sub->subchannel = __pri_new_tei(-1, pri->localtype, pri->switchtype, pri, NULL, NULL, NULL, tei, 1); if (!sub->subchannel) { @@ -946,6 +954,9 @@ q921_send_tei(pri, Q921_TEI_IDENTITY_ASSIGNED, ri, tei, 1); break; case Q921_TEI_IDENTITY_ASSIGNED: + if (!BRI_TE_PTMP(pri)) + return NULL; + if (ri != pri->ri) { pri_message(pri, "TEI assignment received for invalid Ri %02x (our is %02x)\n", ri, pri->ri); return NULL; @@ -969,6 +980,8 @@ pri->q921_state = Q921_TEI_ASSIGNED; break; case Q921_TEI_IDENTITY_CHECK_REQUEST: + if (!BRI_TE_PTMP(pri)) + return NULL; /* We're assuming one TEI per PRI in TE PTMP mode */ /* If no subchannel (TEI) ignore */ @@ -981,6 +994,8 @@ break; case Q921_TEI_IDENTITY_REMOVE: + if (!BRI_TE_PTMP(pri)) + return NULL; /* XXX: Assuming multiframe mode has been disconnected already */ if (!pri->subchannel) return NULL; @@ -1243,6 +1258,28 @@ return NULL; } +#if 0 +static pri_event *q921_handle_unmatched_frame(struct pri *pri, q921_h *h, int len) +{ + pri_error(pri, "Could not find candidate subchannel for received frame with SAPI/TEI of %d/%d.\n", h->h.sapi, h->h.tei); + if (h->h.tei < 64) { + pri_error(pri, "Do not support manual TEI range. Discarding\n"); + return NULL; + } + + if (h->h.sapi != Q921_CALL_CTRL) { + pri_error(pri, "Message with SAPI other than CALL CTRL is discarded\n"); + return NULL; + } + + pri_message(pri, "Sending TEI release, in order to re-establish TEI state\n"); + + /* TODO: Send TEI release message here */ + + return NULL; +} +#endif + static pri_event *__q921_receive(struct pri *pri, q921_h *h, int len) { pri_event *ev; @@ -1268,7 +1305,17 @@ if (pri->subchannel) return q921_receive(pri->subchannel, h, len + 2); else { + /* This means we couldn't find a candidate subchannel for it... + * Time for some corrective action */ + +#if 0 + if (pri->master) + return q921_handle_unmatched_frame(pri->master, h, len); + else + return NULL; +#else return NULL; +#endif } } Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=941&r1=940&r2=941 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Fri Jul 17 16:49:00 2009 @@ -2675,11 +2675,6 @@ *mhb = mh; } -static int inline PRI_NT_PTMP(struct pri *ctrl) -{ - return (((ctrl)->localtype == PRI_NETWORK) && ((ctrl)->tei == Q921_TEI_GROUP)); -} - static int q931_xmit(struct pri *ctrl, q931_h *h, int len, int cr) { /* @@ -2690,7 +2685,7 @@ * If those are true, we need to send the SETUP in a UI frame * instead of an I-frame. */ - if (PRI_NT_PTMP(ctrl)) + if (BRI_NT_PTMP(ctrl)) q921_transmit_uiframe(ctrl, h, len); else q921_transmit_iframe(ctrl, h, len, cr); From libpri-commits at lists.digium.com Fri Jul 17 17:30:59 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Fri, 17 Jul 2009 22:30:59 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r942 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Fri Jul 17 17:30:56 2009 New Revision: 942 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=942 Log: Only reschedule T203 when we have received an I frame or an S frame on a link managing a TEI. Modified: team/mattf/libpri-1.4-ntptmp/q921.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=942&r1=941&r2=942 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Fri Jul 17 17:30:56 2009 @@ -1037,6 +1037,10 @@ pri_error(pri, "!! Received short I-frame (expected 4, got %d)\n", len); break; } + + /* T203 is rescheduled only on reception of I frames or S frames */ + reschedule_t203(pri); + return q921_handle_iframe(pri, &h->i, len); break; case 1: @@ -1048,6 +1052,10 @@ pri_error(pri, "!! Received short S-frame (expected 4, got %d)\n", len); break; } + + /* T203 is rescheduled only on reception of I frames or S frames */ + reschedule_t203(pri); + switch(h->s.ss) { case 0: /* Receiver Ready */ @@ -1322,7 +1330,6 @@ if (pri->debug & PRI_DEBUG_Q921_DUMP) pri_message(pri, "Handling message for SAPI/TEI=%d/%d\n", h->h.sapi, h->h.tei); ev = __q921_receive_qualified(pri, h, len); - reschedule_t203(pri); return ev; } From libpri-commits at lists.digium.com Tue Jul 21 14:50:19 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 19:50:19 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r943 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 14:50:14 2009 New Revision: 943 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=943 Log: Make sure we only send SETUP messages as UI frames for now Modified: team/mattf/libpri-1.4-ntptmp/q921.c team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=943&r1=942&r2=943 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 14:50:14 2009 @@ -910,7 +910,7 @@ static pri_event *q921_receive_MDL(struct pri *pri, q921_u *h, int len) { int ri; - struct pri *sub; + struct pri *sub = pri; int tei; if (!BRI_NT_PTMP(pri) && !BRI_TE_PTMP(pri)) { Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=943&r1=942&r2=943 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Tue Jul 21 14:50:14 2009 @@ -2675,7 +2675,7 @@ *mhb = mh; } -static int q931_xmit(struct pri *ctrl, q931_h *h, int len, int cr) +static int q931_xmit(struct pri *ctrl, q931_h *h, int len, int cr, int uiframe) { /* * For NT-PTMP mode, we need to check the following: @@ -2685,7 +2685,7 @@ * If those are true, we need to send the SETUP in a UI frame * instead of an I-frame. */ - if (BRI_NT_PTMP(ctrl)) + if (BRI_NT_PTMP(ctrl) && uiframe) q921_transmit_uiframe(ctrl, h, len); else q921_transmit_iframe(ctrl, h, len, cr); @@ -2741,7 +2741,7 @@ ctrl = ctrl->subchannel; } if (ctrl) { - q931_xmit(ctrl, h, len, 1); + q931_xmit(ctrl, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0); } call->acked = 1; return 0; @@ -3583,7 +3583,7 @@ KLUDGE this by changing byte 4 from a 0xf (SERVICE) to a 0x7 (SERVICE ACKNOWLEDGE) */ h->raw[h->crlen + 2] -= 0x8; - q931_xmit(ctrl, h, len, 1); + q931_xmit(ctrl, h, len, 1, 0); return 0; } cref = q931_cr(h); From libpri-commits at lists.digium.com Tue Jul 21 15:23:47 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 20:23:47 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r945 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 15:23:44 2009 New Revision: 945 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=945 Log: Add functional handling for unmatched TEI/SAPI messages that are received. Right now we tell the other end to remove the TEI Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h team/mattf/libpri-1.4-ntptmp/q921.c Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_internal.h?view=diff&rev=945&r1=944&r2=945 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri_internal.h (original) +++ team/mattf/libpri-1.4-ntptmp/pri_internal.h Tue Jul 21 15:23:44 2009 @@ -295,21 +295,25 @@ void __pri_free_tei(struct pri *p); -static inline int BRI_NT_PTMP(struct pri *ctrl) +static inline struct pri * PRI_MASTER(struct pri *pri) { - while (ctrl->master) - ctrl = ctrl->master; - - return ctrl->bri && (((ctrl)->localtype == PRI_NETWORK) && ((ctrl)->tei == Q921_TEI_GROUP)); + while (pri->master) + pri = pri->master; + return pri; } -static inline int BRI_TE_PTMP(struct pri *ctrl) +static inline int BRI_NT_PTMP(struct pri *pri) { - while (ctrl->master) - ctrl = ctrl->master; - - return ctrl->bri && (((ctrl)->localtype == PRI_CPE) && ((ctrl)->tei == Q921_TEI_GROUP)); + return pri->bri && (((pri)->localtype == PRI_NETWORK) && ((pri)->tei == Q921_TEI_GROUP)); } +static inline int BRI_TE_PTMP(struct pri *pri) +{ + while (pri->master) + pri = pri->master; + + return pri->bri && (((pri)->localtype == PRI_CPE) && ((pri)->tei == Q921_TEI_GROUP)); +} + #endif Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=945&r1=944&r2=945 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 15:23:44 2009 @@ -1266,27 +1266,29 @@ return NULL; } -#if 0 static pri_event *q921_handle_unmatched_frame(struct pri *pri, q921_h *h, int len) { + pri = PRI_MASTER(pri); + pri_error(pri, "Could not find candidate subchannel for received frame with SAPI/TEI of %d/%d.\n", h->h.sapi, h->h.tei); + if (h->h.tei < 64) { pri_error(pri, "Do not support manual TEI range. Discarding\n"); return NULL; } - if (h->h.sapi != Q921_CALL_CTRL) { + if (h->h.sapi != Q921_SAPI_CALL_CTRL) { pri_error(pri, "Message with SAPI other than CALL CTRL is discarded\n"); return NULL; } - pri_message(pri, "Sending TEI release, in order to re-establish TEI state\n"); + pri_error(pri, "Sending TEI release, in order to re-establish TEI state\n"); /* TODO: Send TEI release message here */ + q921_send_tei(pri, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); return NULL; } -#endif static pri_event *__q921_receive(struct pri *pri, q921_h *h, int len) { @@ -1316,14 +1318,7 @@ /* This means we couldn't find a candidate subchannel for it... * Time for some corrective action */ -#if 0 - if (pri->master) - return q921_handle_unmatched_frame(pri->master, h, len); - else - return NULL; -#else - return NULL; -#endif + return q921_handle_unmatched_frame(pri, h, len); } } From libpri-commits at lists.digium.com Tue Jul 21 15:24:24 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 20:24:24 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r946 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 15:24:21 2009 New Revision: 946 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=946 Log: Remove unused broadcast receive code (we handle it another way) Modified: team/mattf/libpri-1.4-ntptmp/q921.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=946&r1=945&r2=946 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 15:24:21 2009 @@ -1303,12 +1303,6 @@ if (h->h.ea1 || !(h->h.ea2)) return NULL; -#if 0 /* Will be rejected by subchannel analyzis */ - /* Check for broadcasts - not yet handled */ - if (h->h.tei == Q921_TEI_GROUP) - return NULL; -#endif - if (!((h->h.sapi == pri->sapi) && ((h->h.tei == pri->tei) || (h->h.tei == Q921_TEI_GROUP)))) { /* Check for SAPIs we don't yet handle */ /* If it's not us, try any subchannels we have */ From libpri-commits at lists.digium.com Tue Jul 21 17:11:51 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 22:11:51 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r947 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 17:11:48 2009 New Revision: 947 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=947 Log: Fix bidirectional calling so that it works again... the pri for the call has to be set every time we receive a message, not just when we create a new call. Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h team/mattf/libpri-1.4-ntptmp/q921.c team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri_internal.h?view=diff&rev=947&r1=946&r2=947 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri_internal.h (original) +++ team/mattf/libpri-1.4-ntptmp/pri_internal.h Tue Jul 21 17:11:48 2009 @@ -295,22 +295,29 @@ void __pri_free_tei(struct pri *p); -static inline struct pri * PRI_MASTER(struct pri *pri) +static inline struct pri * PRI_MASTER(struct pri *mypri) { + struct pri *pri = mypri; + while (pri->master) pri = pri->master; return pri; } -static inline int BRI_NT_PTMP(struct pri *pri) +static inline int BRI_NT_PTMP(struct pri *mypri) { + struct pri *pri; + + pri = PRI_MASTER(mypri); + return pri->bri && (((pri)->localtype == PRI_NETWORK) && ((pri)->tei == Q921_TEI_GROUP)); } -static inline int BRI_TE_PTMP(struct pri *pri) +static inline int BRI_TE_PTMP(struct pri *mypri) { - while (pri->master) - pri = pri->master; + struct pri *pri; + + pri = PRI_MASTER(mypri); return pri->bri && (((pri)->localtype == PRI_CPE) && ((pri)->tei == Q921_TEI_GROUP)); } Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=947&r1=946&r2=947 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 17:11:48 2009 @@ -560,6 +560,7 @@ pri->txqueue = f; /* Immediately transmit unless we're in a recovery state, or the window size is too big */ + pri_message(pri, "TEI/SAPI: %d/%d state %d retran %d busy %d\n", pri->tei, pri->sapi, pri->q921_state, pri->retrans, pri->busy); if ((pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) && (!pri->retrans && !pri->busy)) { if (pri->windowlen < pri->window) { q921_send_queued_iframes(pri); Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=947&r1=946&r2=947 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Tue Jul 21 17:11:48 2009 @@ -2377,17 +2377,13 @@ struct pri *master; /* Find the master - He has the call pool */ - if (ctrl->master) { - master = ctrl->master; - } else { - master = ctrl; - } + master = PRI_MASTER(ctrl); cur = *master->callpool; prev = NULL; while (cur) { if (cur->cr == cr) { - return cur; + goto out; } prev = cur; cur = cur->next; @@ -2411,23 +2407,16 @@ cur->ourcallstate = Q931_CALL_STATE_NULL; cur->peercallstate = Q931_CALL_STATE_NULL; - /* PRI is set to whoever called us */ - if (ctrl->bri && (ctrl->localtype == PRI_CPE)) { - /* - * Point to the master to avoid stale pointer problems if - * the TEI is removed later. - */ - cur->pri = master; - } else { - cur->pri = ctrl; - } - /* Append to end of list */ if (prev) { prev->next = cur; } else { *master->callpool = cur; } + +out: + /* PRI is set to whoever called us */ + cur->pri = ctrl; return cur; } @@ -2732,6 +2721,7 @@ len = sizeof(buf) - len; ctrl = call->pri; + if (ctrl->bri && (ctrl->localtype == PRI_CPE)) { /* * Must use the BRI subchannel structure to send with the correct TEI. @@ -2741,7 +2731,8 @@ ctrl = ctrl->subchannel; } if (ctrl) { - q931_xmit(ctrl, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0); + pri_message(ctrl, "Sending message for call %p on %p TEI/SAPI %d/%d, call->pri is %p, TEI/SAPI %d/%d\n", call, ctrl, ctrl->tei, ctrl->sapi, call->pri, call->pri->tei, call->pri->sapi); + q931_xmit(call->pri, h, len, 1, (msgtype == Q931_SETUP) ? 1 : 0); } call->acked = 1; return 0; @@ -3317,6 +3308,9 @@ q931_release_complete(ctrl,c,cause); break; case Q931_CALL_STATE_CALL_INITIATED: + if (BRI_NT_PTMP(ctrl)) { + + } /* we sent SETUP */ case Q931_CALL_STATE_OVERLAP_SENDING: /* received SETUP_ACKNOWLEDGE */ @@ -3592,6 +3586,7 @@ pri_error(ctrl, "Unable to locate call %d\n", cref); return -1; } + pri_message(ctrl, "Received message for call %p on %p TEI/SAPI %d/%d, call->pri is %p TEI/SAPI %d/%d\n", c, ctrl, ctrl->tei, ctrl->sapi, c->pri, c->pri->tei, c->pri->sapi); /* Preliminary handling */ if ((h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_1) || (h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_2)) { prepare_to_handle_maintenance_message(ctrl, mh, c); From libpri-commits at lists.digium.com Tue Jul 21 17:28:43 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 22:28:43 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r948 - /team/mattf/libpri-1.4-ntptmp/pri.c Message-ID: Author: mattf Date: Tue Jul 21 17:28:39 2009 New Revision: 948 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=948 Log: Make sure the message that we pass back uses the master pri as the callback Modified: team/mattf/libpri-1.4-ntptmp/pri.c Modified: team/mattf/libpri-1.4-ntptmp/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/pri.c?view=diff&rev=948&r1=947&r2=948 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/pri.c (original) +++ team/mattf/libpri-1.4-ntptmp/pri.c Tue Jul 21 17:28:39 2009 @@ -817,7 +817,7 @@ vsnprintf(tmp, sizeof(tmp), fmt, ap); va_end(ap); if (__pri_message) - __pri_message(pri, tmp); + __pri_message(PRI_MASTER(pri), tmp); else fputs(tmp, stdout); } @@ -830,7 +830,7 @@ vsnprintf(tmp, sizeof(tmp), fmt, ap); va_end(ap); if (__pri_error) - __pri_error(pri, tmp); + __pri_error(PRI_MASTER(pri), tmp); else fputs(tmp, stderr); } From libpri-commits at lists.digium.com Tue Jul 21 17:31:21 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 22:31:21 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r949 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 17:31:18 2009 New Revision: 949 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=949 Log: Make sure we send the remove message twice, as recommended by Q.931 Modified: team/mattf/libpri-1.4-ntptmp/q921.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=949&r1=948&r2=949 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 17:31:18 2009 @@ -1285,7 +1285,8 @@ pri_error(pri, "Sending TEI release, in order to re-establish TEI state\n"); - /* TODO: Send TEI release message here */ + /* Q.931 says we should send the remove message twice, in case of link corruption */ + q921_send_tei(pri, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); q921_send_tei(pri, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); return NULL; From libpri-commits at lists.digium.com Tue Jul 21 17:31:50 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 21 Jul 2009 22:31:50 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r950 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Tue Jul 21 17:31:47 2009 New Revision: 950 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=950 Log: As I was saying... :-) Make sure we send the remove message twice, as recommended by Q.921 Modified: team/mattf/libpri-1.4-ntptmp/q921.c Modified: team/mattf/libpri-1.4-ntptmp/q921.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q921.c?view=diff&rev=950&r1=949&r2=950 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q921.c (original) +++ team/mattf/libpri-1.4-ntptmp/q921.c Tue Jul 21 17:31:47 2009 @@ -1285,7 +1285,7 @@ pri_error(pri, "Sending TEI release, in order to re-establish TEI state\n"); - /* Q.931 says we should send the remove message twice, in case of link corruption */ + /* Q.921 says we should send the remove message twice, in case of link corruption */ q921_send_tei(pri, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); q921_send_tei(pri, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); From libpri-commits at lists.digium.com Thu Jul 23 15:54:02 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 23 Jul 2009 20:54:02 -0000 Subject: [libpri-commits] rmudgett: branch 1.4 r952 - /branches/1.4/pri_facility.c Message-ID: Author: rmudgett Date: Thu Jul 23 15:53:59 2009 New Revision: 952 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=952 Log: Fixed potential NULL pointer dereference. Modified: branches/1.4/pri_facility.c Modified: branches/1.4/pri_facility.c URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/pri_facility.c?view=diff&rev=952&r1=951&r2=952 ============================================================================== --- branches/1.4/pri_facility.c (original) +++ branches/1.4/pri_facility.c Thu Jul 23 15:53:59 2009 @@ -873,7 +873,7 @@ unsigned char buffer[255]; unsigned char *end; - if (!req->called[0]) { + if (!req->called || !req->called[0]) { return -1; } From libpri-commits at lists.digium.com Thu Jul 23 17:26:10 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 23 Jul 2009 22:26:10 -0000 Subject: [libpri-commits] rmudgett: branch group/issue14068 r958 - /team/group/issue14068/ Message-ID: Author: rmudgett Date: Thu Jul 23 17:26:06 2009 New Revision: 958 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=958 Log: Add full caller ID and redirecting information to new SETUP record. Modified: team/group/issue14068/libpri.h team/group/issue14068/pri.c team/group/issue14068/pri_internal.h team/group/issue14068/q931.c Modified: team/group/issue14068/libpri.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/libpri.h?view=diff&rev=958&r1=957&r2=958 ============================================================================== --- team/group/issue14068/libpri.h (original) +++ team/group/issue14068/libpri.h Thu Jul 23 17:26:06 2009 @@ -726,13 +726,13 @@ /*! * \brief Give connected line information to a call - * \note Could be used instead of pri_sr_set_caller() before calling pri_setup(). + * \note Could be used instead of pri_sr_set_caller_party() before calling pri_setup(). */ int pri_connected_line_update(struct pri *pri, q931_call *call, const struct pri_party_connected_line *connected); /*! * \brief Give redirection information to a call - * \note Should be used instead of pri_sr_set_redirecting() before calling pri_setup(). + * \note Could be used instead of pri_sr_set_redirecting_parties() before calling pri_setup(). */ int pri_redirecting_update(struct pri *pri, q931_call *call, const struct pri_party_redirecting *redirecting); @@ -790,9 +790,29 @@ int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn); int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1); int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete); -/*! \note Use pri_connected_line_update() instead to pass more precise caller information. */ + +/*! + * \brief Set the caller party ID information in the call SETUP record. + * + * \param sr New call SETUP record. + * \param caller Caller party ID information to set. + * + * \return Nothing + */ +void pri_sr_set_caller_party(struct pri_sr *sr, const struct pri_party_id *caller); +/*! \note Use pri_sr_set_caller_party() instead to pass more precise caller information. */ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres); -/*! \note Use pri_redirecting_update() instead to pass more precise redirecting information. */ + +/*! + * \brief Set the redirecting information in the call SETUP record. + * + * \param sr New call SETUP record. + * \param caller Redirecting information to set. + * + * \return Nothing + */ +void pri_sr_set_redirecting_parties(struct pri_sr *sr, const struct pri_party_redirecting *redirecting); +/*! \note Use pri_sr_set_redirecting_parties() instead to pass more precise redirecting information. */ int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason); #define PRI_USER_USER_TX Modified: team/group/issue14068/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri.c?view=diff&rev=958&r1=957&r2=958 ============================================================================== --- team/group/issue14068/pri.c (original) +++ team/group/issue14068/pri.c Thu Jul 23 17:26:06 2009 @@ -603,29 +603,17 @@ * \internal * \brief Copy the PRI party number to the Q.931 party number structure. * - * \param ctrl D channel controller. * \param q931_number Q.931 party number structure * \param pri_number PRI party number structure * * \return Nothing */ -static void pri_copy_party_number_to_q931(struct pri *ctrl, struct q931_party_number *q931_number, const struct pri_party_number *pri_number) +static void pri_copy_party_number_to_q931(struct q931_party_number *q931_number, const struct pri_party_number *pri_number) { q931_party_number_init(q931_number); if (pri_number->valid) { q931_number->valid = 1; q931_number->presentation = pri_number->presentation; - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(q931_number->presentation & 0x7c)) { - q931_number->presentation = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } q931_number->plan = pri_number->plan; libpri_copy_string(q931_number->str, pri_number->str, sizeof(q931_number->str)); } @@ -635,16 +623,15 @@ * \internal * \brief Copy the PRI party id to the Q.931 party id structure. * - * \param ctrl D channel controller. * \param q931_id Q.931 party id structure * \param pri_id PRI party id structure * * \return Nothing */ -static void pri_copy_party_id_to_q931(struct pri *ctrl, struct q931_party_id *q931_id, const struct pri_party_id *pri_id) +static void pri_copy_party_id_to_q931(struct q931_party_id *q931_id, const struct pri_party_id *pri_id) { pri_copy_party_name_to_q931(&q931_id->name, &pri_id->name); - pri_copy_party_number_to_q931(ctrl, &q931_id->number, &pri_id->number); + pri_copy_party_number_to_q931(&q931_id->number, &pri_id->number); } int pri_connected_line_update(struct pri *ctrl, q931_call *call, const struct pri_party_connected_line *connected) @@ -655,7 +642,8 @@ return -1; } - pri_copy_party_id_to_q931(ctrl, &party_id, &connected->id); + pri_copy_party_id_to_q931(&party_id, &connected->id); + q931_party_id_fixup(ctrl, &party_id); if (!q931_party_id_cmp(&party_id, &call->local_id)) { /* The local party information did not change so do nothing. */ return 0; @@ -708,14 +696,17 @@ } /* Save redirecting.to information and reason. */ - pri_copy_party_id_to_q931(ctrl, &call->redirecting.to, &redirecting->to); + pri_copy_party_id_to_q931(&call->redirecting.to, &redirecting->to); + q931_party_id_fixup(ctrl, &call->redirecting.to); call->redirecting.reason = redirecting->reason; switch (call->ourcallstate) { case Q931_CALL_STATE_NULL: /* Save the remaining redirecting information before we place a call. */ - pri_copy_party_id_to_q931(ctrl, &call->redirecting.from, &redirecting->from); - pri_copy_party_id_to_q931(ctrl, &call->redirecting.orig_called, &redirecting->orig_called); + pri_copy_party_id_to_q931(&call->redirecting.from, &redirecting->from); + q931_party_id_fixup(ctrl, &call->redirecting.from); + pri_copy_party_id_to_q931(&call->redirecting.orig_called, &redirecting->orig_called); + q931_party_id_fixup(ctrl, &call->redirecting.orig_called); call->redirecting.orig_reason = redirecting->orig_reason; if (redirecting->count <= 0) { if (call->redirecting.from.number.valid) { @@ -909,6 +900,8 @@ static void pri_sr_init(struct pri_sr *req) { memset(req, 0, sizeof(struct pri_sr)); + q931_party_redirecting_init(&req->redirecting); + q931_party_id_init(&req->caller); req->reversecharge = PRI_REVERSECHARGE_NONE; } @@ -931,13 +924,8 @@ pri_sr_init(&req); pri_sr_set_connection_call_independent(&req); - - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); if (mwi_message_send(pri, c, &req, 1) < 0) { pri_message(pri, "Unable to send MWI activate message\n"); @@ -956,13 +944,8 @@ pri_sr_init(&req); pri_sr_set_connection_call_independent(&req); - - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); if(mwi_message_send(pri, c, &req, 0) < 0) { pri_message(pri, "Unable to send MWI deactivate message\n"); @@ -988,16 +971,12 @@ if (!pri || !c) return -1; pri_sr_init(&req); + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); req.transmode = transmode; req.channel = channel; req.exclusive = exclusive; req.nonisdn = nonisdn; - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; req.userl1 = ulayer1; return q931_setup(pri, c, &req); } @@ -1216,22 +1195,69 @@ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres) { - sr->caller = caller; - sr->callername = callername; - sr->callerplan = callerplan; - sr->callerpres = callerpres; + q931_party_id_init(&sr->caller); + if (caller) { + sr->caller.number.valid = 1; + sr->caller.number.presentation = callerpres; + sr->caller.number.plan = callerplan; + libpri_copy_string(sr->caller.number.str, caller, sizeof(sr->caller.number.str)); + + if (callername) { + sr->caller.name.valid = 1; + sr->caller.name.presentation = callerpres; + sr->caller.name.char_set = PRI_CHAR_SET_ISO8859_1; + libpri_copy_string(sr->caller.name.str, callername, + sizeof(sr->caller.name.str)); + } + } return 0; } +void pri_sr_set_caller_party(struct pri_sr *sr, const struct pri_party_id *caller) +{ + pri_copy_party_id_to_q931(&sr->caller, caller); +} + int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason) { - sr->redirectingnum = num; - sr->redirectingplan = plan; - sr->redirectingpres = pres; - sr->redirectingreason = reason; + q931_party_redirecting_init(&sr->redirecting); + if (num && num[0]) { + sr->redirecting.from.number.valid = 1; + sr->redirecting.from.number.presentation = pres; + sr->redirecting.from.number.plan = plan; + libpri_copy_string(sr->redirecting.from.number.str, num, + sizeof(sr->redirecting.from.number.str)); + + sr->redirecting.count = 1; + sr->redirecting.reason = reason; + } return 0; } +void pri_sr_set_redirecting_parties(struct pri_sr *sr, const struct pri_party_redirecting *redirecting) +{ + pri_copy_party_id_to_q931(&sr->redirecting.from, &redirecting->from); + pri_copy_party_id_to_q931(&sr->redirecting.to, &redirecting->to); + pri_copy_party_id_to_q931(&sr->redirecting.orig_called, &redirecting->orig_called); + sr->redirecting.orig_reason = redirecting->orig_reason; + sr->redirecting.reason = redirecting->reason; + if (redirecting->count <= 0) { + if (sr->redirecting.from.number.valid) { + /* + * We are redirecting with an unknown count + * so assume the count is one. + */ + sr->redirecting.count = 1; + } else { + sr->redirecting.count = 0; + } + } else if (redirecting->count < PRI_MAX_REDIRECTS) { + sr->redirecting.count = redirecting->count; + } else { + sr->redirecting.count = PRI_MAX_REDIRECTS; + } +} + void pri_sr_set_reversecharge(struct pri_sr *sr, int requested) { sr->reversecharge = requested; Modified: team/group/issue14068/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_internal.h?view=diff&rev=958&r1=957&r2=958 ============================================================================== --- team/group/issue14068/pri_internal.h (original) +++ team/group/issue14068/pri_internal.h Thu Jul 23 17:26:06 2009 @@ -135,44 +135,6 @@ unsigned char sendfacility; }; -/*! \brief New call setup parameter structure */ -struct pri_sr { - int transmode; - int channel; - int exclusive; - int nonisdn; - char *caller; - int callerplan; - char *callername; - int callerpres; - char *called; - int calledplan; - int userl1; - int numcomplete; - char *redirectingnum; - int redirectingplan; - int redirectingpres; - int redirectingreason; - int justsignalling; - const char *useruserinfo; - int transferable; - int reversecharge; -}; - -/* Internal switch types */ -#define PRI_SWITCH_GR303_EOC_PATH 19 -#define PRI_SWITCH_GR303_TMC_SWITCHING 20 - -struct apdu_event { - int message; /* What message to send the ADPU in */ - void (*callback)(void *data); /* Callback function for when response is received */ - void *data; /* Data to callback */ - unsigned char apdu[255]; /* ADPU to send */ - int apdu_len; /* Length of ADPU */ - int sent; /* Have we been sent already? */ - struct apdu_event *next; /* Linked list pointer */ -}; - /*! \brief Maximum name length plus null terminator (From ECMA-164) */ #define PRI_MAX_NAME_LEN (50 + 1) @@ -273,6 +235,38 @@ unsigned char orig_reason; /*! \brief Redirection reasons */ unsigned char reason; +}; + +/*! \brief New call setup parameter structure */ +struct pri_sr { + int transmode; + int channel; + int exclusive; + int nonisdn; + struct q931_party_redirecting redirecting; + struct q931_party_id caller; + char *called; + int calledplan; + int userl1; + int numcomplete; + int justsignalling; + const char *useruserinfo; + int transferable; + int reversecharge; +}; + +/* Internal switch types */ +#define PRI_SWITCH_GR303_EOC_PATH 19 +#define PRI_SWITCH_GR303_TMC_SWITCHING 20 + +struct apdu_event { + int message; /* What message to send the ADPU in */ + void (*callback)(void *data); /* Callback function for when response is received */ + void *data; /* Data to callback */ + unsigned char apdu[255]; /* ADPU to send */ + int apdu_len; /* Length of ADPU */ + int sent; /* Have we been sent already? */ + struct apdu_event *next; /* Linked list pointer */ }; /*! \brief Incoming call transfer states. */ @@ -459,6 +453,7 @@ void q931_party_id_copy_to_pri(struct pri_party_id *pri_id, const struct q931_party_id *q931_id); void q931_party_redirecting_copy_to_pri(struct pri_party_redirecting *pri_redirecting, const struct q931_party_redirecting *q931_redirecting); +void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id); int q931_party_id_presentation(const struct q931_party_id *id); const char *q931_call_state_str(int callstate); Modified: team/group/issue14068/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=958&r1=957&r2=958 ============================================================================== --- team/group/issue14068/q931.c (original) +++ team/group/issue14068/q931.c Thu Jul 23 17:26:06 2009 @@ -490,6 +490,30 @@ pri_redirecting->count = q931_redirecting->count; pri_redirecting->orig_reason = q931_redirecting->orig_reason; pri_redirecting->reason = q931_redirecting->reason; +} + +/*! + * \brief Fixup some values in the q931_party_id that may be objectionable by switches. + * + * \param ctrl D channel controller. + * \param id Party ID to tweak. + * + * \return Nothing + */ +void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id) +{ + switch (ctrl->switchtype) { + case PRI_SWITCH_DMS100: + case PRI_SWITCH_ATT4ESS: + /* Doesn't like certain presentation types */ + if (id->number.valid && !(id->number.presentation & 0x7c)) { + /* i.e., If presentation is allowed it must be a network number */ + id->number.presentation = PRES_ALLOWED_NETWORK_NUMBER; + } + break; + default: + break; + } } /*! @@ -3745,55 +3769,19 @@ c->chanflags = FLAG_EXCLUSIVE; else if (c->channelno) c->chanflags = FLAG_PREFERRED; - if (req->caller) { - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(req->callerpres & 0x7c)) { - req->callerpres = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } - - c->local_id.number.valid = 1; - c->local_id.number.presentation = req->callerpres; - c->local_id.number.plan = req->callerplan; - libpri_copy_string(c->local_id.number.str, req->caller, - sizeof(c->local_id.number.str)); - - if (req->callername) { - c->local_id.name.valid = 1; - c->local_id.name.presentation = req->callerpres; - c->local_id.name.char_set = PRI_CHAR_SET_ISO8859_1; - libpri_copy_string(c->local_id.name.str, req->callername, - sizeof(c->local_id.name.str)); - } - } - if (req->redirectingnum && req->redirectingnum[0]) { - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(req->redirectingpres & 0x7c)) { - req->redirectingpres = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } - - c->redirecting.from.number.valid = 1; - c->redirecting.from.number.presentation = req->redirectingpres; - c->redirecting.from.number.plan = req->redirectingplan; - libpri_copy_string(c->redirecting.from.number.str, req->redirectingnum, - sizeof(c->redirecting.from.number.str)); - - c->redirecting.count = 1; - c->redirecting.reason = req->redirectingreason; - } + + if (req->caller.number.valid) { + c->local_id = req->caller; + q931_party_id_fixup(ctrl, &c->local_id); + } + + if (req->redirecting.from.number.valid) { + c->redirecting = req->redirecting; + q931_party_id_fixup(ctrl, &c->redirecting.from); + q931_party_id_fixup(ctrl, &c->redirecting.to); + q931_party_id_fixup(ctrl, &c->redirecting.orig_called); + } + if (req->called) { c->called_number.valid = 1; c->called_number.plan = req->calledplan; From libpri-commits at lists.digium.com Thu Jul 23 17:56:07 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Thu, 23 Jul 2009 22:56:07 -0000 Subject: [libpri-commits] rmudgett: branch group/issue14292 r960 - /team/group/issue14292/ Message-ID: Author: rmudgett Date: Thu Jul 23 17:56:03 2009 New Revision: 960 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=960 Log: Merged revisions 958 via svnmerge from https://origsvn.digium.com/svn/libpri/team/group/issue14068 ........ r958 | rmudgett | 2009-07-23 17:26:06 -0500 (Thu, 23 Jul 2009) | 1 line Add full caller ID and redirecting information to new SETUP record. ........ Modified: team/group/issue14292/ (props changed) team/group/issue14292/libpri.h team/group/issue14292/pri.c team/group/issue14292/pri_internal.h team/group/issue14292/q931.c Propchange: team/group/issue14292/ ------------------------------------------------------------------------------ automerge = * Propchange: team/group/issue14292/ ------------------------------------------------------------------------------ --- issue14292-integrated (original) +++ issue14292-integrated Thu Jul 23 17:56:03 2009 @@ -1,1 +1,1 @@ -/team/group/issue14068:1-954 +/team/group/issue14068:1-959 Modified: team/group/issue14292/libpri.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14292/libpri.h?view=diff&rev=960&r1=959&r2=960 ============================================================================== --- team/group/issue14292/libpri.h (original) +++ team/group/issue14292/libpri.h Thu Jul 23 17:56:03 2009 @@ -796,13 +796,13 @@ /*! * \brief Give connected line information to a call - * \note Could be used instead of pri_sr_set_caller() before calling pri_setup(). + * \note Could be used instead of pri_sr_set_caller_party() before calling pri_setup(). */ int pri_connected_line_update(struct pri *pri, q931_call *call, const struct pri_party_connected_line *connected); /*! * \brief Give redirection information to a call - * \note Should be used instead of pri_sr_set_redirecting() before calling pri_setup(). + * \note Could be used instead of pri_sr_set_redirecting_parties() before calling pri_setup(). */ int pri_redirecting_update(struct pri *pri, q931_call *call, const struct pri_party_redirecting *redirecting); @@ -865,9 +865,29 @@ int pri_sr_set_channel(struct pri_sr *sr, int channel, int exclusive, int nonisdn); int pri_sr_set_bearer(struct pri_sr *sr, int transmode, int userl1); int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int complete); -/*! \note Use pri_connected_line_update() instead to pass more precise caller information. */ + +/*! + * \brief Set the caller party ID information in the call SETUP record. + * + * \param sr New call SETUP record. + * \param caller Caller party ID information to set. + * + * \return Nothing + */ +void pri_sr_set_caller_party(struct pri_sr *sr, const struct pri_party_id *caller); +/*! \note Use pri_sr_set_caller_party() instead to pass more precise caller information. */ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres); -/*! \note Use pri_redirecting_update() instead to pass more precise redirecting information. */ + +/*! + * \brief Set the redirecting information in the call SETUP record. + * + * \param sr New call SETUP record. + * \param caller Redirecting information to set. + * + * \return Nothing + */ +void pri_sr_set_redirecting_parties(struct pri_sr *sr, const struct pri_party_redirecting *redirecting); +/*! \note Use pri_sr_set_redirecting_parties() instead to pass more precise redirecting information. */ int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason); Modified: team/group/issue14292/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14292/pri.c?view=diff&rev=960&r1=959&r2=960 ============================================================================== --- team/group/issue14292/pri.c (original) +++ team/group/issue14292/pri.c Thu Jul 23 17:56:03 2009 @@ -605,29 +605,17 @@ * \internal * \brief Copy the PRI party number to the Q.931 party number structure. * - * \param ctrl D channel controller. * \param q931_number Q.931 party number structure * \param pri_number PRI party number structure * * \return Nothing */ -static void pri_copy_party_number_to_q931(struct pri *ctrl, struct q931_party_number *q931_number, const struct pri_party_number *pri_number) +static void pri_copy_party_number_to_q931(struct q931_party_number *q931_number, const struct pri_party_number *pri_number) { q931_party_number_init(q931_number); if (pri_number->valid) { q931_number->valid = 1; q931_number->presentation = pri_number->presentation; - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(q931_number->presentation & 0x7c)) { - q931_number->presentation = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } q931_number->plan = pri_number->plan; libpri_copy_string(q931_number->str, pri_number->str, sizeof(q931_number->str)); } @@ -637,16 +625,15 @@ * \internal * \brief Copy the PRI party id to the Q.931 party id structure. * - * \param ctrl D channel controller. * \param q931_id Q.931 party id structure * \param pri_id PRI party id structure * * \return Nothing */ -static void pri_copy_party_id_to_q931(struct pri *ctrl, struct q931_party_id *q931_id, const struct pri_party_id *pri_id) +static void pri_copy_party_id_to_q931(struct q931_party_id *q931_id, const struct pri_party_id *pri_id) { pri_copy_party_name_to_q931(&q931_id->name, &pri_id->name); - pri_copy_party_number_to_q931(ctrl, &q931_id->number, &pri_id->number); + pri_copy_party_number_to_q931(&q931_id->number, &pri_id->number); } int pri_connected_line_update(struct pri *ctrl, q931_call *call, const struct pri_party_connected_line *connected) @@ -657,7 +644,8 @@ return -1; } - pri_copy_party_id_to_q931(ctrl, &party_id, &connected->id); + pri_copy_party_id_to_q931(&party_id, &connected->id); + q931_party_id_fixup(ctrl, &party_id); if (!q931_party_id_cmp(&party_id, &call->local_id)) { /* The local party information did not change so do nothing. */ return 0; @@ -710,14 +698,17 @@ } /* Save redirecting.to information and reason. */ - pri_copy_party_id_to_q931(ctrl, &call->redirecting.to, &redirecting->to); + pri_copy_party_id_to_q931(&call->redirecting.to, &redirecting->to); + q931_party_id_fixup(ctrl, &call->redirecting.to); call->redirecting.reason = redirecting->reason; switch (call->ourcallstate) { case Q931_CALL_STATE_NULL: /* Save the remaining redirecting information before we place a call. */ - pri_copy_party_id_to_q931(ctrl, &call->redirecting.from, &redirecting->from); - pri_copy_party_id_to_q931(ctrl, &call->redirecting.orig_called, &redirecting->orig_called); + pri_copy_party_id_to_q931(&call->redirecting.from, &redirecting->from); + q931_party_id_fixup(ctrl, &call->redirecting.from); + pri_copy_party_id_to_q931(&call->redirecting.orig_called, &redirecting->orig_called); + q931_party_id_fixup(ctrl, &call->redirecting.orig_called); call->redirecting.orig_reason = redirecting->orig_reason; if (redirecting->count <= 0) { if (call->redirecting.from.number.valid) { @@ -922,6 +913,8 @@ static void pri_sr_init(struct pri_sr *req) { memset(req, 0, sizeof(struct pri_sr)); + q931_party_redirecting_init(&req->redirecting); + q931_party_id_init(&req->caller); req->reversecharge = PRI_REVERSECHARGE_NONE; } @@ -953,13 +946,8 @@ pri_sr_init(&req); pri_sr_set_connection_call_independent(&req); - - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); if (mwi_message_send(pri, c, &req, 1) < 0) { pri_message(pri, "Unable to send MWI activate message\n"); @@ -978,13 +966,8 @@ pri_sr_init(&req); pri_sr_set_connection_call_independent(&req); - - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); if(mwi_message_send(pri, c, &req, 0) < 0) { pri_message(pri, "Unable to send MWI deactivate message\n"); @@ -1010,16 +993,12 @@ if (!pri || !c) return -1; pri_sr_init(&req); + pri_sr_set_caller(&req, caller, callername, callerplan, callerpres); + pri_sr_set_called(&req, called, calledplan, 0); req.transmode = transmode; req.channel = channel; req.exclusive = exclusive; req.nonisdn = nonisdn; - req.caller = caller; - req.callerplan = callerplan; - req.callername = callername; - req.callerpres = callerpres; - req.called = called; - req.calledplan = calledplan; req.userl1 = ulayer1; return q931_setup(pri, c, &req); } @@ -1295,20 +1274,67 @@ int pri_sr_set_caller(struct pri_sr *sr, char *caller, char *callername, int callerplan, int callerpres) { - sr->caller = caller; - sr->callername = callername; - sr->callerplan = callerplan; - sr->callerpres = callerpres; + q931_party_id_init(&sr->caller); + if (caller) { + sr->caller.number.valid = 1; + sr->caller.number.presentation = callerpres; + sr->caller.number.plan = callerplan; + libpri_copy_string(sr->caller.number.str, caller, sizeof(sr->caller.number.str)); + + if (callername) { + sr->caller.name.valid = 1; + sr->caller.name.presentation = callerpres; + sr->caller.name.char_set = PRI_CHAR_SET_ISO8859_1; + libpri_copy_string(sr->caller.name.str, callername, + sizeof(sr->caller.name.str)); + } + } return 0; } +void pri_sr_set_caller_party(struct pri_sr *sr, const struct pri_party_id *caller) +{ + pri_copy_party_id_to_q931(&sr->caller, caller); +} + int pri_sr_set_redirecting(struct pri_sr *sr, char *num, int plan, int pres, int reason) { - sr->redirectingnum = num; - sr->redirectingplan = plan; - sr->redirectingpres = pres; - sr->redirectingreason = reason; + q931_party_redirecting_init(&sr->redirecting); + if (num && num[0]) { + sr->redirecting.from.number.valid = 1; + sr->redirecting.from.number.presentation = pres; + sr->redirecting.from.number.plan = plan; + libpri_copy_string(sr->redirecting.from.number.str, num, + sizeof(sr->redirecting.from.number.str)); + + sr->redirecting.count = 1; + sr->redirecting.reason = reason; + } return 0; +} + +void pri_sr_set_redirecting_parties(struct pri_sr *sr, const struct pri_party_redirecting *redirecting) +{ + pri_copy_party_id_to_q931(&sr->redirecting.from, &redirecting->from); + pri_copy_party_id_to_q931(&sr->redirecting.to, &redirecting->to); + pri_copy_party_id_to_q931(&sr->redirecting.orig_called, &redirecting->orig_called); + sr->redirecting.orig_reason = redirecting->orig_reason; + sr->redirecting.reason = redirecting->reason; + if (redirecting->count <= 0) { + if (sr->redirecting.from.number.valid) { + /* + * We are redirecting with an unknown count + * so assume the count is one. + */ + sr->redirecting.count = 1; + } else { + sr->redirecting.count = 0; + } + } else if (redirecting->count < PRI_MAX_REDIRECTS) { + sr->redirecting.count = redirecting->count; + } else { + sr->redirecting.count = PRI_MAX_REDIRECTS; + } } void pri_sr_set_reversecharge(struct pri_sr *sr, int requested) Modified: team/group/issue14292/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14292/pri_internal.h?view=diff&rev=960&r1=959&r2=960 ============================================================================== --- team/group/issue14292/pri_internal.h (original) +++ team/group/issue14292/pri_internal.h Thu Jul 23 17:56:03 2009 @@ -135,47 +135,6 @@ unsigned char sendfacility; }; -/*! \brief New call setup parameter structure */ -struct pri_sr { - int transmode; - int channel; - int exclusive; - int nonisdn; - char *caller; - int callerplan; - char *callername; - int callerpres; - char *called; - int calledplan; - int userl1; - int numcomplete; - char *redirectingnum; - int redirectingplan; - int redirectingpres; - int redirectingreason; - int justsignalling; - int nochannelsignalling; - int ccbsnr; - const char *useruserinfo; - int transferable; - int reversecharge; - int ccringout; -}; - -/* Internal switch types */ -#define PRI_SWITCH_GR303_EOC_PATH 19 -#define PRI_SWITCH_GR303_TMC_SWITCHING 20 - -struct apdu_event { - int message; /* What message to send the ADPU in */ - void (*callback)(void *data); /* Callback function for when response is received */ - void *data; /* Data to callback */ - unsigned char apdu[255]; /* ADPU to send */ - int apdu_len; /* Length of ADPU */ - int sent; /* Have we been sent already? */ - struct apdu_event *next; /* Linked list pointer */ -}; - /*! \brief Maximum name length plus null terminator (From ECMA-164) */ #define PRI_MAX_NAME_LEN (50 + 1) @@ -276,6 +235,41 @@ unsigned char orig_reason; /*! \brief Redirection reasons */ unsigned char reason; +}; + +/*! \brief New call setup parameter structure */ +struct pri_sr { + int transmode; + int channel; + int exclusive; + int nonisdn; + struct q931_party_redirecting redirecting; + struct q931_party_id caller; + char *called; + int calledplan; + int userl1; + int numcomplete; + int justsignalling; + int nochannelsignalling; + int ccbsnr; + const char *useruserinfo; + int transferable; + int reversecharge; + int ccringout; +}; + +/* Internal switch types */ +#define PRI_SWITCH_GR303_EOC_PATH 19 +#define PRI_SWITCH_GR303_TMC_SWITCHING 20 + +struct apdu_event { + int message; /* What message to send the ADPU in */ + void (*callback)(void *data); /* Callback function for when response is received */ + void *data; /* Data to callback */ + unsigned char apdu[255]; /* ADPU to send */ + int apdu_len; /* Length of ADPU */ + int sent; /* Have we been sent already? */ + struct apdu_event *next; /* Linked list pointer */ }; /*! \brief Incoming call transfer states. */ @@ -467,6 +461,7 @@ void q931_party_id_copy_to_pri(struct pri_party_id *pri_id, const struct q931_party_id *q931_id); void q931_party_redirecting_copy_to_pri(struct pri_party_redirecting *pri_redirecting, const struct q931_party_redirecting *q931_redirecting); +void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id); int q931_party_id_presentation(const struct q931_party_id *id); const char *q931_call_state_str(int callstate); Modified: team/group/issue14292/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14292/q931.c?view=diff&rev=960&r1=959&r2=960 ============================================================================== --- team/group/issue14292/q931.c (original) +++ team/group/issue14292/q931.c Thu Jul 23 17:56:03 2009 @@ -490,6 +490,30 @@ pri_redirecting->count = q931_redirecting->count; pri_redirecting->orig_reason = q931_redirecting->orig_reason; pri_redirecting->reason = q931_redirecting->reason; +} + +/*! + * \brief Fixup some values in the q931_party_id that may be objectionable by switches. + * + * \param ctrl D channel controller. + * \param id Party ID to tweak. + * + * \return Nothing + */ +void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id) +{ + switch (ctrl->switchtype) { + case PRI_SWITCH_DMS100: + case PRI_SWITCH_ATT4ESS: + /* Doesn't like certain presentation types */ + if (id->number.valid && !(id->number.presentation & 0x7c)) { + /* i.e., If presentation is allowed it must be a network number */ + id->number.presentation = PRES_ALLOWED_NETWORK_NUMBER; + } + break; + default: + break; + } } /*! @@ -3771,55 +3795,19 @@ c->chanflags = FLAG_EXCLUSIVE; else if (c->channelno) c->chanflags = FLAG_PREFERRED; - if (req->caller) { - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(req->callerpres & 0x7c)) { - req->callerpres = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } - - c->local_id.number.valid = 1; - c->local_id.number.presentation = req->callerpres; - c->local_id.number.plan = req->callerplan; - libpri_copy_string(c->local_id.number.str, req->caller, - sizeof(c->local_id.number.str)); - - if (req->callername) { - c->local_id.name.valid = 1; - c->local_id.name.presentation = req->callerpres; - c->local_id.name.char_set = PRI_CHAR_SET_ISO8859_1; - libpri_copy_string(c->local_id.name.str, req->callername, - sizeof(c->local_id.name.str)); - } - } - if (req->redirectingnum && req->redirectingnum[0]) { - switch (ctrl->switchtype) { - case PRI_SWITCH_DMS100: - case PRI_SWITCH_ATT4ESS: - /* Doesn't like certain presentation types */ - if (!(req->redirectingpres & 0x7c)) { - req->redirectingpres = PRES_ALLOWED_NETWORK_NUMBER; - } - break; - default: - break; - } - - c->redirecting.from.number.valid = 1; - c->redirecting.from.number.presentation = req->redirectingpres; - c->redirecting.from.number.plan = req->redirectingplan; - libpri_copy_string(c->redirecting.from.number.str, req->redirectingnum, - sizeof(c->redirecting.from.number.str)); - - c->redirecting.count = 1; - c->redirecting.reason = req->redirectingreason; - } + + if (req->caller.number.valid) { + c->local_id = req->caller; + q931_party_id_fixup(ctrl, &c->local_id); + } + + if (req->redirecting.from.number.valid) { + c->redirecting = req->redirecting; + q931_party_id_fixup(ctrl, &c->redirecting.from); + q931_party_id_fixup(ctrl, &c->redirecting.to); + q931_party_id_fixup(ctrl, &c->redirecting.orig_called); + } + if (req->called) { c->called_number.valid = 1; c->called_number.plan = req->calledplan; From libpri-commits at lists.digium.com Mon Jul 27 16:37:22 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Mon, 27 Jul 2009 21:37:22 -0000 Subject: [libpri-commits] mattf: branch mattf/libpri-1.4-ntptmp r961 - /team/mattf/libpri-1.4-ntptmp/ Message-ID: Author: mattf Date: Mon Jul 27 16:37:19 2009 New Revision: 961 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=961 Log: Provide support for triggering a fake clearing sequence on SETUP messages sent without response Modified: team/mattf/libpri-1.4-ntptmp/q931.c Modified: team/mattf/libpri-1.4-ntptmp/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/mattf/libpri-1.4-ntptmp/q931.c?view=diff&rev=961&r1=960&r2=961 ============================================================================== --- team/mattf/libpri-1.4-ntptmp/q931.c (original) +++ team/mattf/libpri-1.4-ntptmp/q931.c Mon Jul 27 16:37:19 2009 @@ -3275,6 +3275,21 @@ return 0; } +static int pri_internal_clear(void *data); + +/* Fake RELEASE for NT-PTMP initiated SETUPs w/o response */ +static void pri_fake_clearing(void *data) +{ + struct q931_call *c = data; + struct pri *ctrl = c->pri; + if (ctrl->debug & PRI_DEBUG_Q931_STATE) + pri_message(ctrl, DBGHEAD "Timed out waiting for data link re-establishment\n", DBGINFO); + + c->cause = PRI_CAUSE_DESTINATION_OUT_OF_ORDER; + if (pri_internal_clear(c) == Q931_RES_HAVEEVENT) + ctrl->schedev = 1; +} + int q931_hangup(struct pri *ctrl, q931_call *c, int cause) { int disconnect = 1; @@ -3309,7 +3324,15 @@ break; case Q931_CALL_STATE_CALL_INITIATED: if (BRI_NT_PTMP(ctrl)) { - + if (c->pri == PRI_MASTER(ctrl)) { + /* We need to fake a received clearing message in this case... */ + if (c->retranstimer) + pri_schedule_del(ctrl, c->retranstimer); + + c->retranstimer = pri_schedule_event(ctrl, 0, pri_fake_clearing, c); + /* This means that we never got a response from a TEI */ + return 0; + } } /* we sent SETUP */ case Q931_CALL_STATE_OVERLAP_SENDING: From libpri-commits at lists.digium.com Mon Jul 27 19:50:14 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 28 Jul 2009 00:50:14 -0000 Subject: [libpri-commits] rmudgett: branch group/issue14068 r962 - /team/group/issue14068/ Message-ID: Author: rmudgett Date: Mon Jul 27 19:50:10 2009 New Revision: 962 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=962 Log: Added subaddress place holder support to protect future ABI compatibility. Modified: team/group/issue14068/libpri.h team/group/issue14068/pri.c team/group/issue14068/pri_facility.c team/group/issue14068/pri_internal.h team/group/issue14068/q931.c Modified: team/group/issue14068/libpri.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/libpri.h?view=diff&rev=962&r1=961&r2=962 ============================================================================== --- team/group/issue14068/libpri.h (original) +++ team/group/issue14068/libpri.h Mon Jul 27 19:50:10 2009 @@ -401,12 +401,44 @@ char str[64]; }; +/*! + * \note This structure is a place holder for possible future subaddress support + * to maintain ABI compatibility. + */ +struct pri_party_subaddress { + /*! \brief TRUE if the subaddress information is valid/present */ + int valid; + /*! + * \brief Subaddress type. + * \details + * nsap(0), + * user_specified(2) + */ + int type; + /*! + * \brief TRUE if odd number of address signals + * \note The odd/even indicator is used when the type of subaddress is + * user_specified and the coding is BCD. + */ + int odd_even_indicator; + /*! \brief Length of the subaddress data */ + int length; + /*! + * \brief Subaddress data with null terminator. + * \note The null terminator is a convenience only since the data could be + * BCD/binary and thus have a null byte as part of the contents. + */ + char data[32]; +}; + /*! \brief Information needed to identify an endpoint in a call. */ struct pri_party_id { /*! \brief Subscriber name */ struct pri_party_name name; /*! \brief Subscriber phone number */ struct pri_party_number number; + /*! \brief Subscriber subaddress */ + struct pri_party_subaddress subaddress; }; /*! \brief Connected Line/Party information */ @@ -724,13 +756,13 @@ Set non-isdn to non-zero if you are not connecting to ISDN equipment */ int pri_answer(struct pri *pri, q931_call *call, int channel, int nonisdn); -/*! - * \brief Give connected line information to a call +/*! + * \brief Give connected line information to a call * \note Could be used instead of pri_sr_set_caller_party() before calling pri_setup(). */ int pri_connected_line_update(struct pri *pri, q931_call *call, const struct pri_party_connected_line *connected); -/*! +/*! * \brief Give redirection information to a call * \note Could be used instead of pri_sr_set_redirecting_parties() before calling pri_setup(). */ Modified: team/group/issue14068/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri.c?view=diff&rev=962&r1=961&r2=962 ============================================================================== --- team/group/issue14068/pri.c (original) +++ team/group/issue14068/pri.c Mon Jul 27 19:50:10 2009 @@ -746,7 +746,7 @@ /* fall through */ case PRI_SWITCH_QSIG: if (call->redirecting.state != Q931_REDIRECTING_STATE_PENDING_TX_DIV_LEG_3 - || strcmp(call->redirecting.to.number.str, call->called_number.str) != 0) { + || strcmp(call->redirecting.to.number.str, call->called.number.str) != 0) { /* immediately send divertingLegInformation1 APDU */ if (rose_diverting_leg_information1_encode(ctrl, call) || q931_facility(ctrl, call)) { Modified: team/group/issue14068/pri_facility.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_facility.c?view=diff&rev=962&r1=961&r2=962 ============================================================================== --- team/group/issue14068/pri_facility.c (original) +++ team/group/issue14068/pri_facility.c Mon Jul 27 19:50:10 2009 @@ -1757,7 +1757,7 @@ end = enc_qsig_call_rerouting(ctrl, buffer, buffer + sizeof(buffer), call->remote_id.number.str, dest, original ? original : - call->called_number.str, reason); + call->called.number.str, reason); if (!end) { return -1; } Modified: team/group/issue14068/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_internal.h?view=diff&rev=962&r1=961&r2=962 ============================================================================== --- team/group/issue14068/pri_internal.h (original) +++ team/group/issue14068/pri_internal.h Mon Jul 27 19:50:10 2009 @@ -180,12 +180,56 @@ char str[PRI_MAX_NUMBER_LEN]; }; +/*! \brief Maximum subaddress length plus null terminator */ +#define PRI_MAX_SUBADDRESS_LEN (20 + 1) + +#if defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) +struct q931_party_subaddress { + /*! \brief TRUE if the subaddress information is valid/present */ + unsigned char valid; + /*! + * \brief Subaddress type. + * \details + * nsap(0), + * user_specified(2) + */ + unsigned char type; + /*! + * \brief TRUE if odd number of address signals + * \note The odd/even indicator is used when the type of subaddress is + * user_specified and the coding is BCD. + */ + unsigned char odd_even_indicator; + /*! \brief Length of the subaddress data */ + unsigned char length; + /*! + * \brief Subaddress data with null terminator. + * \note The null terminator is a convenience only since the data could be + * BCD/binary and thus have a null byte as part of the contents. + */ + char data[PRI_MAX_SUBADDRESS_LEN]; +}; +#endif /* defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) */ + +struct q931_party_address { + /*! \brief Subscriber phone number */ + struct q931_party_number number; +#if defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) + /*! \brief Subscriber subaddress */ + struct q931_party_subaddress subaddress; +#endif /* defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) */ +}; + /*! \brief Information needed to identify an endpoint in a call. */ struct q931_party_id { /*! \brief Subscriber name */ struct q931_party_name name; /*! \brief Subscriber phone number */ struct q931_party_number number; +#if defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) + /*! \brief Subscriber subaddress */ + struct q931_party_subaddress subaddress; +#endif /* defined(POSSIBLE_FUTURE_SUBADDRESS_SUPPORT) */ }; enum Q931_REDIRECTING_STATE { @@ -383,12 +427,12 @@ struct q931_party_number redirection_number; /*! - * \brief Called party number. - * \note The called_number.str is the accumulated overlap dial digits + * \brief Called party address. + * \note The called.number.str is the accumulated overlap dial digits * and enbloc digits. - * \note The called_number.presentation value is not used. - */ - struct q931_party_number called_number; + * \note The called.number.presentation value is not used. + */ + struct q931_party_address called; int nonisdn; int complete; /* no more digits coming */ int newcall; /* if the received message has a new call reference value */ @@ -403,7 +447,7 @@ int useruserprotocoldisc; char useruserinfo[256]; - char callingsubaddr[256]; /* Calling party subaddress */ + char callingsubaddr[PRI_MAX_SUBADDRESS_LEN]; /* Calling party subaddress */ long aoc_units; /* Advice of Charge Units */ Modified: team/group/issue14068/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=962&r1=961&r2=962 ============================================================================== --- team/group/issue14068/q931.c (original) +++ team/group/issue14068/q931.c Mon Jul 27 19:50:10 2009 @@ -1558,19 +1558,19 @@ return -1; } - call->called_number.valid = 1; - call->called_number.plan = ie->data[0] & 0x7f; + call->called.number.valid = 1; + call->called.number.plan = ie->data[0] & 0x7f; if (msgtype == Q931_SETUP) { - q931_get_number((unsigned char *) call->called_number.str, - sizeof(call->called_number.str), ie->data + 1, len - 3); + q931_get_number((unsigned char *) call->called.number.str, + sizeof(call->called.number.str), ie->data + 1, len - 3); } else if (call->ourcallstate == Q931_CALL_STATE_OVERLAP_RECEIVING) { /* * Since we are receiving overlap digits now, we need to append - * them to any previously received digits in call->called_number.str. + * them to any previously received digits in call->called.number.str. */ - called_len = strlen(call->called_number.str); - called_end = call->called_number.str + called_len; - max_len = (sizeof(call->called_number.str) - 1) - called_len; + called_len = strlen(call->called.number.str); + called_end = call->called.number.str + called_len; + max_len = (sizeof(call->called.number.str) - 1) - called_len; if (max_len < len - 3) { called_len = max_len; } else { @@ -1588,12 +1588,12 @@ { size_t datalen; - if (!call->called_number.valid) { + if (!call->called.number.valid) { return 0; } datalen = strlen(call->overlap_digits); - ie->data[0] = 0x80 | call->called_number.plan; + ie->data[0] = 0x80 | call->called.number.plan; memcpy(ie->data + 1, call->overlap_digits, datalen); return datalen + (1 + 2); } @@ -2940,7 +2940,7 @@ cur->aoc_units = -1; cur->changestatus = -1; q931_party_number_init(&cur->redirection_number); - q931_party_number_init(&cur->called_number); + q931_party_number_init(&cur->called.number); q931_party_id_init(&cur->local_id); q931_party_id_init(&cur->remote_id); q931_party_redirecting_init(&cur->redirecting); @@ -3331,12 +3331,12 @@ /* * Since we are doing overlap dialing now, we need to accumulate - * the digits into call->called_number.str. + * the digits into call->called.number.str. */ - c->called_number.valid = 1; - if (strlen(c->called_number.str) < sizeof(c->called_number.str) - 1) { + c->called.number.valid = 1; + if (strlen(c->called.number.str) < sizeof(c->called.number.str) - 1) { /* There is enough room for the new digit. */ - strcat(c->called_number.str, c->overlap_digits); + strcat(c->called.number.str, c->overlap_digits); } return send_message(ctrl, c, Q931_INFORMATION, information_ies); @@ -3783,10 +3783,10 @@ } if (req->called) { - c->called_number.valid = 1; - c->called_number.plan = req->calledplan; - libpri_copy_string(c->called_number.str, req->called, - sizeof(c->called_number.str)); + c->called.number.valid = 1; + c->called.number.plan = req->calledplan; + libpri_copy_string(c->called.number.str, req->called, + sizeof(c->called.number.str)); libpri_copy_string(c->overlap_digits, req->called, sizeof(c->overlap_digits)); } else return -1; @@ -4033,7 +4033,7 @@ c->userl3 = -1; c->rateadaption = -1; - q931_party_number_init(&c->called_number); + q931_party_number_init(&c->called.number); q931_party_id_init(&c->local_id); q931_party_id_init(&c->remote_id); q931_party_redirecting_init(&c->redirecting); @@ -4435,8 +4435,8 @@ c->redirecting.to.number.valid = 1; c->redirecting.to.number.presentation = PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED; - c->redirecting.to.number.plan = c->called_number.plan; - libpri_copy_string(c->redirecting.to.number.str, c->called_number.str, + c->redirecting.to.number.plan = c->called.number.plan; + libpri_copy_string(c->redirecting.to.number.str, c->called.number.str, sizeof(c->redirecting.to.number.str)); } @@ -4463,8 +4463,8 @@ ctrl->ev.ring.ani2 = c->ani2; /* Called party information */ - ctrl->ev.ring.calledplan = c->called_number.plan; - libpri_copy_string(ctrl->ev.ring.callednum, c->called_number.str, sizeof(ctrl->ev.ring.callednum)); + ctrl->ev.ring.calledplan = c->called.number.plan; + libpri_copy_string(ctrl->ev.ring.callednum, c->called.number.str, sizeof(ctrl->ev.ring.callednum)); /* Original called party information (For backward compatibility) */ libpri_copy_string(ctrl->ev.ring.origcalledname, c->redirecting.orig_called.name.str, sizeof(ctrl->ev.ring.origcalledname)); From libpri-commits at lists.digium.com Tue Jul 28 11:29:31 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 28 Jul 2009 16:29:31 -0000 Subject: [libpri-commits] rmudgett: branch group/issue14292 r964 - /team/group/issue14292/pri_facility.c Message-ID: Author: rmudgett Date: Tue Jul 28 11:29:26 2009 New Revision: 964 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=964 Log: Fixed compile error from subaddress place holder changes. Modified: team/group/issue14292/pri_facility.c Modified: team/group/issue14292/pri_facility.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14292/pri_facility.c?view=diff&rev=964&r1=963&r2=964 ============================================================================== --- team/group/issue14292/pri_facility.c (original) +++ team/group/issue14292/pri_facility.c Tue Jul 28 11:29:26 2009 @@ -2457,9 +2457,9 @@ q931_copy_presented_number_unscreened_to_rose(ctrl, &msg.args.qsig.CcbsRequest.number_a, &call->local_id.number); - /* numberB is the called_number */ + /* numberB is the called.number */ q931_copy_number_to_rose(ctrl, &msg.args.qsig.CcbsRequest.number_b, - &call->called_number); + &call->called.number); msg.args.qsig.CcbsRequest.q931ie.length = sizeof(q931ie); memcpy(msg.args.qsig.CcbsRequest.q931ie_contents, q931ie, sizeof(q931ie)); From libpri-commits at lists.digium.com Tue Jul 28 14:17:43 2009 From: libpri-commits at lists.digium.com (SVN commits to the libpri project) Date: Tue, 28 Jul 2009 19:17:43 -0000 Subject: [libpri-commits] rmudgett: branch group/issue14068 r965 - /team/group/issue14068/ Message-ID: Author: rmudgett Date: Tue Jul 28 14:17:39 2009 New Revision: 965 URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=965 Log: Added more called party address support for possible future subaddress. * Added needed q931_party_address support like q931_party_id support. * Collected the called party information in pri_sr into a q931_party_address. This simplified the code that uses the called party information. * Simplified the Q.SIG and ETSI PRI/BRI-PTP REDIRECTING(to-) setup for DivertingLegInformation3 control. Modified: team/group/issue14068/pri.c team/group/issue14068/pri_facility.c team/group/issue14068/pri_internal.h team/group/issue14068/q931.c Modified: team/group/issue14068/pri.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri.c?view=diff&rev=965&r1=964&r2=965 ============================================================================== --- team/group/issue14068/pri.c (original) +++ team/group/issue14068/pri.c Tue Jul 28 14:17:39 2009 @@ -902,6 +902,7 @@ memset(req, 0, sizeof(struct pri_sr)); q931_party_redirecting_init(&req->redirecting); q931_party_id_init(&req->caller); + q931_party_address_init(&req->called); req->reversecharge = PRI_REVERSECHARGE_NONE; } @@ -1187,8 +1188,12 @@ int pri_sr_set_called(struct pri_sr *sr, char *called, int calledplan, int numcomplete) { - sr->called = called; - sr->calledplan = calledplan; + q931_party_address_init(&sr->called); + if (called) { + sr->called.number.valid = 1; + sr->called.number.plan = calledplan; + libpri_copy_string(sr->called.number.str, called, sizeof(sr->called.number.str)); + } sr->numcomplete = numcomplete; return 0; } Modified: team/group/issue14068/pri_facility.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_facility.c?view=diff&rev=965&r1=964&r2=965 ============================================================================== --- team/group/issue14068/pri_facility.c (original) +++ team/group/issue14068/pri_facility.c Tue Jul 28 14:17:39 2009 @@ -1464,11 +1464,14 @@ msg.operation = ROSE_QSIG_MWIActivate; msg.invoke_id = get_invokeid(ctrl); + /* The called.number is the served user */ + q931_copy_number_to_rose(ctrl, &msg.args.qsig.MWIActivate.served_user_number, + &req->called.number); + /* + * For now, we will just force the numbering plan to unknown to preserve + * the original behaviour. + */ msg.args.qsig.MWIActivate.served_user_number.plan = 0; /* unknown */ - libpri_copy_string((char *) msg.args.qsig.MWIActivate.served_user_number.str, - req->called, sizeof(msg.args.qsig.MWIActivate.served_user_number.str)); - msg.args.qsig.MWIActivate.served_user_number.length = strlen((char *) - msg.args.qsig.MWIActivate.served_user_number.str); msg.args.qsig.MWIActivate.basic_service = 1; /* speech */ @@ -1510,11 +1513,14 @@ msg.operation = ROSE_QSIG_MWIDeactivate; msg.invoke_id = get_invokeid(ctrl); + /* The called.number is the served user */ + q931_copy_number_to_rose(ctrl, &msg.args.qsig.MWIDeactivate.served_user_number, + &req->called.number); + /* + * For now, we will just force the numbering plan to unknown to preserve + * the original behaviour. + */ msg.args.qsig.MWIDeactivate.served_user_number.plan = 0; /* unknown */ - libpri_copy_string((char *) msg.args.qsig.MWIDeactivate.served_user_number.str, - req->called, sizeof(msg.args.qsig.MWIDeactivate.served_user_number.str)); - msg.args.qsig.MWIDeactivate.served_user_number.length = strlen((char *) - msg.args.qsig.MWIDeactivate.served_user_number.str); msg.args.qsig.MWIDeactivate.basic_service = 1; /* speech */ @@ -1539,7 +1545,7 @@ unsigned char buffer[255]; unsigned char *end; - if (!req->called || !req->called[0]) { + if (!req->called.number.valid || !req->called.number.str[0]) { return -1; } Modified: team/group/issue14068/pri_internal.h URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_internal.h?view=diff&rev=965&r1=964&r2=965 ============================================================================== --- team/group/issue14068/pri_internal.h (original) +++ team/group/issue14068/pri_internal.h Tue Jul 28 14:17:39 2009 @@ -289,8 +289,7 @@ int nonisdn; struct q931_party_redirecting redirecting; struct q931_party_id caller; - char *called; - int calledplan; + struct q931_party_address called; int userl1; int numcomplete; int justsignalling; @@ -485,6 +484,7 @@ void q931_party_name_init(struct q931_party_name *name); void q931_party_number_init(struct q931_party_number *number); +void q931_party_address_init(struct q931_party_address *address); void q931_party_id_init(struct q931_party_id *id); void q931_party_redirecting_init(struct q931_party_redirecting *redirecting); Modified: team/group/issue14068/q931.c URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=965&r1=964&r2=965 ============================================================================== --- team/group/issue14068/q931.c (original) +++ team/group/issue14068/q931.c Tue Jul 28 14:17:39 2009 @@ -294,6 +294,18 @@ number->presentation = PRI_PRES_UNAVAILABLE | PRI_PRES_USER_NUMBER_UNSCREENED; number->plan = (PRI_TON_UNKNOWN << 4) | PRI_NPI_E163_E164; number->str[0] = '\0'; +} + +/*! + * \brief Initialize the given struct q931_party_address + * + * \param address Structure to initialize + * + * \return Nothing + */ +void q931_party_address_init(struct q931_party_address *address) +{ + q931_party_number_init(&address->number); } /*! @@ -2940,7 +2952,7 @@ cur->aoc_units = -1; cur->changestatus = -1; q931_party_number_init(&cur->redirection_number); - q931_party_number_init(&cur->called.number); + q931_party_address_init(&cur->called); q931_party_id_init(&cur->local_id); q931_party_id_init(&cur->remote_id); q931_party_redirecting_init(&cur->redirecting); @@ -3782,12 +3794,9 @@ q931_party_id_fixup(ctrl, &c->redirecting.orig_called); } - if (req->called) { - c->called.number.valid = 1; - c->called.number.plan = req->calledplan; - libpri_copy_string(c->called.number.str, req->called, - sizeof(c->called.number.str)); - libpri_copy_string(c->overlap_digits, req->called, sizeof(c->overlap_digits)); + if (req->called.number.valid) { + c->called = req->called; + libpri_copy_string(c->overlap_digits, req->called.number.str, sizeof(c->overlap_digits)); } else return -1; @@ -4033,7 +4042,7 @@ c->userl3 = -1; c->rateadaption = -1; - q931_party_number_init(&c->called.number); + q931_party_address_init(&c->called); q931_party_id_init(&c->local_id); q931_party_id_init(&c->remote_id); q931_party_redirecting_init(&c->redirecting); @@ -4431,13 +4440,9 @@ * incoming call was redirected by checking if the * REDIRECTING(count) is nonzero. */ - q931_party_number_init(&c->redirecting.to.number); - c->redirecting.to.number.valid = 1; + c->redirecting.to.number = c->called.number; c->redirecting.to.number.presentation = PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED; - c->redirecting.to.number.plan = c->called.number.plan; - libpri_copy_string(c->redirecting.to.number.str, c->called.number.str, - sizeof(c->redirecting.to.number.str)); } ctrl->ev.e = PRI_EVENT_RING;