Esempio n. 1
0
File: csp_io.c Progetto: janbre/NUTS
int csp_send(csp_conn_t * conn, csp_packet_t * packet, uint32_t timeout) {

    int ret;

    if ((conn == NULL) || (packet == NULL) || (conn->state != CONN_OPEN)) {
        csp_log_error("Invalid call to csp_send\r\n");
        return 0;
    }

#ifdef CSP_USE_RDP
    if (conn->idout.flags & CSP_FRDP) {
        if (csp_rdp_send(conn, packet, timeout) != CSP_ERR_NONE) {
            csp_route_t * ifout = csp_route_if(conn->idout.dst);
            if (ifout != NULL && ifout->interface != NULL)
                ifout->interface->tx_error++;
            csp_log_warn("RDP send failed\r\n!");
            return 0;
        }
    }
#endif

    ret = csp_send_direct(conn->idout, packet, timeout);

    return (ret == CSP_ERR_NONE) ? 1 : 0;

}
Esempio n. 2
0
/**
 * Send a packet on an already established connection
 * @param conn pointer to connection
 * @param packet pointer to packet,
 * @param timeout a timeout to wait for TX to complete. NOTE: not all underlying drivers supports flow-control.
 * @return returns 1 if successful and 0 otherwise. you MUST free the frame yourself if the transmission was not successful.
 */
int csp_send(csp_conn_t * conn, csp_packet_t * packet, unsigned int timeout) {

	if ((conn == NULL) || (packet == NULL) || (conn->state != CONN_OPEN)) {
		csp_debug(CSP_ERROR, "Invalid call to csp_send\r\n");
		return 0;
	}

#if CSP_USE_RDP

	int result = 1;
	switch(conn->idout.protocol) {
	case CSP_RDP:
		result = csp_rdp_send(conn, packet, timeout);
		break;
	default:
		break;
	}
	if (result == 0) {
		csp_debug(CSP_WARN, "RPD send failed\r\n!");
		return 0;
	}

#endif

	return csp_send_direct(conn->idout, packet, timeout);

}