Annotation of embedaddon/mtr/ui/raw.c, revision 1.1.1.3

1.1       misho       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
1.1.1.3 ! misho       8:     it under the terms of the GNU General Public License version 2 as
1.1       misho       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: 
1.1.1.2   misho      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.
1.1       misho      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,
1.1.1.2   misho      70:     ip_t *ip_addr,
                     71:     struct mplslen *mpls)
1.1       misho      72: {
1.1.1.3 ! misho      73:     printf("h %d %s\n", host, strlongip(ctl->af, ip_addr));
1.1.1.2   misho      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: 
1.1       misho      81:     fflush(stdout);
                     82: }

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