System information
Input parameters:
@calledat TINYINT, /*1=first check, 2=after authentication, 3=before routing out, 4=after routing out*/
@protocoll TINYINT, /*0=SIP, 1=H323, 2=GSM, 3=Other*/
@fromip varchar(22), /*caller ip address*/
@fromport SMALLINT, /*caller port*/
@callerid int, /*caller device database id from tb_users*/
@callernumber varchar(35), /*caller number or sip username*/
@callername varchar(35), /*caller name or displayname*/
@calledid INT, /*called device database id from tb_users*/
@origcallednumber varchar(35), /*called number as received*/
@techprefix VARCHAR(10), /*called number tech prefix*/
@normcallednumber varchar(35) /*normalized (changed) called number*/
The stored procedure can be called at different routing stage:
1: before authentication
2: after auth
3: before routing
4: after routing
This means that if a number has efect on authentication then you can rewrite it on stage 1, but if you need to modify the called number only for the b-leg call then it is
better to call this function only at stage 4
Some of the input values are not set at earlier stage. For example when calledat is 1 then the callerid will be 0 because the caller is still not known at this
stage.
Usually only the called number have to be rewritten, but you can also change the other values.
Accepted output values:
-emty string: no effect
-_REJECT: will disconnect the call
-_REJECTPLAY,filename: play a file and disconnect the call
-callednumber: will change the called number
-callednumber,calleddialed,origcallednumber,techprefix,callernumber,callerid,calledid
Field details:
-Callednumber: will be used for further routing decisions, for billing purposes and it is stored in CDR record
-Calleddialed: will be used only for b-leg
-Origcallednumber: can be used for further routing decision (mostly not used)
-Techprefix: can be used for further routing decision. Deprecated after version 3.5
-Callernumber: can be used for further routing decision and stored in CDR record
-Callerid: you can modify the caller user if you change this parameter
-Calledid: you can modify the called user if you change this parameter










