Re: Custom Registration Header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Harry,

Thanks for the response. I'm actually rebuilding a new config from scratch so I'm not using the get config method. I'll look into your other suggestions as well.

When setting the account config I'm assuming it all gets copied into the account pool's memory, right? I'm going to have to update the config with new registration headers somewhat frequently so I want to avoid any leaks.

Best,
Colin
On Thu, May 26, 2016 at 6:16 AM Harald Radke <harryrat@xxxxxx> wrote:
hm... I dont use the sua abstraction, however, I assume you retrieved your account config via pjsua_acc_get_config()?  for that you needed a pool anyways, maybe you can combine config getting and adjusting?
 
also, pjsua_pool_create/release() spares you the caching pool handling I guess.
 
Regards,
 
 Harry
Gesendet: Donnerstag, 26. Mai 2016 um 05:25 Uhr
Von: "Colin Morelli" <colin.morelli@xxxxxxxxx>
An: "pjsip list" <pjsip@xxxxxxxxxxxxxxx>
Betreff: Re: Custom Registration Header
Ok, so I managed to get it working, but I'm far from being great with this so I'd really appreciate feedback on my approach. Basically I'm running:
 
  pj_caching_pool cp;
  pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
  pj_pool_t *pool = pj_pool_create(&cp.factory, "header", 1000, 1000, NULL);
  [self convertAccountConfiguration:configuration config:&config pool:pool]; // this is the method that sets headers by allocating from the provided pool
  pjsua_acc_modify((int) _id, &config);
  pj_pool_release(pool);
 
Is that acceptable? Is there a better approach?
 
 
On Wed, May 25, 2016 at 9:57 PM Colin Morelli <colin.morelli@xxxxxxxxx> wrote:
If it makes any difference, I'm actually looking to have this header change on every registration request. The use case is to include a JWT in the registration (instead of a standard username and password)
 
Thanks,
Colin
 
On Wed, May 25, 2016 at 9:54 PM Colin Morelli <colin.morelli@xxxxxxxxx> wrote:
Hey all,
 
I'm trying to send a custom header in my registration request. However, my app always ends up crashing when trying to set it. I'm calling:
 
  pj_list_init(&config->reg_hdr_list);
  pjsip_generic_string_hdr generic_hdr;
  pj_str_t name = pj_str("name");
  pj_str_t value = pj_str("value");
  pjsip_generic_string_hdr_init2(&generic_hdr, &name, &value);
  pj_list_push_back(&config->reg_hdr_list, &generic_hdr);
 
The backtrace from the crash is:
 
    frame #0: 0x348dcae6 libsystem_platform.dylib`_platform_memmove + 486
    frame #1: 0x347ebc64 libsystem_c.dylib`__memcpy_chk + 16
    frame #2: 0x347ebc64 libsystem_c.dylib`__memcpy_chk + 16
    frame #3: 0x0026f34a MyApp`pj_memcpy + 26
    frame #4: 0x0026f31c MyApp`pj_strdup + 68
    frame #5: 0x002c58f2 MyApp`pjsip_generic_string_hdr_init + 38
    frame #6: 0x002c5948 MyApp`pjsip_generic_string_hdr_create + 36
    frame #7: 0x002c6d1c MyApp`pjsip_generic_string_hdr_clone + 24
    frame #8: 0x002c4d62 MyApp`pjsip_hdr_clone + 34
    frame #9: 0x00301aae MyApp`pjsua_acc_config_dup + 420
    frame #10: 0x00301e68 MyApp`pjsua_acc_add + 666
 
I'm assuming I need to be allocating the strings on the pool but I'm not sure which pool to use without causing a leak.
 
Best,
Colin
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux