// Get the SDP message from SIP message and check it's Content-Type // return -1 on error, 0 if empty message, 1 if message present and not empty static int getSDPMessage(struct sip_msg *msg, str *sdp) { sdp->s = get_body(msg); if (sdp->s==NULL) { LOG(L_ERR, "error: mediaproxy/getSDPMessage(): cannot get the SDP body from SIP message\n"); return -1; } sdp->len = msg->buf + msg->len - sdp->s; if (sdp->len==0) { // 0 length body is ok for ACK messages if (!(msg->first_line.type == SIP_REQUEST && msg->first_line.u.request.method_value == METHOD_ACK)) { LOG(L_ERR, "error: mediaproxy/getSDPMessage(): SDP message has zero length\n"); } return 0; } if (!checkContentType(msg)) { LOG(L_ERR, "error: mediaproxy/getSDPMessage(): content type is not `application/sdp'\n"); return -1; } return 1; }
static int internalPut(WordPutData *put, DFNode *abstract, DFNode *concrete, int isNew) { if (abstract->tag != HTML_IMG) return 0; switch (concrete->tag) { case WORD_DRAWING: case WORD_PICT: case WORD_OBJECT: break; default: return 0; } const char *htmlSrc = DFGetAttribute(abstract,HTML_SRC); if ((htmlSrc == NULL) || !checkContentType(put->conv,htmlSrc)) return 0; char *htmlFilename = DFRemovePercentEncoding(htmlSrc); char *htmlPath = DFAppendPathComponent(put->conv->abstractPath,htmlFilename); int r = internalPut2(put,abstract,concrete,isNew,htmlSrc,htmlPath); free(htmlFilename); free(htmlPath); return r; }
// Get the SDP message from SIP message and check it's Content-Type // Return values: // 1 - success // -1 - error in getting body or invalid content type // -2 - empty message static int getSDPMessage(struct sip_msg *msg, str *sdp) { sdp->s = get_body(msg); if (sdp->s==NULL) { LM_ERR("cannot get the SDP body\n"); return -1; } sdp->len = msg->buf + msg->len - sdp->s; if (sdp->len == 0) return -2; if (!checkContentType(msg)) { LM_ERR("content type is not `application/sdp'\n"); return -1; } return 1; }