MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mc_compact

Function mc_compact

modules/compression/compression.c:627–676  ·  view source on GitHub ↗

* Compaction function * 1) Headers of same type will be put together * 2) Header names with compact forms will be transformed to * compact form * 3) Headers which not in whitelist will be removed * 4) Unnecessary sdp body codec attributes lower than 96 removed */

Source from the content-addressed store, hash-verified

625 * 4) Unnecessary sdp body codec attributes lower than 96 removed
626 */
627static int mc_compact(struct sip_msg* msg, mc_whitelist_p wh_list, void* flags_p)
628{
629 struct mc_compact_args *mc_compact_args_p;
630
631 /* first check if anyone else has called mc_compact() on this msg */
632 if (GET_GLOBAL_CTX(compact_ctx_pos))
633 return -1;
634
635 mc_compact_args_p = pkg_malloc(sizeof(struct mc_compact_args));
636 if (mc_compact_args_p==NULL) {
637 LM_ERR("no more pkg mem\n");
638 goto error;
639 }
640
641 mc_compact_args_p->wh_list = mc_dup_whitelist(wh_list);
642 if (mc_compact_args_p->wh_list==NULL) {
643 LM_ERR("no more pkg mem\n");
644 goto error;
645 }
646
647 mc_compact_args_p->flags = (unsigned int)(unsigned long)flags_p;
648 SET_GLOBAL_CTX(compact_ctx_pos, (void*)mc_compact_args_p);
649
650 /* register stateless callbacks */
651 if (register_post_raw_processing_cb(wrap_msg_compact, POST_RAW_PROCESSING, 1/*to be freed*/) < 0) {
652 LM_ERR("failed to add raw processing cb\n");
653 goto error;
654 }
655
656 if (tm_api.t_gett && msg->msg_flags&FL_TM_CB_REGISTERED)
657 goto error;
658
659 /*register tm callback if tm api */
660 if (tm_api.register_tmcb &&
661 tm_api.register_tmcb( msg, 0, TMCB_PRE_SEND_BUFFER,
662 wrap_tm_compact, NULL, 0) != 1) {
663 LM_ERR("failed to add tm TMCB_PRE_SEND_BUFFER callback\n");
664 msg->msg_flags |= FL_TM_CB_REGISTERED;
665 goto error;
666 }
667
668 /* we do not release the whitelist here, as it will be used later by the
669 * tm callbacks */
670 return 1;
671
672error:
673 SET_GLOBAL_CTX(compact_ctx_pos, NULL);
674 free_mc_compact_args(mc_compact_args_p);
675 return -1;
676}
677
678/*
679 *

Callers

nothing calls this directly

Calls 3

mc_dup_whitelistFunction · 0.85
free_mc_compact_argsFunction · 0.85

Tested by

no test coverage detected