CALLERID(pres) on isdn lines

I’m trying to figure out how to set the presentation number (not the callerpres) on an outgoing channel,
and how to read the proper CALLERID(pres) from an incoming channel.
My setup consists in a sangoma card and asterisk 11.15.

I did a trace on the sangoma card as explained in and I see I receive the following data from the provider:
cli: 0123456789
cli_flag: 0x0313
cli_pres: 0123456789
cli_pres_flag: 0x0313

when I retrieve CALLERID(pres) in the dialplan it returns “allowed_not_screened”, but that’s wrong, value should be “allowed”.
Also, cli and cli_pres can be different, how can I read/write them?

When in the dialplan I do
Set(VAR0=${CALLERID(num)}); 0123456789
Set(VAR1=${CALLERID(pres)}); allowed_not_screened instead of allowed
… agi that might modify VAR0 and VAR1, and set also VAR2 …
Set(CALLERID(all)="$VAR0 <$VAR0>")

the call goes back out on a dahdi channel and my card receives:
cli: 0123456789
cli_flag: 0x0310
cli_pres_flag: 0x0200

so cli_flag get’s incorrectly readen (I can tell the agi to correct the value, but would be better for me to fix my configuration), and cli_pres never gets set.

if the call comes with a different cli_flag, for example 0x317, it gets correctly read as prohib.

I’m sure this problem could be explained better, but I hope someone can put me in the right direction.

Thanks all