Blame ui/cmdpipe.h

Packit b802ec
/*
Packit b802ec
    mtr  --  a network diagnostic tool
Packit b802ec
    Copyright (C) 2016  Matt Kimball
Packit b802ec
Packit b802ec
    This program is free software; you can redistribute it and/or modify
Packit b802ec
    it under the terms of the GNU General Public License version 2 as
Packit b802ec
    published by the Free Software Foundation.
Packit b802ec
Packit b802ec
    This program is distributed in the hope that it will be useful,
Packit b802ec
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b802ec
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b802ec
    GNU General Public License for more details.
Packit b802ec
Packit b802ec
    You should have received a copy of the GNU General Public License
Packit b802ec
    along with this program; if not, write to the Free Software
Packit b802ec
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit b802ec
*/
Packit b802ec
Packit b802ec
#ifndef CMDPIPE_H
Packit b802ec
#define CMDPIPE_H
Packit b802ec
Packit b802ec
#include "mtr.h"
Packit b802ec
Packit b802ec
#define COMMAND_BUFFER_SIZE 4096
Packit b802ec
#define PACKET_REPLY_BUFFER_SIZE 4096
Packit b802ec
Packit b802ec
/*  We use a pipe to the mtr-packet subprocess to generate probes  */
Packit b802ec
struct packet_command_pipe_t {
Packit b802ec
    /*  the process id of mtr-packet  */
Packit b802ec
    pid_t pid;
Packit b802ec
Packit b802ec
    /*  the end of the pipe we read for replies  */
Packit b802ec
    int read_fd;
Packit b802ec
Packit b802ec
    /*  the end of the pipe we write for commands  */
Packit b802ec
    int write_fd;
Packit b802ec
Packit b802ec
    /* storage for incoming replies */
Packit b802ec
    char reply_buffer[PACKET_REPLY_BUFFER_SIZE];
Packit b802ec
Packit b802ec
    /*  the number of bytes currently used in reply_buffer  */
Packit b802ec
    size_t reply_buffer_used;
Packit b802ec
};
Packit b802ec
Packit b802ec
typedef
Packit b802ec
void (
Packit b802ec
    *probe_reply_func_t) (
Packit b802ec
    struct mtr_ctl * ctl,
Packit b802ec
    int sequence,
Packit b802ec
    struct mplslen * mpls,
Packit b802ec
    ip_t * addr,
Packit b802ec
    int round_trip_time);
Packit b802ec
Packit b802ec
int open_command_pipe(
Packit b802ec
    struct mtr_ctl *ctl,
Packit b802ec
    struct packet_command_pipe_t *cmdpipe);
Packit b802ec
Packit b802ec
void close_command_pipe(
Packit b802ec
    struct packet_command_pipe_t *cmdpipe);
Packit b802ec
Packit b802ec
void send_probe_command(
Packit b802ec
    struct mtr_ctl *ctl,
Packit b802ec
    struct packet_command_pipe_t *cmdpipe,
Packit b802ec
    ip_t * address,
Packit b802ec
    ip_t * localaddress,
Packit b802ec
    int packet_size,
Packit b802ec
    int sequence,
Packit b802ec
    int time_to_live);
Packit b802ec
Packit b802ec
void handle_command_replies(
Packit b802ec
    struct mtr_ctl *ctl,
Packit b802ec
    struct packet_command_pipe_t *cmdpipe,
Packit b802ec
    probe_reply_func_t reply_func);
Packit b802ec
Packit b802ec
#endif