srtp: negotiate encryption and apply keys to backend
[siplcs.git] / src / core / sdpmsg.c
blob6c5d23ee787c7f19c24c8fec6cb95d24063e86ac
1 /**
2 * @file sdpmsg.c
4 * pidgin-sipe
6 * Copyright (C) 2013-2015 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2010 Jakub Adam <jakub.adam@ktknet.cz>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
28 #include <glib.h>
30 #include "sipe-backend.h"
31 #include "sipe-core.h"
32 #include "sdpmsg.h"
33 #include "sipe-utils.h"
35 static gboolean
36 append_attribute(struct sdpmedia *media, gchar *attr)
38 gchar **parts = g_strsplit(attr + 2, ":", 2);
40 if(!parts[0]) {
41 g_strfreev(parts);
42 return FALSE;
45 media->attributes = sipe_utils_nameval_add(media->attributes,
46 parts[0],
47 parts[1] ? parts[1] : "");
48 g_strfreev(parts);
49 return TRUE;
52 static gboolean
53 parse_attributes(struct sdpmsg *smsg, gchar *msg) {
54 gchar **lines = g_strsplit(msg, "\r\n", 0);
55 gchar **ptr = lines;
57 while (*ptr != NULL) {
58 if (g_str_has_prefix(*ptr, "o=")) {
59 gchar **parts = g_strsplit(*ptr + 2, " ", 6);
60 smsg->ip = g_strdup(parts[5]);
61 g_strfreev(parts);
62 } else if (g_str_has_prefix(*ptr, "m=")) {
63 gchar **parts = g_strsplit(*ptr + 2, " ", 3);
64 struct sdpmedia *media = g_new0(struct sdpmedia, 1);
66 smsg->media = g_slist_append(smsg->media, media);
68 media->name = g_strdup(parts[0]);
69 media->port = atoi(parts[1]);
70 media->encryption_active =
71 g_strstr_len(parts[2], -1, "/SAVP") != NULL;
73 g_strfreev(parts);
75 while (*(++ptr) && !g_str_has_prefix(*ptr, "m=")) {
77 if (g_str_has_prefix(*ptr, "a=")) {
78 if (!append_attribute(media, *ptr)) {
79 g_strfreev(lines);
80 return FALSE;
84 continue;
87 ++ptr;
90 g_strfreev(lines);
92 return TRUE;
95 static struct sdpcandidate * sdpcandidate_copy(struct sdpcandidate *candidate);
96 static void sdpcandidate_free(struct sdpcandidate *candidate);
98 static SipeComponentType
99 parse_component(const gchar *str)
101 switch (atoi(str)) {
102 case 1: return SIPE_COMPONENT_RTP;
103 case 2: return SIPE_COMPONENT_RTCP;
104 default: return SIPE_COMPONENT_NONE;
108 static gchar *
109 base64_pad(const gchar* str)
111 size_t str_len = strlen(str);
112 int mod = str_len % 4;
114 if (mod > 0) {
115 gchar *result = NULL;
116 int pad = 4 - mod;
117 gchar *ptr = result = g_malloc(str_len + pad + 1);
119 memcpy(ptr, str, str_len);
120 ptr += str_len;
121 memset(ptr, '=', pad);
122 ptr += pad;
123 *ptr = '\0';
125 return result;
126 } else
127 return g_strdup(str);
130 static GSList *
131 parse_append_candidate_draft_6(gchar **tokens, GSList *candidates)
133 struct sdpcandidate *candidate = g_new0(struct sdpcandidate, 1);
135 candidate->username = base64_pad(tokens[0]);
136 candidate->component = parse_component(tokens[1]);
137 candidate->password = base64_pad(tokens[2]);
139 if (sipe_strequal(tokens[3], "UDP"))
140 candidate->protocol = SIPE_NETWORK_PROTOCOL_UDP;
141 else if (sipe_strequal(tokens[3], "TCP"))
142 candidate->protocol = SIPE_NETWORK_PROTOCOL_TCP_ACTIVE;
143 else {
144 sdpcandidate_free(candidate);
145 return candidates;
148 candidate->priority = atoi(tokens[4] + 2);
149 candidate->ip = g_strdup(tokens[5]);
150 candidate->port = atoi(tokens[6]);
152 candidates = g_slist_append(candidates, candidate);
154 // draft 6 candidates are both active and passive
155 if (candidate->protocol == SIPE_NETWORK_PROTOCOL_TCP_ACTIVE) {
156 candidate = sdpcandidate_copy(candidate);
157 candidate->protocol = SIPE_NETWORK_PROTOCOL_TCP_PASSIVE;
158 candidates = g_slist_append(candidates, candidate);
161 return candidates;
164 static GSList *
165 parse_append_candidate_rfc_5245(gchar **tokens, GSList *candidates)
167 struct sdpcandidate *candidate = g_new0(struct sdpcandidate, 1);
169 candidate->foundation = g_strdup(tokens[0]);
170 candidate->component = parse_component(tokens[1]);
172 if (sipe_strequal(tokens[2], "UDP"))
173 candidate->protocol = SIPE_NETWORK_PROTOCOL_UDP;
174 else if (sipe_strequal(tokens[2], "TCP-ACT"))
175 candidate->protocol = SIPE_NETWORK_PROTOCOL_TCP_ACTIVE;
176 else if (sipe_strequal(tokens[2], "TCP-PASS"))
177 candidate->protocol = SIPE_NETWORK_PROTOCOL_TCP_PASSIVE;
178 else {
179 sdpcandidate_free(candidate);
180 return candidates;
183 candidate->priority = atoi(tokens[3]);
184 candidate->ip = g_strdup(tokens[4]);
185 candidate->port = atoi(tokens[5]);
187 if (sipe_strequal(tokens[7], "host"))
188 candidate->type = SIPE_CANDIDATE_TYPE_HOST;
189 else if (sipe_strequal(tokens[7], "relay"))
190 candidate->type = SIPE_CANDIDATE_TYPE_RELAY;
191 else if (sipe_strequal(tokens[7], "srflx"))
192 candidate->type = SIPE_CANDIDATE_TYPE_SRFLX;
193 else if (sipe_strequal(tokens[7], "prflx"))
194 candidate->type = SIPE_CANDIDATE_TYPE_PRFLX;
195 else {
196 sdpcandidate_free(candidate);
197 return candidates;
200 candidates = g_slist_append(candidates, candidate);
202 // TCP-ACT candidates are both active and passive
203 if (candidate->protocol == SIPE_NETWORK_PROTOCOL_TCP_ACTIVE) {
204 candidate = sdpcandidate_copy(candidate);
205 candidate->protocol = SIPE_NETWORK_PROTOCOL_TCP_PASSIVE;
206 candidates = g_slist_append(candidates, candidate);
208 return candidates;
211 static GSList *
212 parse_candidates(GSList *attrs, SipeIceVersion *ice_version)
214 GSList *candidates = NULL;
215 const gchar *attr;
216 int i = 0;
218 while ((attr = sipe_utils_nameval_find_instance(attrs, "candidate", i++))) {
219 gchar **tokens = g_strsplit_set(attr, " ", 0);
221 if (sipe_strequal(tokens[6], "typ")) {
222 candidates = parse_append_candidate_rfc_5245(tokens, candidates);
223 if (candidates)
224 *ice_version = SIPE_ICE_RFC_5245;
225 } else {
226 candidates = parse_append_candidate_draft_6(tokens, candidates);
227 if (candidates)
228 *ice_version = SIPE_ICE_DRAFT_6;
231 g_strfreev(tokens);
234 if (!candidates)
235 *ice_version = SIPE_ICE_NO_ICE;
237 if (*ice_version == SIPE_ICE_RFC_5245) {
238 const gchar *username = sipe_utils_nameval_find(attrs, "ice-ufrag");
239 const gchar *password = sipe_utils_nameval_find(attrs, "ice-pwd");
241 if (username && password) {
242 GSList *i;
243 for (i = candidates; i; i = i->next) {
244 struct sdpcandidate *c = i->data;
245 c->username = g_strdup(username);
246 c->password = g_strdup(password);
251 return candidates;
254 static GSList *
255 create_legacy_candidates(gchar *ip, guint16 port)
257 struct sdpcandidate *candidate;
258 GSList *candidates = NULL;
260 candidate = g_new0(struct sdpcandidate, 1);
261 candidate->foundation = g_strdup("1");
262 candidate->component = SIPE_COMPONENT_RTP;
263 candidate->type = SIPE_CANDIDATE_TYPE_HOST;
264 candidate->protocol = SIPE_NETWORK_PROTOCOL_UDP;
265 candidate->ip = g_strdup(ip);
266 candidate->port = port;
268 candidates = g_slist_append(candidates, candidate);
270 candidate = g_new0(struct sdpcandidate, 1);
271 candidate->foundation = g_strdup("1");
272 candidate->component = SIPE_COMPONENT_RTCP;
273 candidate->type = SIPE_CANDIDATE_TYPE_HOST;
274 candidate->protocol = SIPE_NETWORK_PROTOCOL_UDP;
275 candidate->ip = g_strdup(ip);
276 candidate->port = port + 1;
278 candidates = g_slist_append(candidates, candidate);
280 return candidates;
283 static GSList *
284 parse_codecs(GSList *attrs, SipeMediaType type)
286 int i = 0;
287 const gchar *attr;
288 GSList *codecs = NULL;
290 while ((attr = sipe_utils_nameval_find_instance(attrs, "rtpmap", i++))) {
291 struct sdpcodec *codec = g_new0(struct sdpcodec, 1);
292 gchar **tokens = g_strsplit_set(attr, " /", 3);
294 int j = 0;
295 const gchar* params;
297 codec->id = atoi(tokens[0]);
298 codec->name = g_strdup(tokens[1]);
299 codec->clock_rate = atoi(tokens[2]);
300 codec->type = type;
302 // TODO: more secure and effective implementation
303 while((params = sipe_utils_nameval_find_instance(attrs, "fmtp", j++))) {
304 gchar **tokens = g_strsplit_set(params, " ", 0);
305 gchar **next = tokens + 1;
307 if (atoi(tokens[0]) == codec->id) {
308 while (*next) {
309 gchar name[50];
310 gchar value[50];
312 if (sscanf(*next, "%[a-zA-Z0-9]=%s", name, value) == 2)
313 codec->parameters = sipe_utils_nameval_add(codec->parameters, name, value);
315 ++next;
319 g_strfreev(tokens);
322 codecs = g_slist_append(codecs, codec);
323 g_strfreev(tokens);
326 return codecs;
329 static guchar *
330 parse_encryption_key(GSList *attrs)
332 int i = 0;
333 const gchar *attr;
334 guchar *result = NULL;
336 while ((attr = sipe_utils_nameval_find_instance(attrs, "crypto", i++))) {
337 gchar **tokens = g_strsplit_set(attr, " :|", 6);
339 if (tokens[0] && tokens[1] && tokens[2] && tokens[3] && tokens[4] &&
340 sipe_strcase_equal(tokens[1], "AES_CM_128_HMAC_SHA1_80") &&
341 sipe_strequal(tokens[2], "inline") &&
342 !tokens[5]) {
343 gsize key_len;
344 result = g_base64_decode(tokens[3], &key_len);
345 if (key_len != SIPE_SRTP_KEY_LEN) {
346 g_free(result);
347 result = NULL;
351 g_strfreev(tokens);
353 if (result) {
354 break;
358 return result;
361 struct sdpmsg *
362 sdpmsg_parse_msg(gchar *msg)
364 struct sdpmsg *smsg = g_new0(struct sdpmsg, 1);
365 GSList *i;
367 if (!parse_attributes(smsg, msg)) {
368 sdpmsg_free(smsg);
369 return NULL;
372 for (i = smsg->media; i; i = i->next) {
373 struct sdpmedia *media = i->data;
374 SipeMediaType type;
376 media->candidates = parse_candidates(media->attributes,
377 &smsg->ice_version);
379 if (!media->candidates && media->port != 0) {
380 // No a=candidate in SDP message, this seems to be MSOC 2005
381 media->candidates = create_legacy_candidates(smsg->ip, media->port);
384 if (sipe_strequal(media->name, "audio"))
385 type = SIPE_MEDIA_AUDIO;
386 else if (sipe_strequal(media->name, "video"))
387 type = SIPE_MEDIA_VIDEO;
388 else {
389 // Unknown media type
390 sdpmsg_free(smsg);
391 return NULL;
394 media->codecs = parse_codecs(media->attributes, type);
395 media->encryption_key = parse_encryption_key(media->attributes);
398 return smsg;
401 static gchar *
402 codecs_to_string(GSList *codecs)
404 GString *result = g_string_new(NULL);
406 for (; codecs; codecs = codecs->next) {
407 struct sdpcodec *c = codecs->data;
408 GSList *params = c->parameters;
410 g_string_append_printf(result,
411 "a=rtpmap:%d %s/%d\r\n",
412 c->id,
413 c->name,
414 c->clock_rate);
416 if (params) {
417 GString *param_str = g_string_new(NULL);
418 int written_params = 0;
420 g_string_append_printf(param_str, "a=fmtp:%d", c->id);
422 for (; params; params = params->next) {
423 struct sipnameval* par = params->data;
424 if (sipe_strequal(par->name, "farsight-send-profile")) {
425 // Lync AVMCU doesn't like this property.
426 continue;
429 g_string_append_printf(param_str, " %s=%s",
430 par->name, par->value);
431 ++written_params;
434 g_string_append(param_str, "\r\n");
436 if (written_params > 0) {
437 g_string_append(result, param_str->str);
440 g_string_free(param_str, TRUE);
444 return g_string_free(result, FALSE);
447 static gchar *
448 codec_ids_to_string(GSList *codecs)
450 GString *result = g_string_new(NULL);
452 for (; codecs; codecs = codecs->next) {
453 struct sdpcodec *c = codecs->data;
454 g_string_append_printf(result, " %d", c->id);
457 return g_string_free(result, FALSE);
460 static gchar *
461 base64_unpad(const gchar *str)
463 gchar *result = g_strdup(str);
464 gchar *ptr;
466 for (ptr = result + strlen(result); ptr != result; --ptr) {
467 if (*(ptr - 1) != '=') {
468 *ptr = '\0';
469 break;
473 return result;
476 static gchar *
477 candidates_to_string(GSList *candidates, SipeIceVersion ice_version)
479 GString *result = g_string_new("");
480 GSList *i;
481 GSList *processed_tcp_candidates = NULL;
483 for (i = candidates; i; i = i->next) {
484 struct sdpcandidate *c = i->data;
485 const gchar *protocol;
486 const gchar *type;
487 gchar *related = NULL;
489 if (ice_version == SIPE_ICE_RFC_5245) {
491 switch (c->protocol) {
492 case SIPE_NETWORK_PROTOCOL_TCP_ACTIVE:
493 protocol = "TCP-ACT";
494 break;
495 case SIPE_NETWORK_PROTOCOL_TCP_PASSIVE:
496 protocol = "TCP-PASS";
497 break;
498 case SIPE_NETWORK_PROTOCOL_UDP:
499 protocol = "UDP";
500 break;
501 default:
502 /* error unknown/unsupported type */
503 protocol = "UNKNOWN";
504 break;
507 switch (c->type) {
508 case SIPE_CANDIDATE_TYPE_HOST:
509 type = "host";
510 break;
511 case SIPE_CANDIDATE_TYPE_RELAY:
512 type = "relay";
513 related = g_strdup_printf("raddr %s rport %d ",
514 c->base_ip,
515 c->base_port);
516 break;
517 case SIPE_CANDIDATE_TYPE_SRFLX:
518 type = "srflx";
519 related = g_strdup_printf("raddr %s rport %d",
520 c->base_ip,
521 c->base_port);
522 break;
523 case SIPE_CANDIDATE_TYPE_PRFLX:
524 type = "prflx";
525 break;
526 default:
527 /* error unknown/unsupported type */
528 type = "unknown";
529 break;
532 g_string_append_printf(result,
533 "a=candidate:%s %u %s %u %s %d typ %s %s\r\n",
534 c->foundation,
535 c->component,
536 protocol,
537 c->priority,
538 c->ip,
539 c->port,
540 type,
541 related ? related : "");
542 g_free(related);
544 } else if (ice_version == SIPE_ICE_DRAFT_6) {
545 gchar *username;
546 gchar *password;
548 switch (c->protocol) {
549 case SIPE_NETWORK_PROTOCOL_TCP_ACTIVE:
550 case SIPE_NETWORK_PROTOCOL_TCP_PASSIVE: {
551 GSList *prev_cand = processed_tcp_candidates;
552 for (; prev_cand; prev_cand = prev_cand->next) {
553 struct sdpcandidate *c2 = (struct sdpcandidate *)prev_cand->data;
555 if (sipe_strequal(c->ip, c2->ip) &&
556 c->component == c2->component) {
557 break;
561 if (prev_cand) {
562 protocol = NULL;
563 } else {
564 protocol = "TCP";
565 processed_tcp_candidates =
566 g_slist_append(processed_tcp_candidates, c);
568 break;
570 case SIPE_NETWORK_PROTOCOL_UDP:
571 protocol = "UDP";
572 break;
573 default:
574 /* unknown/unsupported type, ignore */
575 protocol = NULL;
576 break;
579 if (!protocol) {
580 continue;
583 username = base64_unpad(c->username);
584 password = base64_unpad(c->password);
586 g_string_append_printf(result,
587 "a=candidate:%s %u %s %s 0.%u %s %d\r\n",
588 username,
589 c->component,
590 password,
591 protocol,
592 c->priority,
593 c->ip,
594 c->port);
596 g_free(username);
597 g_free(password);
601 g_slist_free(processed_tcp_candidates);
603 return g_string_free(result, FALSE);
606 static gchar *
607 remote_candidates_to_string(GSList *candidates, SipeIceVersion ice_version)
609 GString *result = g_string_new("");
611 if (candidates) {
612 if (ice_version == SIPE_ICE_RFC_5245) {
613 GSList *i;
614 g_string_append(result, "a=remote-candidates:");
616 for (i = candidates; i; i = i->next) {
617 struct sdpcandidate *c = i->data;
618 g_string_append_printf(result, "%u %s %u ",
619 c->component, c->ip, c->port);
622 g_string_append(result, "\r\n");
623 } else if (ice_version == SIPE_ICE_DRAFT_6) {
624 struct sdpcandidate *c = candidates->data;
625 g_string_append_printf(result, "a=remote-candidate:%s\r\n",
626 c->username);
630 return g_string_free(result, FALSE);
633 static gchar *
634 attributes_to_string(GSList *attributes)
636 GString *result = g_string_new("");
638 for (; attributes; attributes = attributes->next) {
639 struct sipnameval *a = attributes->data;
640 g_string_append_printf(result, "a=%s", a->name);
641 if (!sipe_strequal(a->value, ""))
642 g_string_append_printf(result, ":%s", a->value);
643 g_string_append(result, "\r\n");
646 return g_string_free(result, FALSE);
649 static gchar *
650 media_to_string(const struct sdpmsg *msg, const struct sdpmedia *media)
652 gchar *media_str;
654 gchar *transport_profile = NULL;
656 gchar *media_conninfo = NULL;
658 gchar *codecs_str = NULL;
659 gchar *codec_ids_str = codec_ids_to_string(media->codecs);
661 gchar *candidates_str = NULL;
662 gchar *remote_candidates_str = NULL;
664 gchar *attributes_str = NULL;
665 gchar *credentials = NULL;
667 gchar *crypto = NULL;
669 gboolean uses_tcp_transport = FALSE;
671 if (media->port != 0) {
672 if (!sipe_strequal(msg->ip, media->ip)) {
673 media_conninfo = g_strdup_printf("c=IN IP4 %s\r\n", media->ip);
676 codecs_str = codecs_to_string(media->codecs);
677 candidates_str = candidates_to_string(media->candidates, msg->ice_version);
678 remote_candidates_str = remote_candidates_to_string(media->remote_candidates,
679 msg->ice_version);
681 if (media->remote_candidates) {
682 struct sdpcandidate *c = media->remote_candidates->data;
683 uses_tcp_transport =
684 c->protocol == SIPE_NETWORK_PROTOCOL_TCP_ACTIVE ||
685 c->protocol == SIPE_NETWORK_PROTOCOL_TCP_PASSIVE ||
686 c->protocol == SIPE_NETWORK_PROTOCOL_TCP_SO;
689 attributes_str = attributes_to_string(media->attributes);
691 if (msg->ice_version == SIPE_ICE_RFC_5245 && media->candidates) {
692 struct sdpcandidate *c = media->candidates->data;
694 credentials = g_strdup_printf("a=ice-ufrag:%s\r\n"
695 "a=ice-pwd:%s\r\n",
696 c->username,
697 c->password);
700 if (media->encryption_key) {
701 gchar *key_encoded = g_base64_encode(media->encryption_key, SIPE_SRTP_KEY_LEN);
702 crypto = g_strdup_printf("a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:%s|2^31\r\n",
703 key_encoded);
704 g_free(key_encoded);
708 transport_profile = g_strdup_printf("%sRTP/%sAVP",
709 uses_tcp_transport ? "TCP/" : "",
710 media->encryption_active ? "S" : "");
712 media_str = g_strdup_printf("m=%s %d %s%s\r\n"
713 "%s"
714 "%s"
715 "%s"
716 "%s"
717 "%s"
718 "%s"
719 "%s",
720 media->name, media->port, transport_profile, codec_ids_str,
721 media_conninfo ? media_conninfo : "",
722 candidates_str ? candidates_str : "",
723 crypto ? crypto : "",
724 remote_candidates_str ? remote_candidates_str : "",
725 codecs_str ? codecs_str : "",
726 attributes_str ? attributes_str : "",
727 credentials ? credentials : "");
729 g_free(transport_profile);
730 g_free(media_conninfo);
731 g_free(codecs_str);
732 g_free(codec_ids_str);
733 g_free(candidates_str);
734 g_free(remote_candidates_str);
735 g_free(attributes_str);
736 g_free(credentials);
737 g_free(crypto);
739 return media_str;
742 gchar *
743 sdpmsg_to_string(const struct sdpmsg *msg)
745 GString *body = g_string_new(NULL);
746 GSList *i;
748 g_string_append_printf(
749 body,
750 "v=0\r\n"
751 "o=- 0 0 IN IP4 %s\r\n"
752 "s=session\r\n"
753 "c=IN IP4 %s\r\n"
754 "b=CT:99980\r\n"
755 "t=0 0\r\n",
756 msg->ip, msg->ip);
759 for (i = msg->media; i; i = i->next) {
760 gchar *media_str = media_to_string(msg, i->data);
761 g_string_append(body, media_str);
762 g_free(media_str);
765 return g_string_free(body, FALSE);
768 static struct sdpcandidate *
769 sdpcandidate_copy(struct sdpcandidate *candidate)
771 if (candidate) {
772 struct sdpcandidate *copy = g_new0(struct sdpcandidate, 1);
774 copy->foundation = g_strdup(candidate->foundation);
775 copy->component = candidate->component;
776 copy->type = candidate->type;
777 copy->protocol = candidate->protocol;
778 copy->priority = candidate->priority;
779 copy->ip = g_strdup(candidate->ip);
780 copy->port = candidate->port;
781 copy->base_ip = g_strdup(candidate->base_ip);
782 copy->base_port = candidate->base_port;
783 copy->username = g_strdup(candidate->username);
784 copy->password = g_strdup(candidate->password);
786 return copy;
787 } else
788 return NULL;
791 static void
792 sdpcandidate_free(struct sdpcandidate *candidate)
794 if (candidate) {
795 g_free(candidate->foundation);
796 g_free(candidate->ip);
797 g_free(candidate->base_ip);
798 g_free(candidate->username);
799 g_free(candidate->password);
800 g_free(candidate);
804 void
805 sdpcodec_free(struct sdpcodec *codec)
807 if (codec) {
808 g_free(codec->name);
809 sipe_utils_nameval_free(codec->parameters);
810 g_free(codec);
814 void
815 sdpmedia_free(struct sdpmedia *media)
817 if (media) {
818 g_free(media->name);
819 g_free(media->ip);
821 sipe_utils_nameval_free(media->attributes);
823 sipe_utils_slist_free_full(media->candidates,
824 (GDestroyNotify) sdpcandidate_free);
825 sipe_utils_slist_free_full(media->codecs,
826 (GDestroyNotify) sdpcodec_free);
827 sipe_utils_slist_free_full(media->remote_candidates,
828 (GDestroyNotify) sdpcandidate_free);
830 g_free(media->encryption_key);
832 g_free(media);
836 void
837 sdpmsg_free(struct sdpmsg *msg)
839 if (msg) {
840 g_free(msg->ip);
841 sipe_utils_slist_free_full(msg->media,
842 (GDestroyNotify) sdpmedia_free);
843 g_free(msg);
848 Local Variables:
849 mode: c
850 c-file-style: "bsd"
851 indent-tabs-mode: t
852 tab-width: 8
853 End: