* Parse all SDP parts from the SIP body. * * returns the first found SDP on success * returns NULL if no SDP found or if error */
| 684 | * returns NULL if no SDP found or if error |
| 685 | */ |
| 686 | sdp_info_t* parse_sdp(struct sip_msg* _m) |
| 687 | { |
| 688 | struct body_part *part; |
| 689 | sdp_info_t *sdp, *ret; |
| 690 | |
| 691 | if ( parse_sip_body(_m)<0 || _m->body==NULL) { |
| 692 | LM_DBG("message body has length zero: %p\n", _m->body); |
| 693 | return NULL; |
| 694 | } |
| 695 | |
| 696 | ret = NULL; |
| 697 | |
| 698 | /* iterate all body parts and look for the SDP mime */ |
| 699 | for( part=&_m->body->first ; part ; part=part->next) { |
| 700 | |
| 701 | /* skip body parts which were deleted or newly added */ |
| 702 | if (!is_body_part_received(part)) |
| 703 | continue; |
| 704 | |
| 705 | if ( part->mime != ((TYPE_APPLICATION<<16)+SUBTYPE_SDP) ) |
| 706 | continue; |
| 707 | |
| 708 | if (part->parsed) { |
| 709 | if (!ret) |
| 710 | ret = part->parsed; |
| 711 | continue; |
| 712 | } |
| 713 | |
| 714 | if ( (sdp=new_sdp())==NULL ) { |
| 715 | LM_ERR("Can't create new sdp, skipping\n"); |
| 716 | } else { |
| 717 | if (parse_sdp_session(&part->body, 0, NULL, sdp)<0) { |
| 718 | LM_ERR("failed to parse SDP for body part, skipping\n"); |
| 719 | free_sdp( sdp ); |
| 720 | } else { |
| 721 | part->parsed = (void*)sdp; |
| 722 | part->free_parsed_f = (free_parsed_part_function)free_sdp; |
| 723 | /* remember the first found SDP */ |
| 724 | if (!ret) ret = sdp; |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | return ret; |
| 730 | } |
| 731 | |
| 732 | void free_sdp_content(sdp_info_t* sdp) |
| 733 | { |
no test coverage detected