+ union parameter newparam;
+ char string[1024], *p = string, *opt, *key;
+ int gain, i, newmode = 0;
+
+ strncpy(string, data, sizeof(string)-1);
+ string[sizeof(string)-1] = '\0';
+
+ /* parse options */
+ while((opt = strsep(&p, ":")))
+ {
+ switch(opt[0]) {
+ case 'd':
+ if (opt[1] == '\0') {
+ CERROR(call, call->ast, "Option 'd' (display) expects parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'd' (display) with text '%s'.\n", opt+1);
+ if (call->state == CHAN_LCR_STATE_OUT_PREPARE)
+ strncpy(call->display, opt+1, sizeof(call->display)-1);
+ else {
+ memset(&newparam, 0, sizeof(union parameter));
+ strncpy(newparam.notifyinfo.display, opt+1, sizeof(newparam.notifyinfo.display)-1);
+ send_message(MESSAGE_NOTIFY, call->ref, &newparam);
+ }
+ break;
+ case 'n':
+ if (opt[1] != '\0') {
+ CERROR(call, call->ast, "Option 'n' (no DTMF) expects no parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'n' (no DTMF).\n");
+ call->no_dtmf = 1;
+ break;
+ case 'c':
+ if (opt[1] == '\0') {
+ CERROR(call, call->ast, "Option 'c' (encrypt) expects key parameter.\n", opt);
+ break;
+ }
+ key = opt+1;
+ /* check for 0xXXXX... type of key */
+ if (!!strncmp((char *)key, "0x", 2)) {
+ CERROR(call, call->ast, "Option 'c' (encrypt) expects key parameter starting with '0x'.\n", opt);
+ break;
+ }
+ key+=2;
+ if (strlen(key) > 56*2 || (strlen(key) % 1)) {
+ CERROR(call, call->ast, "Option 'c' (encrypt) expects key parameter with max 56 bytes ('0x' + 112 characters)\n", opt);
+ break;
+ }
+ i = 0;
+ while(*key)
+ {
+ if (*key>='0' && *key<='9')
+ call->bf_key[i] = (*key-'0') << 8;
+ else if (*key>='a' && *key<='f')
+ call->bf_key[i] = (*key-'a'+10) << 8;
+ else if (*key>='A' && *key<='F')
+ call->bf_key[i] = (*key-'A'+10) << 8;
+ else
+ break;
+ key++;
+ if (*key>='0' && *key<='9')
+ call->bf_key[i] += (*key - '0');
+ else if (*key>='a' && *key<='f')
+ call->bf_key[i] += (*key - 'a' + 10);
+ else if (*key>='A' && *key<='F')
+ call->bf_key[i] += (*key - 'A' + 10);
+ else
+ break;
+ key++;
+ i++;
+ }
+ if (*key) {
+ CERROR(call, call->ast, "Option 'c' (encrypt) expects key parameter with hex values 0-9,a-f.\n");
+ break;
+ }
+ call->bf_len = i;
+ CDEBUG(call, call->ast, "Option 'c' (encrypt) blowfish key '%s' (len=%d).\n", opt+1, i);
+ if (call->bchannel)
+ bchannel_blowfish(call->bchannel, call->bf_key, call->bf_len);
+ break;
+ case 'h':
+ if (opt[1] != '\0') {
+ CERROR(call, call->ast, "Option 'h' (HDLC) expects no parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'h' (HDLC).\n");
+ if (!call->hdlc) {
+ call->hdlc = 1;
+ newmode = 1;
+ }
+ break;
+ case 't':
+ if (opt[1] != '\0') {
+ CERROR(call, call->ast, "Option 't' (transparent) expects no parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 't' (transparent).\n");
+ if (!call->transparent) {
+ call->transparent = 1;
+ newmode = 1;
+ }
+ break;
+ case 'e':
+ if (opt[1] == '\0') {
+ CERROR(call, call->ast, "Option 'e' (echo cancel) expects parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'e' (echo cancel) with config '%s'.\n", opt+1);
+ strncpy(call->pipeline, opt+1, sizeof(call->pipeline)-1);
+ if (call->bchannel)
+ bchannel_pipeline(call->bchannel, call->pipeline);
+ break;
+#if 0
+ case 's':
+ if (opt[1] != '\0') {
+ CERROR(call, call->ast, "Option 's' (inband DTMF) expects no parameter.\n", opt);
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 's' (inband DTMF).\n");
+ call->inband_dtmf = 1;
+todo
+ break;
+#endif
+ case 'v':
+ if (opt[1] != 'r' && opt[1] != 't') {
+ CERROR(call, call->ast, "Option 'v' (volume) expects parameter.\n", opt);
+ break;
+ }
+ gain = atoi(opt+2);
+ if (gain < -8 || gain >8) {
+ CERROR(call, call->ast, "Option 'v' (volume) expects parameter in range of -8 through 8.\n");
+ break;
+ }
+ CDEBUG(call, call->ast, "Option 'v' (volume) with gain 2^%d.\n", gain);
+ if (opt[1] == 'r') {
+ call->rx_gain = gain;
+ if (call->bchannel)
+ bchannel_gain(call->bchannel, call->rx_gain, 0);
+ } else {
+ call->tx_gain = gain;
+ if (call->bchannel)
+ bchannel_gain(call->bchannel, call->tx_gain, 1);
+ }
+ break;
+ default:
+ CERROR(call, call->ast, "Option '%s' unknown.\n", opt);
+ }
+ }
+
+ /* re-open, if bchannel is created */
+ if (call->bchannel && call->bchannel->b_sock > -1) {
+ bchannel_destroy(call->bchannel);
+ if (bchannel_create(call->bchannel, ((call->transparent)?1:0) + ((call->hdlc)?2:0)))
+ bchannel_activate(call->bchannel, 1);
+ }