SIP trunking without fromuser and register


I’m using Asterisk Realtime SIP with PstgreSQL database. I have SQL table sip_conf with the following format:

id serial NOT NULL,
“name” character varying(80) NOT NULL DEFAULT ‘’::character varying,
host character varying(31) NOT NULL DEFAULT ‘’::character varying,
nat character varying(5) NOT NULL DEFAULT ‘no’::character varying,
“type” character varying(255) NOT NULL DEFAULT ‘friend’::character varying,
accountcode character varying(20),
amaflags character varying(13),
callgroup character varying(10),
callerid character varying(80),
cancallforward character(3) DEFAULT ‘yes’::bpchar,
canreinvite character(6) DEFAULT ‘yes’::bpchar,
context character varying(80),
defaultip character varying(15),
dtmfmode character varying(7),
fromuser character varying(80),
fromdomain character varying(80),
insecure character varying(10),
“language” character(2),
mailbox character varying(50),
md5secret character varying(80),
deny character varying(95),
permit character varying(95),
mask character varying(95),
musicclass character varying(100),
pickupgroup character varying(10),
qualify character(3),
regexten character varying(80),
restrictcid character(3),
rtptimeout character(3),
rtpholdtimeout character(3),
secret character varying(80),
setvar character varying(100),
disallow character varying(100) DEFAULT ‘all’::character varying,
allow character varying(100) DEFAULT ‘alaw;ulaw;gsm;g729’::character varying,
fullcontact character varying(80) NOT NULL DEFAULT ‘’::character varying,
ipaddr character varying(15) NOT NULL DEFAULT ‘’::character varying,
port character varying(5) NOT NULL DEFAULT 5060,
regserver character varying(100),
username character varying(80) NOT NULL DEFAULT ‘’::character varying,
regseconds character varying(10),
lastms character varying(10),
siptype smallint DEFAULT 0,
CONSTRAINT sip_conf_pkey PRIMARY KEY (id),
CONSTRAINT sip_conf_type_check CHECK (“type”::text = ‘user’::text OR “type”::text = ‘peer’::text OR “type”::text = ‘friend’::text)
ALTER TABLE sip_conf OWNER TO asterisk;

I want to create separate trunks for incoming an outgoing calls from/to other asterisk servers. Each trunk has its own user and password. I don’t want to use the register and fromuser options because:
register can’t be used because I want to use only the SQL table
fromuser can’t be used because I don’t want to override the callerid

Here is an example of what I want to have (I’m not writing the exact syntax, only for illustration purpose):
------Server A------


------Server B------


So I want:
333@ServerB calls 123@ServerA through server_b_outgoing_trunk (e.g. _9X.,1,Dial(SIP/server_b_outgoing_trunk/${EXTEN:1},Tt) )
extension 123 sees on the display ‘333’ NOT ‘serverA_user1’ (which will be displayed if using fromuser in [server_b_outgoing_trunk] )


I found a way to send the original Caller ID.

For outgoing connection(peer) there should be sendrpid=yes
For incoming connection(user) there should be trustrpid=yes

However I have other problem. I have qualify=yes and rtcachefriends=on but when I do “sip show peers” for status on my peers I see Unknown, they are working but somehow the qualify=yes isn’t and it so only for trunks. SIP extensions are OK.