Browse code

- fixed missing Max-Forwards header in Notify messages (reported by Mika Saari)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2300 689a6050-402a-0410-94f2-e92a70836424

Anca Vamanu authored on 25/05/2007 15:12:19
Showing 1 changed files
... ...
@@ -46,6 +46,8 @@
46 46
 #include "utils_func.h"
47 47
 
48 48
 #define ALLOC_SIZE 3000
49
+#define MAX_FORWARD 70
50
+
49 51
 extern struct tm_binds tmb;
50 52
 c_back_param* shm_dup_subs(subs_t* subs, str to_tag);
51 53
 
... ...
@@ -86,6 +88,8 @@ int build_str_hdr(subs_t* subs, int is_body, str** hdr)
86 88
 		LOG(L_ERR, "PRESENCE: build_str_hdr:ERROR while allocating memory\n");
87 89
 		return -1;
88 90
 	}
91
+	memset(str_hdr, 0, sizeof(str));
92
+
89 93
 	str_hdr->s = (char*)pkg_malloc(ALLOC_SIZE* sizeof(char));
90 94
 	if(str_hdr->s== NULL)
91 95
 	{
... ...
@@ -94,8 +98,22 @@ int build_str_hdr(subs_t* subs, int is_body, str** hdr)
94 98
 		return -1;
95 99
 	}	
96 100
 
97
-	strncpy(str_hdr->s ,"Event: ", 7);
98
-	str_hdr->len = 7;
101
+	strncpy(str_hdr->s ,"Max-Forwards: ", 14);
102
+	str_hdr->len = 14;
103
+	len= sprintf(str_hdr->s+str_hdr->len, "%d", MAX_FORWARD);
104
+	if(len<= 0)
105
+	{
106
+		LOG(L_ERR, "PRESENCE: build_str_hdr:ERROR while printing in string\n");
107
+		pkg_free(str_hdr->s);
108
+		pkg_free(str_hdr);
109
+		return -1;
110
+	}	
111
+	str_hdr->len+= len; 
112
+	strncpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
113
+	str_hdr->len += CRLF_LEN;
114
+
115
+	strncpy(str_hdr->s+str_hdr->len  ,"Event: ", 7);
116
+	str_hdr->len+= 7;
99 117
 	strncpy(str_hdr->s+str_hdr->len, event->stored_name.s, event->stored_name.len);
100 118
 	str_hdr->len+= event->stored_name.len;
101 119
 	if (subs->event_id.len)