Ejemplo n.º 1
0
SOAP_FMAC5 int SOAP_FMAC6 soap_recv___cwmp__Fault(struct soap *soap, struct __cwmp__Fault *_param_1)
{
	soap_default___cwmp__Fault(soap, _param_1);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get___cwmp__Fault(soap, _param_1, "-cwmp:Fault", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_NO_METHOD;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
Ejemplo n.º 2
0
SOAP_FMAC5 int SOAP_FMAC6 soap_recv_d__ProbeMatches(struct soap *soap, struct d__ProbeMatches *_param_2)
{
	soap_default_d__ProbeMatches(soap, _param_2);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get_d__ProbeMatches(soap, _param_2, "d:ProbeMatches", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_NO_METHOD;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
Ejemplo n.º 3
0
SOAP_FMAC5 int SOAP_FMAC6 soap_recv_ns__sendString(struct soap *soap, struct ns__sendString *_param_1)
{
	soap_default_ns__sendString(soap, _param_1);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get_ns__sendString(soap, _param_1, "ns:sendString", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_NO_METHOD;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
Ejemplo n.º 4
0
int dpws_discoveryProxy::recv_ResolveMatches(struct __wsd__ResolveMatches& tmp)
{
	struct soap *soap = this;
	struct __wsd__ResolveMatches *_param_6 = &tmp;
	soap_default___wsd__ResolveMatches(soap, _param_6);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get___wsd__ResolveMatches(soap, _param_6, "-wsd:ResolveMatches", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_NO_METHOD;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
int WSDualHttpBinding_USCOREICalculatorDuplexProxy::recv_Equation(struct __tempuri__Equation& tmp)
{	struct soap *soap = this->soap;

	struct __tempuri__Equation *_param_7 = &tmp;
	soap_default___tempuri__Equation(soap, _param_7);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get___tempuri__Equation(soap, _param_7, "-tempuri:Equation", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_OK;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
int PullPointSubscriptionBindingProxy::recv_Notify_(struct __tev__Notify_& tmp)
{	struct soap *soap = this->soap;

	struct __tev__Notify_ *_param_15 = &tmp;
	soap_default___tev__Notify_(soap, _param_15);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get___tev__Notify_(soap, _param_15, "-tev:Notify", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_OK;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
Ejemplo n.º 7
0
int wsddProxy::recv_Resolve(struct __wsdd__Resolve& tmp)
{	struct soap *soap = this;

	struct __wsdd__Resolve *_param_6 = &tmp;
	soap_default___wsdd__Resolve(soap, _param_6);
	soap_begin(soap);
	if (soap_begin_recv(soap)
	 || soap_envelope_begin_in(soap)
	 || soap_recv_header(soap)
	 || soap_body_begin_in(soap))
		return soap_closesock(soap);
	soap_get___wsdd__Resolve(soap, _param_6, "-wsdd:Resolve", NULL);
	if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
		soap->error = SOAP_OK;
	if (soap->error
	 || soap_body_end_in(soap)
	 || soap_envelope_end_in(soap)
	 || soap_end_recv(soap))
		return soap_closesock(soap);
	return soap_closesock(soap);
}
Ejemplo n.º 8
0
int soap_parser_decode(void *handle, const char *xml)
{
    SoapParser *parser = (SoapParser *)handle;
    struct soap *soap;
    int fd[2];

    if (parser == NULL) {
        return -1;
    }
    if (xml == NULL) {
        LOGE(LOG_TAG, "input xml is empty");
        return -1;
    }

    soap = parser->soap;
    pipe(fd);

    /*soap_init(soap);*/
    soap_init1(soap, SOAP_XML_IGNORENS);
    soap_set_namespaces(soap, namespaces);

    soap->socket = -1;
    soap->recvfd = fd[0];
    write(fd[1], xml, strlen(xml));
    close(fd[1]);

    if (soap_begin_recv(soap) != 0
        || soap_envelope_begin_in(soap) != 0) {
        LOGE(LOG_TAG, "begin decode failed, error=%d", soap->error);
        return -1;
    }

    if (soap_recv_header(soap) != 0) {
        LOGE(LOG_TAG, "decode soap header failed, %d", soap->error);
        return -1;
    }
    _soap_header_parse(soap->header,
                       &(parser->id),
                       &(parser->hold_requests),
                       &(parser->session_timeout),
                       &(parser->supported_cwmp_versions),
                       &(parser->use_cwmp_version));

    if (soap_body_begin_in(soap) != 0) {
        LOGE(LOG_TAG, "decode soap body failed, %d", soap->error);
        return -1;
    }

    parser->_namespaces = _soap_namespaces_parse(soap);
    parser->namespaces = parser->_namespaces;
    parser->version = _soap_version_parse(xml, parser->namespaces);
    if (parser->version == CWMP_VERSION_1_2) {
        if (parser->supported_cwmp_versions != 0 && parser->use_cwmp_version != 0) {
            parser->version = CWMP_VERSION_1_4;
        } else if (parser->session_timeout > 0) {
            parser->version = CWMP_VERSION_1_3;
        }
    }

    if (soap_recv_fault(soap, 1) != 0) {
        parser->type = CWMP_MSG_FAULT;
        _soap_fault_dump(soap->fault);
        if (soap->fault != NULL
            && soap->fault->detail != NULL
            && soap->fault->detail->__type == SOAP_TYPE__cwmp__Fault) {
            struct _cwmp__Fault *cwmp_fault;
            cwmp_fault = (struct _cwmp__Fault *)soap->fault->detail->fault;
            if (cwmp_fault != NULL) {
                if (cwmp_fault->FaultCode != NULL) {
                    parser->fault_code = atoi(cwmp_fault->FaultCode);
                }
                parser->fault_string = cwmp_fault->FaultString;
                parser->fault_body = cwmp_fault;
                parser->body = cwmp_fault;
            }
        }
        return 0;
    }

    int gsoap_type;
    parser->body = soap_getelement(soap, &gsoap_type);
    parser->type = _get_cwmp_type(gsoap_type);
    if (soap->error) {
        LOGE(LOG_TAG, "get cwmp body failed, error=%d", soap->error);
        return -1;
    }

    if (soap_body_end_in(soap)
        || soap_envelope_end_in(soap)
        || soap_end_recv(soap)) {
        LOGE(LOG_TAG, "end decode failed, %d", soap->error);
        return -1;
    }
    close(fd[0]);

    return 0;
}
Ejemplo n.º 9
0
/**
 * xml -> body
 * @param[in] handle: parser
 * @param[in] xml: the xml to be decoded
 * @param[out] id: cpe's id? I don't know
 * @param[out] hold_request: hold
 * @param[out] type: SOAP/RPC type
 * @param[out] body: the result get from xml
 */
int soap_parser_decode(void *handle, const char *xml,
                       int *id, int *hold_requests, int *type, void **body)
{
    struct soap_parser *parser = (struct soap_parser *)handle;
    struct soap *soap = parser->soap;
    int fd[2];

    if (xml == NULL) {
        return -1;
    }

    /*LOGD(parser->tag, xml);*/

    pipe(fd);

    *id = 0;
    *hold_requests = 0;
    *type = 0;
    *body = NULL;

    soap_init(soap);
    soap->socket = -1;
    soap->recvfd = fd[0];
    write(fd[1], xml, strlen(xml));
    close(fd[1]);

    if (soap_begin_recv(soap)
        || soap_envelope_begin_in(soap)
        || soap_recv_header(soap)
        || soap_body_begin_in(soap)) {
        return -1;
    }

    if (soap->header != NULL) {
        if (soap->header->__HoldRequests != NULL) {
            *hold_requests = soap->header->__HoldRequests->__item;
        }
        if (soap->header->__ID != NULL) {
            if (soap->header->__ID->__item != NULL) {
                *id = atoi(soap->header->__ID->__item);
            }
        }
    }

    if (soap_recv_fault(soap, 1)) {
        LOGE(parser->tag, "FaultCode=%s, FaultString=%s",
             soap->fault->faultcode, soap->fault->faultstring);
        *type = SOAP_TYPE__ns1__Fault;
        if (soap->fault != NULL && soap->fault->detail != NULL) {
            *body = soap->fault->detail->__any;
        }
        return 0;
    }

    *body = soap_getelement(soap, type);
    if (soap->error) {
        return -1;
    }

    if (soap_body_end_in(soap)
        || soap_envelope_end_in(soap)
        || soap_end_recv(soap)) {
        return -1;
    }
    ////soap_end(soap);
    //soap_free(soap);
    close(fd[0]);

    if (soap->header != NULL) {
        if (soap->header->__ID != NULL) {
            LOGV(parser->tag, "soap header: ID=%s(%s)",
                 soap->header->__ID->__item,
                 soap->header->__ID->SOAP_ENV__mustUnderstand);
        }
        if (soap->header->__HoldRequests != NULL) {
            LOGV(parser->tag, "soap header: HoldRequests=%s(%s)",
                 soap->header->__HoldRequests->__item,
                 soap->header->__HoldRequests->SOAP_ENV__mustUnderstand);
        }
    }
    return 0;
}
Ejemplo n.º 10
0
void process_requests(int server_s, struct soap *soap)/*by SeanHou*/
{
    /* :TODO:Monday, December 01, 2014 11:17:36 HKT:SeanHou:  */
    int OnvifEN = 0;
    int lookupindex = 0;
    char service_uri[100] = "";

    memset((void*)&soap->peer, 0, sizeof(soap->peer));
    soap->socket = SOAP_INVALID_SOCKET;
    soap->error  = SOAP_OK;
    soap->errmode = 0;
    soap->keep_alive = 0;

    fprintf(stderr, "Warning:" \
            "(==>%s).\n", __func__);

    /* :TODO:End---  */
    int retval = 0;
    request *current, *trailer;

    if (pending_requests) {
        get_request(server_s);
#ifdef ORIGINAL_BEHAVIOR
        pending_requests = 0;
#endif
    }

    current = request_ready;

    while (current) {
        /* :TODO:Monday, December 01, 2014 11:18:42 HKT:SeanHou: juge is onvif */
        OnvifEN = isonvif(current->client_stream, service_uri, &lookupindex);
        if(OnvifEN == 1)
        {
            fprintf(stderr, "[boa:onvif] Warning: is onvif line[%d]remote port[%d]h2ns[%d]remote ip[%s]\n", __LINE__, current->remote_port, htons(current->remote_port), current->remote_ip_addr);
            struct sockaddr_in onvif_client_addr;
            memset(&onvif_client_addr, 0, sizeof(onvif_client_addr));
            onvif_client_addr.sin_family = AF_INET;
            onvif_client_addr.sin_port = htons(current->remote_port);//随机端口
            onvif_client_addr.sin_addr.s_addr = inet_addr(current->remote_ip_addr);//

            soap->socket = current->fd;
            soap->peer = onvif_client_addr;
            if (soap_valid_socket(soap->socket))
            {
                soap->ip = ntohl(soap->peer.sin_addr.s_addr);
                soap->port = (int)ntohs(soap->peer.sin_port);
                soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
            }


            g_onvif_buffer = (char *)soap_malloc(soap, sizeof(current->client_stream));
            strcpy(g_onvif_buffer, current->client_stream);//mark

            soap_begin_recv(soap);
            if (soap_envelope_begin_in(soap))
            {
                soap_send_fault(soap);
            }
            if (soap_recv_header(soap))
            {
                soap_send_fault(soap);
            }
            if (soap_body_begin_in(soap))
            {
                soap_send_fault(soap);
            }

            int errorCode = 0;
            if (errorCode = soap_serve_request(soap))
            {
                fprintf(stderr, "[boa:onvif]soap_serve_request fail, errorCode %d \n", errorCode);
                soap_send_fault(soap);
            }

            memset(current->client_stream, 0, CLIENT_STREAM_SIZE );

            soap_dealloc(soap, NULL);
            soap_destroy(soap);      
            soap_end(soap);
            current->status = DONE;
            close(soap->socket);
            continue;
        }
        /* :TODO:End---  */
        time(&current_time);
        if (current->buffer_end && /* there is data in the buffer */
                current->status != DEAD && current->status != DONE) {
            retval = req_flush(current);
            /*
             * retval can be -2=error, -1=blocked, or bytes left
             */
            if (retval == -2) { /* error */
                current->status = DEAD;
                retval = 0;
            } else if (retval >= 0) {
                /* notice the >= which is different from below?
                   Here, we may just be flushing headers.
                   We don't want to return 0 because we are not DONE
                   or DEAD */

                retval = 1;
            }
        } else {
            switch (current->status) {
                case READ_HEADER:
                case ONE_CR:
                case ONE_LF:
                case TWO_CR:
                    retval = read_header(current);
                    break;
                case BODY_READ:
                    retval = read_body(current);
                    break;
                case BODY_WRITE:
                    retval = write_body(current);
                    break;
                case WRITE:
                    retval = process_get(current);
                    break;
                case PIPE_READ:
                    retval = read_from_pipe(current);
                    break;
                case PIPE_WRITE:
                    retval = write_from_pipe(current);
                    break;
                case DONE:
                    /* a non-status that will terminate the request */
                    retval = req_flush(current);
                    /*
                     * retval can be -2=error, -1=blocked, or bytes left
                     */
                    if (retval == -2) { /* error */
                        current->status = DEAD;
                        retval = 0;
                    } else if (retval > 0) {
                        retval = 1;
                    }
                    break;
                case DEAD:
                    retval = 0;
                    current->buffer_end = 0;
                    SQUASH_KA(current);
                    break;
                default:
                    retval = 0;
                    fprintf(stderr, "Unknown status (%d), "
                            "closing!\n", current->status);
                    current->status = DEAD;
                    break;
            }

        }

        if (sigterm_flag)
            SQUASH_KA(current);

        /* we put this here instead of after the switch so that
         * if we are on the last request, and get_request is successful,
         * current->next is valid!
         */
        if (pending_requests)
            get_request(server_s);

        switch (retval) {
            case -1:               /* request blocked */
                trailer = current;
                current = current->next;
                block_request(trailer);
                break;
            case 0:                /* request complete */
                current->time_last = current_time;
                trailer = current;
                current = current->next;
                free_request(&request_ready, trailer);
                break;
            case 1:                /* more to do */
                current->time_last = current_time;
                current = current->next;
                break;
            default:
                log_error_time();
                fprintf(stderr, "Unknown retval in process.c - "
                        "Status: %d, retval: %d\n", current->status, retval);
                current = current->next;
                break;
        }
    }
}