コード例 #1
0
ファイル: protocol.c プロジェクト: MuMu360121/jordan-kernel
/*
 * TransmitChannelSignal transmits a four int8 value to the channel
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * channel is the channel to be signaled
 * signal is the value to be delivered
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitChannelSignal(int8 acktype, int8 channel, int32 signal,
			    MUX *mux)
{
	COMMBUFF *commbuff;
	CHANNELSIGNAL_PACKET *packetdata;

	DEBUG("TransmitChannelSignal(%lu, %lu, %lu, %p)\n",
	      (int32) acktype, (int32) channel, signal, mux);

	commbuff = int_alloc_commbuff(sizeof(CHANNELSIGNAL_PACKET));

	packetdata = (CHANNELSIGNAL_PACKET *) commbuff_data(commbuff);
	packetdata->type = PACKETTYPE_CHANNELSIGNAL;

	commbuff_copyin_byte(commbuff,
			     offsetof(CHANNELSIGNAL_PACKET, acktype),
			     acktype);
	commbuff_copyin_byte(commbuff,
			     offsetof(CHANNELSIGNAL_PACKET, channel),
			     channel);
	commbuff_copyin_dword(commbuff,
			      offsetof(CHANNELSIGNAL_PACKET, signal),
			      signal);

	queue_commbuff(commbuff, &mux->send_queue);

	mux->total_queued_amount += sizeof(CHANNELSIGNAL_PACKET);

	task_schedule(&mux->send_task);

	return DEBUGERROR(ERROR_NONE);
}
コード例 #2
0
/*
 * TransmitCredit assembles a control credit packet and initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * channel is the channel the credit should be applied to
 * bytecredit is the amount the byte credit should be increased
 * sendcredit is the amount the send credit should be increased
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitCredit (int8 acktype, int8 channel, int32 bytecredit, int32 sendcredit, MUX* mux)
{
    COMMBUFF*      commbuff;
    CREDIT_PACKET* packetdata;

    DEBUG(
        "TransmitCredit(%lu, %lu, %lu, 0x%lu, %p)\n",
        (int32)acktype,
        (int32)channel,
        (int32)bytecredit,
        (int32)sendcredit,
        mux
    );

    commbuff = int_alloc_commbuff(sizeof(CREDIT_PACKET));

    convert_dword(bytecredit);
    convert_dword(sendcredit);

    packetdata       = (CREDIT_PACKET*)commbuff_data(commbuff);
    packetdata->type = PACKETTYPE_CREDIT;

    commbuff_copyin_byte(commbuff, offsetof(CREDIT_PACKET, acktype), acktype);
    commbuff_copyin_byte(commbuff, offsetof(CREDIT_PACKET, channel), channel);
    commbuff_copyin_dword(commbuff, offsetof(CREDIT_PACKET, bytecredit), bytecredit);
    commbuff_copyin_dword(commbuff, offsetof(CREDIT_PACKET, sendcredit), sendcredit);

    queue_commbuff(commbuff, &mux->send_queue);

    mux->total_queued_amount += sizeof(CREDIT_PACKET);

    task_schedule(&mux->send_task);

    return DEBUGERROR(ERROR_NONE);
}
コード例 #3
0
/*
 * TransmitDisableChannel assembles a control disable channel packet and initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * channel is the channel to be disabled
 * host_interface is the interface which belongs to the host and is requesting the disable
 * client_interface is the interface which belongs to the client and is responding to the disable
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitDisableChannel (int8 acktype, int8 channel, int8 host_interface, int8 client_interface, MUX* mux)
{
    COMMBUFF*              commbuff;
    DISABLECHANNEL_PACKET* packetdata;

    DEBUG("TransmitDisableChannel(%lu, %lu, %lu, %lu, %p)\n", (int32)acktype, (int32)channel, (int32)host_interface, (int32)client_interface, mux);

    commbuff = int_alloc_commbuff(sizeof(DISABLECHANNEL_PACKET));

    packetdata       = (DISABLECHANNEL_PACKET*)commbuff_data(commbuff);
    packetdata->type = PACKETTYPE_DISABLECHANNEL;

    commbuff_copyin_byte(commbuff, offsetof(DISABLECHANNEL_PACKET, acktype), acktype);
    commbuff_copyin_byte(commbuff, offsetof(DISABLECHANNEL_PACKET, channel), channel);
    commbuff_copyin_byte(commbuff, offsetof(DISABLECHANNEL_PACKET, host_interface), host_interface);
    commbuff_copyin_byte(commbuff, offsetof(DISABLECHANNEL_PACKET, client_interface), client_interface);

    queue_commbuff(commbuff, &mux->send_queue);

    mux->total_queued_amount += sizeof(DISABLECHANNEL_PACKET);

    task_schedule(&mux->send_task);

    return DEBUGERROR(ERROR_NONE);
}
コード例 #4
0
/*
 * TransmitQueryInterface assembles a control query interface packet and initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * host_interface is the interface which belongs to the host of the query
 * result is the resultant interface id which is relevent only when acktype is host_end(SUCCESS)
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitQueryInterface (int8 acktype, int8 host_interface, int8 result, sint8* name, MUX* mux)
{
    COMMBUFF*              commbuff;
    QUERYINTERFACE_PACKET* packetdata;
    int32                  namesize;

    DEBUG("TransmitQueryInterface(%lu, %lu, %lu, %p, %p)\n", (int32)acktype, (int32)host_interface, (int32)result, name, mux);

    if(name)
        namesize = strlen((char*)name)+1;
    else
        namesize = 0;

    if(namesize > PACKET_MAXNAME_LENGTH)
        return DEBUGERROR(ERROR_INVALIDPARAMETER);

    commbuff = int_alloc_commbuff(sizeof(QUERYINTERFACE_PACKET));

    packetdata       = (QUERYINTERFACE_PACKET*)commbuff_data(commbuff);
    packetdata->type = PACKETTYPE_QUERYINTERFACE;

    commbuff_copyin_byte(commbuff, offsetof(QUERYINTERFACE_PACKET, acktype), acktype);
    commbuff_copyin_byte(commbuff, offsetof(QUERYINTERFACE_PACKET, host_interface), host_interface);
    commbuff_copyin_byte(commbuff, offsetof(QUERYINTERFACE_PACKET, result), result);
    commbuff_copyin(commbuff, offsetof(QUERYINTERFACE_PACKET, name), name, namesize);

    queue_commbuff(commbuff, &mux->send_queue);

    mux->total_queued_amount += sizeof(QUERYINTERFACE_PACKET);

    task_schedule(&mux->send_task);

    return DEBUGERROR(ERROR_NONE);
}
コード例 #5
0
/*
 * TransmitDisableMUX assembles a control disable mux packet and initializes the transmit procedure
 *
 * Params:
 * acktype specifies host or client as well as failure or success
 * mux is the MUX object the data is to be transmitted through
 */
int32 TransmitDisableMUX (int8 acktype, MUX* mux)
{
    COMMBUFF*          commbuff;
    DISABLEMUX_PACKET* packetdata;

    DEBUG("TransmitDisableMUX(%lu, %p)\n", (int32)acktype, mux);

    commbuff = int_alloc_commbuff(sizeof(DISABLEMUX_PACKET));

    packetdata       = (DISABLEMUX_PACKET*)commbuff_data(commbuff);
    packetdata->type = PACKETTYPE_DISABLEMUX;

    commbuff_copyin_byte(commbuff, offsetof(DISABLEMUX_PACKET, acktype), acktype);

    queue_commbuff(commbuff, &mux->send_queue);

    mux->total_queued_amount += sizeof(DISABLEMUX_PACKET);

    task_schedule(&mux->send_task);

    return DEBUGERROR(ERROR_NONE);
}