int RTIP_SOCKETS_Driver::SendTo( SOCK_SOCKET s, const char* buf, int len, int flags, const SOCK_sockaddr* to, int tolen )
{ 
    NATIVE_PROFILE_PAL_NETWORK();
    int    ret;
    UINT32 ipAddr;
    int    port;

    if(to == NULL)
    {
        set_errno(EINVAL);
        return SOCK_SOCKET_ERROR;
    }
    
    ipAddr = ((SOCK_sockaddr_in *) to)->sin_addr.S_un.S_addr;
    port   = ((SOCK_sockaddr_in *) to)->sin_port;

    ret = rtp_net_sendto ((RTP_HANDLE) s,
                                (const unsigned char *) buf, 
                                len,
                                (unsigned char *)&ipAddr,
                                port, 
                                RTP_NET_TYPE_IPV4,
                                flags);

    return ret;
}
Esempio n. 2
0
SSDP_INT32 SSDP_SendResponse (
    SSDPServerContext *ctx,       /** pointer to SSDP context */
    SSDPPendingResponse *response /** buffer holding response information */)
{
    SSDP_CHAR     *msgBuffer;
    SSDP_SOCKET    responseSock = ctx->announceSocket;

    msgBuffer = (SSDP_CHAR *) rtp_malloc(sizeof(SSDP_CHAR) * SSDP_BUFFER_SIZE);

    if (msgBuffer)
    {
        /* Send response */
        rtp_sprintf(msgBuffer,"HTTP/1.1 200 OK\r\n"
                    "LOCATION: %s\r\n"
                    "EXT: \r\n"
                    "USN: %s\r\n"
                    "SERVER: %s\r\n"
                    "CACHE-CONTROL: max-age=%d\r\n"
                    "ST: %s\r\n"
                    "\r\n",
                    response->targetLocation,
                    response->targetUSN,
                    ctx->serverName,
                    response->targetTimeoutSec,
                    response->searchTarget);

        RTP_LOG_WRITE("SSDPSendResponse SEND", msgBuffer, rtp_strlen(msgBuffer))

        /* Send response to the requesting client */
        if (rtp_net_sendto(responseSock, (unsigned char*)msgBuffer,
                           rtp_strlen(msgBuffer),
                           response->clientAddr.ipAddr,
                           response->clientAddr.port,
                           response->clientAddr.type) < 0)
        {
            SSDP_ProcessError("Response");
            rtp_free(msgBuffer);
            return(-1);
        }

        /* Free up the allocated memory */
        rtp_free(msgBuffer);
    }
    else
    {
        return (-1);
Esempio n. 3
0
int rtsmb_net_write_datagram (RTP_SOCKET socket, PFBYTE remote, int port, PFVOID buf, int size)
{
    int bytes_sent;
    int rv = 0;

    do
    {
        bytes_sent = rtp_net_sendto(socket, buf,size,remote,port, 4);

        if (bytes_sent < 0) /* an error occurred */
        {
            rv = -1;
            break;
        }

        size -= bytes_sent;
        buf = PADD (buf, bytes_sent);

    } while (size > 0);

    return rv;
}
Esempio n. 4
0
SSDP_INT32 SSDP_SendByebye (
    SSDPServerContext *ctx,         /** pointer to SSDP context */
    const SSDP_CHAR *notifyType,    /** the notification type (NT) string */
    const SSDP_CHAR *usn           /** pointer to string containing USN header */)
{
    SSDP_CHAR     ipAddr[RTP_NET_NI_MAXHOST];
    SSDP_CHAR     *msgBfr;
    SSDP_SOCKET    notifySock = ctx->announceSocket;

    if(ctx->ipType == RTP_NET_TYPE_IPV6)
    {
        rtp_sprintf(ipAddr, "[FF02::C]:1900");
    }
    else if (ctx->ipType == RTP_NET_TYPE_IPV4)
    {
        rtp_sprintf(ipAddr, "239.255.255.250:1900");
    }

    msgBfr = (SSDP_CHAR *) rtp_malloc(sizeof(SSDP_CHAR) * SSDP_BUFFER_SIZE);

    if (!msgBfr)
    {
        return (-1);
    }

    /* Send Advertisements */

    /* Fix (03/18/2007) - Correct formatting changed format fields from:
                      "HOST:%s\r\n"
                      "Cache-Control:max-age=%d\r\n"
                      "Location:%s\r\n"
                      "NT:%s\r\n"
                      "NTS:%s\r\n"
                      "Server:%s\r\n"
                      "USN:%s\r\n"

    */
#if (USE_INTEL_SDK_ORDER)
    rtp_sprintf(msgBfr,"NOTIFY * HTTP/1.1\r\n"
                "HOST: %s\r\n"
                "NTS: ssdp:byebye\r\n"
                "USN: %s\r\n"
                "NT: %s\r\n"
                "\r\n",
                ipAddr,
                usn,
                notifyType);
#else
    rtp_sprintf(msgBfr,"NOTIFY * HTTP/1.1\r\n"
                "HOST: %s\r\n"
                "NT: %s\r\n"
                "NTS: ssdp:byebye\r\n"
                "USN: %s\r\n"
                "\r\n",
                ipAddr,
                notifyType,
                usn);
#endif
    if(ctx->ipType == RTP_NET_TYPE_IPV6)
    {
        rtp_strcpy(ipAddr, IPV6_LINK_LOCAL_ADDRESS);
    }
    else if (ctx->ipType == RTP_NET_TYPE_IPV4)
    {
        rtp_strcpy(ipAddr, (const char*)v4mcastAddr);
    }
    RTP_LOG_WRITE("SSDP_SendByeBye SEND", msgBfr, rtp_strlen(msgBfr))
    /* Send the message to the multicast channel */
    if (rtp_net_sendto(notifySock, (unsigned char*)msgBfr, rtp_strlen(msgBfr),(unsigned char *) ipAddr, mcastPort, ctx->ipType) < 0)
    {
        SSDP_ProcessError("SendTo");
        rtp_free(msgBfr);
        return(-1);
    }

    /* Free up the allocated memory */
    rtp_free(msgBfr);
    return(0);
}