+#ifdef AST_1_8_OR_HIGHER
+// clone_variables(requestor, ast);
+
+#if 0
+ ast->caller.ani.number.valid= requestor->caller.ani.number.valid;
+ if (requestor->caller.ani.number.valid)
+ if (requestor->caller.ani.number.str)
+ if (requestor->caller.ani.number.str[0])
+ ast->caller.ani.number.str= strdup(requestor->caller.ani.number.str);
+ ast->caller.ani.number.plan= requestor->caller.ani.number.plan;
+ ast->caller.ani.number.presentation= requestor->caller.ani.number.presentation;
+
+ ast->caller.ani.name.valid= requestor->caller.ani.name.valid;
+ if (requestor->caller.ani.name.valid)
+ if (requestor->caller.ani.name.str)
+ if (requestor->caller.ani.name.str[0])
+ ast->caller.ani.name.str= strdup(requestor->caller.ani.name.str);
+ ast->caller.ani.name.presentation= requestor->caller.ani.name.presentation;
+
+ ast->caller.ani.subaddress.valid= requestor->caller.ani.subaddress.valid;
+ if (requestor->caller.ani.subaddress.valid)
+ if (requestor->caller.ani.subaddress.str)
+ if (requestor->caller.ani.subaddress.str[0])
+ ast->caller.ani.subaddress.str= strdup(requestor->caller.ani.subaddress.str);
+ ast->caller.ani.subaddress.type= requestor->caller.ani.subaddress.type;
+
+ ast->caller.id.number.valid= requestor->caller.id.number.valid;
+ if (requestor->caller.id.number.valid)
+ if (requestor->caller.id.number.str)
+ if (requestor->caller.id.number.str[0])
+ ast->caller.id.number.str= strdup(requestor->caller.id.number.str);
+ ast->caller.id.number.plan= requestor->caller.id.number.plan;
+ ast->caller.id.number.presentation= requestor->caller.id.number.presentation;
+
+ ast->caller.id.name.valid= requestor->caller.id.name.valid;
+ if (requestor->caller.id.name.valid)
+ if (requestor->caller.id.name.str)
+ if (requestor->caller.id.name.str[0])
+ ast->caller.id.name.str= strdup(requestor->caller.id.name.str);
+ ast->caller.id.name.presentation= requestor->caller.id.name.presentation;
+
+ ast->caller.id.subaddress.valid= requestor->caller.id.subaddress.valid;
+ if (requestor->caller.id.subaddress.valid)
+ if (requestor->caller.id.subaddress.str)
+ if (requestor->caller.id.subaddress.str[0])
+ ast->caller.id.subaddress.str= strdup(requestor->caller.id.subaddress.str);
+ ast->caller.id.subaddress.type= requestor->caller.id.subaddress.type;
+
+ if (requestor->dialed.number.str)
+ if (requestor->dialed.number.str[0])
+ ast->dialed.number.str= strdup(requestor->dialed.number.str);
+ ast->dialed.number.plan= requestor->dialed.number.plan;
+
+ ast->dialed.subaddress.valid= requestor->dialed.subaddress.valid;
+ if (requestor->dialed.subaddress.valid)
+ if (requestor->dialed.subaddress.str)
+ if (requestor->dialed.subaddress.str[0])
+ ast->dialed.subaddress.str= strdup(requestor->dialed.subaddress.str);
+ ast->dialed.subaddress.type= requestor->dialed.subaddress.type;
+
+ ast->dialed.transit_network_select= requestor->dialed.transit_network_select;
+ ast->redirecting.count= requestor->redirecting.count;
+ ast->redirecting.reason= requestor->redirecting.reason;
+
+ ast->redirecting.from.number.valid= requestor->redirecting.from.number.valid;
+ if (requestor->redirecting.from.number.valid)
+ if (requestor->redirecting.from.number.str)
+ if (requestor->redirecting.from.number.str[0])
+ ast->redirecting.from.number.str= strdup(requestor->redirecting.from.number.str);
+ ast->redirecting.from.number.plan= requestor->redirecting.from.number.plan;
+ ast->redirecting.from.number.presentation= requestor->redirecting.from.number.presentation;
+
+ ast->redirecting.to.number.valid= requestor->redirecting.to.number.valid;
+ if (requestor->redirecting.to.number.valid)
+ if (requestor->redirecting.to.number.str)
+ if (requestor->redirecting.to.number.str[0])
+ ast->redirecting.to.number.str= strdup(requestor->redirecting.to.number.str);
+ ast->redirecting.to.number.plan= requestor->redirecting.to.number.plan;
+ ast->redirecting.to.number.presentation= requestor->redirecting.to.number.presentation;
+#endif
+ /* store call information for setup */
+
+ /* caller ID */
+ if (requestor->caller.id.number.valid) {
+ if (requestor->caller.id.number.str)
+ strncpy(call->callerinfo.id, requestor->caller.id.number.str, sizeof(call->callerinfo.id)-1);
+ switch(requestor->caller.id.number.presentation & AST_PRES_RESTRICTION) {
+ case AST_PRES_RESTRICTED:
+ call->callerinfo.present = INFO_PRESENT_RESTRICTED;
+ break;
+ case AST_PRES_UNAVAILABLE:
+ call->callerinfo.present = INFO_PRESENT_NOTAVAIL;
+ break;
+ case AST_PRES_ALLOWED:
+ default:
+ call->callerinfo.present = INFO_PRESENT_ALLOWED;
+ }
+ switch(requestor->caller.id.number.presentation & AST_PRES_NUMBER_TYPE) {
+ case AST_PRES_USER_NUMBER_UNSCREENED:
+ call->callerinfo.screen = INFO_SCREEN_USER;
+ break;
+ case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+ call->callerinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
+ break;
+ case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+ call->callerinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
+ break;
+ default:
+ call->callerinfo.screen = INFO_SCREEN_NETWORK;
+ }
+ switch((requestor->caller.id.number.plan >> 4) & 7) {
+ case 4:
+ call->callerinfo.ntype = INFO_NTYPE_SUBSCRIBER;
+ break;
+ case 2:
+ call->callerinfo.ntype = INFO_NTYPE_NATIONAL;
+ break;
+ case 1:
+ call->callerinfo.ntype = INFO_NTYPE_INTERNATIONAL;
+ break;
+ default:
+ call->callerinfo.ntype = INFO_NTYPE_UNKNOWN;
+ }
+ } else
+ call->callerinfo.present = INFO_PRESENT_NOTAVAIL;
+
+ /* caller ID 2 */
+ if (requestor->caller.ani.number.valid) {
+ if (requestor->caller.ani.number.str)
+ strncpy(call->callerinfo.id2, requestor->caller.ani.number.str, sizeof(call->callerinfo.id2)-1);
+ switch(requestor->caller.ani.number.presentation & AST_PRES_RESTRICTION) {
+ case AST_PRES_RESTRICTED:
+ call->callerinfo.present2 = INFO_PRESENT_RESTRICTED;
+ break;
+ case AST_PRES_UNAVAILABLE:
+ call->callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
+ break;
+ case AST_PRES_ALLOWED:
+ default:
+ call->callerinfo.present2 = INFO_PRESENT_ALLOWED;
+ }
+ switch(requestor->caller.ani.number.presentation & AST_PRES_NUMBER_TYPE) {
+ case AST_PRES_USER_NUMBER_UNSCREENED:
+ call->callerinfo.screen2 = INFO_SCREEN_USER;
+ break;
+ case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+ call->callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_PASSED;
+ break;
+ case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+ call->callerinfo.screen2 = INFO_SCREEN_USER_VERIFIED_FAILED;
+ break;
+ default:
+ call->callerinfo.screen2 = INFO_SCREEN_NETWORK;
+ }
+ switch((requestor->caller.ani.number.plan >> 4) & 7) {
+ case 4:
+ call->callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER;
+ break;
+ case 2:
+ call->callerinfo.ntype2 = INFO_NTYPE_NATIONAL;
+ break;
+ case 1:
+ call->callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL;
+ break;
+ default:
+ call->callerinfo.ntype2 = INFO_NTYPE_UNKNOWN;
+ }
+ } else
+ call->callerinfo.present2 = INFO_PRESENT_NOTAVAIL;
+
+ /* caller name */
+ if (requestor->caller.id.name.valid) {
+ if (requestor->caller.id.name.str)
+ strncpy(call->callerinfo.name, requestor->caller.id.name.str, sizeof(call->callerinfo.name)-1);
+ }
+
+ /* redir number */
+ if (requestor->redirecting.from.number.valid) {
+ call->redirinfo.itype = INFO_ITYPE_CHAN;
+ if (requestor->redirecting.from.number.str)
+ strncpy(call->redirinfo.id, requestor->redirecting.from.number.str, sizeof(call->redirinfo.id)-1);
+ switch(requestor->redirecting.from.number.presentation & AST_PRES_RESTRICTION) {
+ case AST_PRES_RESTRICTED:
+ call->redirinfo.present = INFO_PRESENT_RESTRICTED;
+ break;
+ case AST_PRES_UNAVAILABLE:
+ call->redirinfo.present = INFO_PRESENT_NOTAVAIL;
+ break;
+ case AST_PRES_ALLOWED:
+ default:
+ call->redirinfo.present = INFO_PRESENT_ALLOWED;
+ }
+ switch(requestor->redirecting.from.number.presentation & AST_PRES_NUMBER_TYPE) {
+ case AST_PRES_USER_NUMBER_UNSCREENED:
+ call->redirinfo.screen = INFO_SCREEN_USER;
+ break;
+ case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+ call->redirinfo.screen = INFO_SCREEN_USER_VERIFIED_PASSED;
+ break;
+ case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+ call->redirinfo.screen = INFO_SCREEN_USER_VERIFIED_FAILED;
+ break;
+ default:
+ call->redirinfo.screen = INFO_SCREEN_NETWORK;
+ }
+ switch((requestor->redirecting.from.number.plan >> 4) & 7) {
+ case 4:
+ call->redirinfo.ntype = INFO_NTYPE_SUBSCRIBER;
+ break;
+ case 2:
+ call->redirinfo.ntype = INFO_NTYPE_NATIONAL;
+ break;
+ case 1:
+ call->redirinfo.ntype = INFO_NTYPE_INTERNATIONAL;
+ break;
+ default:
+ call->redirinfo.ntype = INFO_NTYPE_UNKNOWN;
+ }
+ }
+#endif
+