Exemplo n.º 1
0
/* send subscriber within of dialog, this subscriber close this dialog with Expires header = 0 */
int send_subscriber_within(struct sip_msg* msg, struct sm_subscriber* subs, int expires){

	dlg_t* dialog =NULL;
	str met= {"SUBSCRIBE", 9};
	int sending;
	str* pt_hdr= NULL;
	struct sm_subscriber* params_cb;

	dialog = build_dlg(subs);
	if(dialog== NULL){
		LM_DBG(" --- ERROR IN BUILD DIALOG \n");
		return -1;
	}
	LM_DBG(" --- FINAL \n");
	LM_DBG(" --- DIALOG CALLID%.*s \n", dialog->id.call_id.len, dialog->id.call_id.s);
	LM_DBG(" --- DIALOG REMTAG%.*s \n", dialog->id.rem_tag.len, dialog->id.rem_tag.s);
	LM_DBG(" --- DIALOG LOCTAG%.*s \n", dialog->id.loc_tag.len, dialog->id.loc_tag.s);
	LM_DBG(" --- DIALOG REMURI%.*s \n", dialog->rem_uri.len, dialog->rem_uri.s);
	LM_DBG(" --- DIALOG LOCURI%.*s \n", dialog->loc_uri.len, dialog->loc_uri.s);
	LM_DBG(" --- DIALOG CONTACT%.*s \n", dialog->rem_target.len, dialog->rem_target.s);

	/*
	   event = pkg_malloc(sizeof (char)* subs->event.len +1);
	   if (event == NULL) {
	   LM_ERR("no more pkg memory\n");
	   return -1;
	   }
	   event[subs->event.len] = 0;
	   memcpy(event, subs->event.s, subs->event.len);

	   LM_DBG(" --- EXPIRES = %d \n", expires);
	   LM_DBG(" --- EVENT = %.*s \n", subs->event.len, subs->event.s);
	   */
	params_cb = subs;

	pt_hdr = add_hdr_subscriber(expires, subs->event);

	sending= eme_tm.t_request_within
		(&met,
		 pt_hdr,
		 0,
		 dialog,
		 subs_cback_func_II,
		 (void*)params_cb,
		 0
		);

	if(sending< 0)
		LM_ERR("while sending request with t_request_within\n");

	if(pt_hdr != NULL){
		pkg_free(pt_hdr->s);
		pkg_free(pt_hdr);
	}
	//pkg_free(event);
	pkg_free(dialog);
	return 1;
}
Exemplo n.º 2
0
/* send notifier within of dialog, this notifier is a request that confirm subscribe */
int send_notifier_within(struct sip_msg* msg, struct sm_subscriber* notify){

	dlg_t* dialog =NULL;
	str met= {"NOTIFY", 6};
	int sending;
	struct sm_subscriber* params_cb;
	//char* event;

	str* pt_hdr= NULL;
	str* pt_body = NULL;

	dialog = build_dlg(notify);
	if(dialog== NULL){
		LM_DBG(" --- ERROR IN BUILD DIALOG \n");
		return -1;
	}
	LM_DBG(" --- FINAL \n");
	LM_DBG(" --- DIALOG CALLID%.*s \n", dialog->id.call_id.len, dialog->id.call_id.s);
	LM_DBG(" --- DIALOG REMTAG%.*s \n", dialog->id.rem_tag.len, dialog->id.rem_tag.s);
	LM_DBG(" --- DIALOG LOCTAG%.*s \n", dialog->id.loc_tag.len, dialog->id.loc_tag.s);
	LM_DBG(" --- DIALOG REMURI%.*s \n", dialog->rem_uri.len, dialog->rem_uri.s);
	LM_DBG(" --- DIALOG LOCURI%.*s \n", dialog->loc_uri.len, dialog->loc_uri.s);
	LM_DBG(" --- DIALOG CONTACT%.*s \n", dialog->rem_target.len, dialog->rem_target.s);

	params_cb = notify;

	pt_body = add_body_notifier(notify);

	pt_hdr = add_hdr_notifier(notify);

	sending= eme_tm.t_request_within
		(&met,
		 pt_hdr,
		 pt_body,
		 dialog,
		 notif_cback_func,
		 (void*)params_cb,
		 0
		);

	if(sending< 0)
		LM_ERR("while sending request with t_request_within\n");

	if(pt_hdr != NULL){
		pkg_free(pt_hdr->s);
		pkg_free(pt_hdr);
	}

	if(pt_body != NULL){
		pkg_free(pt_body->s);
		pkg_free(pt_body);
	}

	pkg_free(dialog);

	return 1;
}
Exemplo n.º 3
0
/* send subscriber within of dialog, this subscriber close this dialog with Expires header = 0 */
int send_subscriber_within(struct sip_msg* msg, struct sm_subscriber* subs, int expires){

    dlg_t* dialog =NULL;
    str met= {"SUBSCRIBE", 9};
    int sending;
    char* event;
    str* pt_hdr= NULL;

    dialog = build_dlg(subs);
    if(dialog== NULL){
            LM_INFO(" --- ERROR IN BUILD DIALOG \n");
            return -1;
    }
    LM_INFO(" --- FINAL \n");
    LM_INFO(" --- DIALOG CALLID%.*s \n", dialog->id.call_id.len, dialog->id.call_id.s);
    LM_INFO(" --- DIALOG REMTAG%.*s \n", dialog->id.rem_tag.len, dialog->id.rem_tag.s);
    LM_INFO(" --- DIALOG LOCTAG%.*s \n", dialog->id.loc_tag.len, dialog->id.loc_tag.s);
    LM_INFO(" --- DIALOG REMURI%.*s \n", dialog->rem_uri.len, dialog->rem_uri.s);
    LM_INFO(" --- DIALOG LOCURI%.*s \n", dialog->loc_uri.len, dialog->loc_uri.s);
    LM_INFO(" --- DIALOG CONTACT%.*s \n", dialog->rem_target.len, dialog->rem_target.s);

    event = pkg_malloc(sizeof (char)* subs->event.len +1);
    event[subs->event.len] = 0;
    memcpy(event, subs->event.s, subs->event.len);

    LM_INFO(" --- EXPIRES = %d \n", expires);
    LM_INFO(" --- EVENT = %.*s \n", subs->event.len, subs->event.s);

    pt_hdr = add_hdr_subscriber(expires, subs->event);

     LM_INFO(" --- AQUI WITHIN \n");

    sending= eme_tm.t_request_within
        (&met,
        pt_hdr,
        0,
        dialog,
        subs_cback_func_II,
        0,
        0
    );

    LM_INFO(" --- AQUI WITHIN II \n");
    if(sending< 0)
        LM_ERR("while sending request with t_request_within\n");

    return 1;
}