Ejemplo n.º 1
0
void ProcessRequestSocket(int fd)
{
    XdmcpHeader header;
#if defined(IPv6) && defined(AF_INET6)
    struct sockaddr_storage addr;
#else
    struct sockaddr addr;
#endif
    int addrlen = sizeof(addr);

    Debug("ProcessRequestSocket\n");
    bzero((char *)&addr, sizeof(addr));
    if(!XdmcpFill(fd, &buffer, (XdmcpNetaddr)&addr, &addrlen))
    {
        Debug("XdmcpFill failed\n");
        return;
    }
    if(!XdmcpReadHeader(&buffer, &header))
    {
        Debug("XdmcpReadHeader failed\n");
        return;
    }
    if(header.version != XDM_PROTOCOL_VERSION)
    {
        Debug("XDMCP header version read was %d, expected %d\n", header.version, XDM_PROTOCOL_VERSION);
        return;
    }
    Debug("header: %d %d %d\n", header.version, header.opcode, header.length);
    switch(header.opcode)
    {
        case BROADCAST_QUERY:
            broadcast_respond((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case QUERY:
            query_respond((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case INDIRECT_QUERY:
            indirect_respond((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case FORWARD_QUERY:
            forward_respond((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case REQUEST:
            request_respond((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case MANAGE:
            manage((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
        case KEEPALIVE:
            send_alive((struct sockaddr *)&addr, addrlen, header.length, fd);
            break;
    }
}
Ejemplo n.º 2
0
static void
receive_packet(int socketfd)
{
#if defined(IPv6) && defined(AF_INET6)
    struct sockaddr_storage from;
#else
    struct sockaddr_in from;
#endif
    int fromlen = sizeof(from);
    XdmcpHeader header;

    /* read message off socket */
    if (!XdmcpFill(socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
        return;

    /* reset retransmission backoff */
    timeOutRtx = 0;

    if (!XdmcpReadHeader(&buffer, &header))
        return;

    if (header.version != XDM_PROTOCOL_VERSION)
        return;

    switch (header.opcode) {
    case WILLING:
        recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
        break;
    case UNWILLING:
        XdmcpFatal("Manager unwilling", &UnwillingMessage);
        break;
    case ACCEPT:
        recv_accept_msg(header.length);
        break;
    case DECLINE:
        recv_decline_msg(header.length);
        break;
    case REFUSE:
        recv_refuse_msg(header.length);
        break;
    case FAILED:
        recv_failed_msg(header.length);
        break;
    case ALIVE:
        recv_alive_msg(header.length);
        break;
    }
}