I have menchioned this on irc few months back but never got a chance to submit the actual code it is not full patch but the code should work, as i was using it before installing freePBX almost as i am senting it here
incoming context (FORWARD_EXTERNAL_CALLERID (check box) LINE_NAME and LINE_NUM should be added to Inbound Routes page, so if someone needs to know that this call was transfered by * and from which line
exten => 2125551212,1,GotoIf($[${ISNULL(${FORWARD_EXTERNAL_CALLERID})}]?5) # check to see if we want to forward the call with incoming CID or our line CID
exten => 2125551212,2,Set(EXTERNAL_CALLERIDNUM="${LINE_NUM}-${CALLERIDNUM}") # set the var with LINE_NUM as prefix then incoming CID
exten => 2125551212,3,Set(EXTERNAL_CALLERIDNAME="${LINE_NAME} ${CALLERIDNAME}") # do the same for CID name
exten => 2125551212,4. Goto(7) # skip the rest
exten => 2125551212,1,GotoIf($[${ISNULL(${LINE_NUM})}]?7) # if no LINE_NUM is set then there is no prefix so don't set EXTERNAL_CALLERID* (this is the current freePBX setup) so calles will use trunk CID info
exten => 2125551212,5,Set(EXTERNAL_CALLERIDNUM="${LINE_NUM}") # set the var with LINE_NUM as full number
exten => 2125551212,6,Set(EXTERNAL_CALLERIDNAME="${LINE_NAME}") # do the same for CID name
exten => 2125551212,6,Answer() #or whatever the normaly freePBX does...
outgoing context (FORCE_CID (check box) should be added to trunk to specify if the CID can be changed or not
...
exten => s,10,GotoIf($[${ISNULL(${FORCE_CID})}]?12) # check if this trunk allows changing of CID or not
exten => s,10,GotoIf($[${ISNULL(${EXTERNAL_CALLERIDNUM})}]?12) # check if we have EXTERNAL_CALLERIDNUM set (it will never be set for all calls that are coming from local context) see above as to when it will/will not be set
exten => s,11,SetCallerID("${EXTERNAL_CALLERIDNAME}" <${EXTERNAL_CALLERIDNUM}>) # change CID
exten => s,12, Dial(...) #do the dial thing