File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mtr / ui / raw.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:07:30 2021 UTC (3 years, 4 months ago) by misho
Branches: mtr, MAIN
CVS tags: v0_94, HEAD
mtr 0.94

    1: /*
    2:     mtr  --  a network diagnostic tool
    3:     Copyright (C) 1998  R.E.Wolff@BitWizard.nl
    4: 
    5:     raw.c -- raw output (for logging for later analysis)
    6: 
    7:     This program is free software; you can redistribute it and/or modify
    8:     it under the terms of the GNU General Public License version 2 as 
    9:     published by the Free Software Foundation.
   10: 
   11:     This program is distributed in the hope that it will be useful,
   12:     but WITHOUT ANY WARRANTY; without even the implied warranty of
   13:     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14:     GNU General Public License for more details.
   15: 
   16:     You should have received a copy of the GNU General Public License along
   17:     with this program; if not, write to the Free Software Foundation, Inc.,
   18:     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   19: */
   20: 
   21: #include "config.h"
   22: 
   23: #include <ctype.h>
   24: #include <stdlib.h>
   25: #include <stdio.h>
   26: #include <sys/types.h>
   27: #include <sys/socket.h>
   28: #include <netinet/in.h>
   29: #include <arpa/inet.h>
   30: 
   31: #include "mtr.h"
   32: #include "raw.h"
   33: #include "net.h"
   34: #include "dns.h"
   35: 
   36: 
   37: /* Log an echo request, or a "ping" */
   38: void raw_rawxmit(
   39:     int host,
   40:     int seq)
   41: {
   42:     printf("x %d %d\n", host, seq);
   43:     fflush(stdout);
   44: }
   45: 
   46: /* Log an echo reply, or a "pong" */
   47: void raw_rawping(
   48:     struct mtr_ctl *ctl,
   49:     int host,
   50:     int msec,
   51:     int seq)
   52: {
   53:     static int havename[MaxHost];
   54:     char *name;
   55: 
   56:     if (ctl->dns && !havename[host]) {
   57:         name = dns_lookup2(ctl, net_addr(host));
   58:         if (name) {
   59:             havename[host]++;
   60:             printf("d %d %s\n", host, name);
   61:         }
   62:     }
   63:     printf("p %d %d %d\n", host, msec, seq);
   64:     fflush(stdout);
   65: }
   66: 
   67: void raw_rawhost(
   68:     struct mtr_ctl *ctl,
   69:     int host,
   70:     ip_t *ip_addr,
   71:     struct mplslen *mpls)
   72: {
   73:     printf("h %d %s\n", host, strlongip(ctl, ip_addr));
   74:     if (ctl->enablempls) {
   75:         int k;
   76:         for (k = 0; k < mpls->labels; k++)
   77:             printf("m %d %lu %u %u %u\n",
   78:                    host, mpls->label[k], mpls->tc[k], mpls->s[k], mpls->ttl[k]);
   79:     }
   80: 
   81:     fflush(stdout);
   82: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>