Exemplo n.º 1
0
/* returns error */
static int APP_CC
process_message(void)
{
    struct stream *s = (struct stream *)NULL;
    int size = 0;
    int id = 0;
    int rv = 0;
    char *next_msg = (char *)NULL;

    if (g_con_trans == 0)
    {
        return 1;
    }

    s = trans_get_in_s(g_con_trans);

    if (s == 0)
    {
        return 1;
    }

    rv = 0;

    while (s_check_rem(s, 8))
    {
        next_msg = s->p;
        in_uint32_le(s, id);
        in_uint32_le(s, size);
        next_msg += size;

        switch (id)
        {
            case 1: /* init */
                rv = process_message_init(s);
                break;
            case 3: /* channel setup */
                rv = process_message_channel_setup(s);
                break;
            case 5: /* channel data */
                rv = process_message_channel_data(s);
                break;
            case 7: /* channel data response */
                rv = process_message_channel_data_response(s);
                break;
            default:
                LOGM((LOG_LEVEL_ERROR, "process_message: error in process_message ",
                      "unknown msg %d", id));
                break;
        }

        if (rv != 0)
        {
            break;
        }

        s->p = next_msg;
    }

    return rv;
}
Exemplo n.º 2
0
/* returns error */
	static int APP_CC
process_message(void)
{
	struct stream* s;
	int size;
	int id;
	int rv;
	char* next_msg;

	if (g_con_trans == 0)
	{
		return 1;
	}
	s = trans_get_in_s(g_con_trans);
	if (s == 0)
	{
		return 1;
	}
	rv = 0;
	while (s_check_rem(s, 8))
	{
		next_msg = s->p;
		in_uint32_le(s, id);
		in_uint32_le(s, size);
		next_msg += size;
		switch (id)
		{
			case 1: /* init */
				rv = process_message_init(s);
				break;
			case 3: /* channel setup */
				rv = process_message_channel_setup(s);
				break;
			case 5: /* channel data */
				rv = process_message_channel_data(s);
				break;
			case 7: /* channel data response */
				rv = process_message_channel_data_response(s);
				break;
			default:
				log_message(&log_conf, LOG_LEVEL_DEBUG, "chansrv[process_message]: "
						"unknown msg %d", id);
				break;
		}
		if (rv != 0)
		{
			break;
		}
		s->p = next_msg;
	}
	return rv;
}