/* * ping.c * * Functions handiling the generation and parsing of ping and pong packets. * * Copyright (c) 2004 Todd MacDermid * Jack Lloyd * */ #include #include #include int cutlass_ping(cutlass_t *cut_handle, conn_t *conn, struct timespec *now) { struct cutlass_packet_hdr header; /* Construct the stuff: ping packet, no contents */ header.cut_type = CUT_PING; header.channel_id = 0; header.length = 0; if(cutlass_send_process(cut_handle, conn, &header, NULL, 0) != 0) cutlass_sysmsg(cut_handle, CUT_ERROR, "cutlass_ping: cutlass_send failed\n"); memcpy(&(conn->last_ping_sent), now, sizeof(struct timespec)); return(0); } int cutlass_pong(cutlass_t *cut_handle, conn_t *conn, uint8_t *ping_packet, struct timespec *now) { struct cutlass_packet_hdr header; /* Construct the stuff: ping packet, no contents */ header.cut_type = CUT_PONG; header.channel_id = 0; header.length = 0; if(cutlass_send_process(cut_handle, conn, &header, NULL, 0) != 0) { cutlass_sysmsg(cut_handle, CUT_ERROR, "cutlass_pong: cutlass_send failed\n"); return(-1); } return(0); }