|
@@ -122,7 +122,7 @@ int build_uri_str(str* username, struct sip_uri* uri, str* from)
|
|
* resp_cback - a response callback that gets called when the transaction is complete
|
|
* resp_cback - a response callback that gets called when the transaction is complete
|
|
*/
|
|
*/
|
|
int bcast_dmq_message(dmq_peer_t* peer, str* body, dmq_node_t* except,
|
|
int bcast_dmq_message(dmq_peer_t* peer, str* body, dmq_node_t* except,
|
|
- dmq_resp_cback_t* resp_cback, int max_forwards)
|
|
|
|
|
|
+ dmq_resp_cback_t* resp_cback, int max_forwards, str* content_type)
|
|
{
|
|
{
|
|
dmq_node_t* node;
|
|
dmq_node_t* node;
|
|
|
|
|
|
@@ -140,7 +140,7 @@ int bcast_dmq_message(dmq_peer_t* peer, str* body, dmq_node_t* except,
|
|
node = node->next;
|
|
node = node->next;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(dmq_send_message(peer, body, node, resp_cback, max_forwards) < 0) {
|
|
|
|
|
|
+ if(dmq_send_message(peer, body, node, resp_cback, max_forwards, content_type) < 0) {
|
|
LM_ERR("error sending dmq message\n");
|
|
LM_ERR("error sending dmq message\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
@@ -162,7 +162,7 @@ error:
|
|
* resp_cback - a response callback that gets called when the transaction is complete
|
|
* resp_cback - a response callback that gets called when the transaction is complete
|
|
*/
|
|
*/
|
|
int dmq_send_message(dmq_peer_t* peer, str* body, dmq_node_t* node,
|
|
int dmq_send_message(dmq_peer_t* peer, str* body, dmq_node_t* node,
|
|
- dmq_resp_cback_t* resp_cback, int max_forwards)
|
|
|
|
|
|
+ dmq_resp_cback_t* resp_cback, int max_forwards, str* content_type)
|
|
{
|
|
{
|
|
uac_req_t uac_r;
|
|
uac_req_t uac_r;
|
|
str str_hdr = {0, 0};
|
|
str str_hdr = {0, 0};
|
|
@@ -171,14 +171,18 @@ int dmq_send_message(dmq_peer_t* peer, str* body, dmq_node_t* node,
|
|
int result = 0;
|
|
int result = 0;
|
|
int len = 0;
|
|
int len = 0;
|
|
|
|
|
|
- /* Max-Forwards */
|
|
|
|
- str_hdr.len = 20 + CRLF_LEN;
|
|
|
|
|
|
+ if (!content_type) {
|
|
|
|
+ LM_ERR("content-type is null\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ /* add Max-Forwards and Content-Type headers */
|
|
|
|
+ str_hdr.len = 34 + content_type->len + (CRLF_LEN*2);
|
|
str_hdr.s = pkg_malloc(str_hdr.len);
|
|
str_hdr.s = pkg_malloc(str_hdr.len);
|
|
if(str_hdr.s==NULL) {
|
|
if(str_hdr.s==NULL) {
|
|
LM_ERR("no more pkg\n");
|
|
LM_ERR("no more pkg\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- len += sprintf(str_hdr.s, "Max-Forwards: %d%s", max_forwards, CRLF);
|
|
|
|
|
|
+ len += sprintf(str_hdr.s, "Max-Forwards: %d" CRLF "Content-Type: %.*s" CRLF, max_forwards, content_type->len, content_type->s);
|
|
str_hdr.len = len;
|
|
str_hdr.len = len;
|
|
|
|
|
|
cb_param = shm_malloc(sizeof(*cb_param));
|
|
cb_param = shm_malloc(sizeof(*cb_param));
|
|
@@ -216,11 +220,12 @@ error:
|
|
/**
|
|
/**
|
|
* @brief config file function for sending dmq message
|
|
* @brief config file function for sending dmq message
|
|
*/
|
|
*/
|
|
-int cfg_dmq_send_message(struct sip_msg* msg, char* peer, char* to, char* body)
|
|
|
|
|
|
+int cfg_dmq_send_message(struct sip_msg* msg, char* peer, char* to, char* body, char* content_type)
|
|
{
|
|
{
|
|
str peer_str;
|
|
str peer_str;
|
|
str to_str;
|
|
str to_str;
|
|
str body_str;
|
|
str body_str;
|
|
|
|
+ str ct_str;
|
|
|
|
|
|
if(get_str_fparam(&peer_str, msg, (fparam_t*)peer)<0) {
|
|
if(get_str_fparam(&peer_str, msg, (fparam_t*)peer)<0) {
|
|
LM_ERR("cannot get peer value\n");
|
|
LM_ERR("cannot get peer value\n");
|
|
@@ -234,11 +239,17 @@ int cfg_dmq_send_message(struct sip_msg* msg, char* peer, char* to, char* body)
|
|
LM_ERR("cannot get body value\n");
|
|
LM_ERR("cannot get body value\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+ if(get_str_fparam(&ct_str, msg, (fparam_t*)content_type)<0) {
|
|
|
|
+ LM_ERR("cannot get content-type value\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- LM_INFO("cfg_dmq_send_message: %.*s - %.*s - %.*s\n",
|
|
|
|
|
|
+ LM_INFO("cfg_dmq_send_message: %.*s - %.*s - %.*s - %.*s\n",
|
|
peer_str.len, peer_str.s,
|
|
peer_str.len, peer_str.s,
|
|
to_str.len, to_str.s,
|
|
to_str.len, to_str.s,
|
|
- body_str.len, body_str.s);
|
|
|
|
|
|
+ body_str.len, body_str.s,
|
|
|
|
+ ct_str.len, ct_str.s);
|
|
|
|
|
|
dmq_peer_t* destination_peer = find_peer(peer_str);
|
|
dmq_peer_t* destination_peer = find_peer(peer_str);
|
|
if(!destination_peer) {
|
|
if(!destination_peer) {
|
|
@@ -260,7 +271,7 @@ int cfg_dmq_send_message(struct sip_msg* msg, char* peer, char* to, char* body)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
if(dmq_send_message(destination_peer, &body_str, to_dmq_node,
|
|
if(dmq_send_message(destination_peer, &body_str, to_dmq_node,
|
|
- ¬ification_callback, 1) < 0) {
|
|
|
|
|
|
+ ¬ification_callback, 1, &ct_str) < 0) {
|
|
LM_ERR("cannot send dmq message\n");
|
|
LM_ERR("cannot send dmq message\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
@@ -284,7 +295,7 @@ void ping_servers(unsigned int ticks, void *param) {
|
|
LM_DBG("ping_servers\n");
|
|
LM_DBG("ping_servers\n");
|
|
body = build_notification_body();
|
|
body = build_notification_body();
|
|
ret = bcast_dmq_message(dmq_notification_peer, body, notification_node,
|
|
ret = bcast_dmq_message(dmq_notification_peer, body, notification_node,
|
|
- ¬ification_callback, 1);
|
|
|
|
|
|
+ ¬ification_callback, 1, ¬ification_content_type);
|
|
pkg_free(body->s);
|
|
pkg_free(body->s);
|
|
pkg_free(body);
|
|
pkg_free(body);
|
|
if(ret < 0) {
|
|
if(ret < 0) {
|