I have figured out a solution to the problem in my last post of this thread but it requires a minor addition to the pjsip library. In particular, I need a function pjsip_tdata_get_dlg() that is similar to the pjsip_rdata_get_dlg() function, but that works on tdatas. This is very useful to use from inside a module to know if a particular outgoing request/response should be modified based on it belonging to a dialog. I have attached a patch that implements this feature. I would be happy if someone from the pjsip team could review it and apply it if they think it makes sense. Best Regards, Kal On Wed, Aug 24, 2016 at 4:38 PM, b17 c0de <b17c0de@xxxxxxxxx> wrote: > Hi Johan, > Thanks so much!!! > > I implemented a module with priority PJSIP_MOD_PRIORITY_TRANSPORT_LAYER+1 to > modify the headers and it works perfectly. > > However, now I have the issue that I only want modify messages of certain > calls. Some calls in my process are normal SIP calls, and some will be using > a custom transport adapter and relying on this new sip module. How can I > know from the sip module what kind of call this is? Is there a way to flag > the call by adding some custom attributes to it? Or is there a way to loop > through all the attached transport adapters on a call and see if it is > attached and get state from it? > > Kal > > On Tue, Aug 23, 2016 at 9:51 PM, JOHAN LANTZ <johan.lantz@xxxxxxxxxxxxxx> > wrote: >> >> If it was only for calls and messages for instance you could use msg_data >> but if you want something that automatically works for all messages you can >> use a pjsip module. >> >> You can check here for how I use it in another scenario: >> https://github.com/johanlantz/pj-nat64 >> >> If you place a module for instance at PJSIP_MOD_PRIORITY_TRANSPORT_LAYER+1 >> you can use it to add or manipulate headers in all directions. >> >> Johan >> >> >> >> >> >> >> From: pjsip on behalf of b17 c0de >> Reply-To: pjsip list >> Date: Tuesday 23 August 2016 at 20:19 >> To: pjsip list >> Subject: Re: [pjsua] Verify response headers >> >> >> Hi Johan, >> Thanks for the help. I will try to get that working. Related to this, I >> also need to add headers to every SIP request AND response. What is the best >> way to do this with PJSUA? The headers I want to add will be static (same >> for every request/response and >> never changing). Is there a way to do this directly? I also looked >> through the PJSUA callbacks, but I didn't see one that could be used for >> this. Is there a callback mechanism with PJLIB that can be used for this? >> What is the easiest way? >> >> Kal >> >> >> On Mon, Aug 22, 2016 at 11:04 PM, JOHAN LANTZ >> <johan.lantz@xxxxxxxxxxxxxx> wrote: >> >> Check for >> case PJSIP_INV_STATE_CONNECTING: >> >> >> >> >> In the: >> >> on_call_state >> >> callback. >> >> Inside the pjsip_event you have access to the full rdata struct where you >> can check all the headers. >> >> Johan >> >> >> From: pjsip on behalf of b17 c0de >> Reply-To: pjsip list >> Date: Monday 22 August 2016 at 22:10 >> To: pjsip list >> Subject: Re: [pjsua] Verify response headers >> >> >> To explain my question in more detail: >> >> (1) Client --[INVITE]--> Server >> (2) Client <--[TRYING]-- Server >> (3) Client <--[OK/200]-- Server >> >> @ Step 3 I need to verify the headers of the 200 response on the client >> side. If the verification fails, I need to end the call immediately. >> >> >> >> >> On Mon, Aug 22, 2016 at 10:03 PM, b17 c0de >> <b17c0de@xxxxxxxxx> wrote: >> >> Hi, >> I would like to check/verify the response headers of a SIP INVITE request. >> If the verification fails I would like to end the call. How can this be done >> in PJSUA? >> >> Thanks, >> Kal >> >> >> >> >> >> >> >> >> >> >> >> ________________________________________ >> >> Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, >> puede contener información privilegiada o confidencial y es para uso >> exclusivo de la persona o entidad de destino. Si no es usted. el >> destinatario indicado, queda notificado de que la >> lectura, utilización, divulgación y/o copia sin autorización puede estar >> prohibida en virtud de la legislación vigente. Si ha recibido este mensaje >> por error, le rogamos que nos lo comunique inmediatamente por esta misma vía >> y proceda a su destrucción. >> >> The information contained in this transmission is privileged and >> confidential information intended only for the use of the individual or >> entity named above. If the reader of this message is not the intended >> recipient, you are hereby notified that any dissemination, >> distribution or copying of this communication is strictly prohibited. If >> you have received this transmission in error, do not read it. Please >> immediately reply to the sender that you have received this communication in >> error and then delete it. >> >> Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, >> pode conter informação privilegiada ou confidencial e é para uso exclusivo >> da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário >> indicado, fica notificado de que a >> leitura, utilização, divulgação e/ou cópia sem autorização pode estar >> proibida em virtude da legislação vigente. Se recebeu esta mensagem por >> erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e >> proceda a sua destruição >> >> >> _______________________________________________ >> Visit our blog: >> http://blog.pjsip.org <http://blog.pjsip.org> >> >> pjsip mailing list >> pjsip@xxxxxxxxxxxxxxx >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> >> >> >> >> >> >> >> ________________________________ >> >> Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, >> puede contener información privilegiada o confidencial y es para uso >> exclusivo de la persona o entidad de destino. Si no es usted. el >> destinatario indicado, queda notificado de que la lectura, utilización, >> divulgación y/o copia sin autorización puede estar prohibida en virtud de la >> legislación vigente. Si ha recibido este mensaje por error, le rogamos que >> nos lo comunique inmediatamente por esta misma vía y proceda a su >> destrucción. >> >> The information contained in this transmission is privileged and >> confidential information intended only for the use of the individual or >> entity named above. If the reader of this message is not the intended >> recipient, you are hereby notified that any dissemination, distribution or >> copying of this communication is strictly prohibited. If you have received >> this transmission in error, do not read it. Please immediately reply to the >> sender that you have received this communication in error and then delete >> it. >> >> Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, >> pode conter informação privilegiada ou confidencial e é para uso exclusivo >> da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário >> indicado, fica notificado de que a leitura, utilização, divulgação e/ou >> cópia sem autorização pode estar proibida em virtude da legislação vigente. >> Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique >> imediatamente por esta mesma via e proceda a sua destruição >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip@xxxxxxxxxxxxxxx >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >
Attachment:
pj-pjsip_tdata_get_dlg.patch
Description: Binary data
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org