/*
 * author: Darren Bounds <dbounds@intrusense.com>
 * copyright: Copyright (C) 2002 by Darren Bounds
 * license: This software is under GPL version 2 of license
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * packit official page at http://packit.sourceforge.net
 */

#include "../include/packit.h"
#include "../include/capture.h"
#include "../include/error.h"

void
print_ipv4_hdr(struct libnet_ipv4_hdr *iphdr)
{
    unsigned char *s_addr, *d_addr;

    struct in_addr ip_src, ip_dst;

#ifdef __DEBUG
    fprintf(stderr, "DEBUG: print_ipv4_hdr()\n");
#endif

    bzero(&ip_src, sizeof(ip_src));
    bzero(&ip_dst, sizeof(ip_dst));

    s_addr = libnet_addr2name4(iphdr->ip_src.s_addr, ((resolve == 1 || resolve == 3) ? 1 : 0));
    d_addr = libnet_addr2name4(iphdr->ip_dst.s_addr, ((resolve == 1 || resolve == 3) ? 1 : 0));

    fprintf(stdout, "IP header:   Src Address: %s  Dst Address: %s\n", 
        s_addr, 
        d_addr);

    fprintf(stdout, "\t     TTL: %d  ID: %d  TOS: 0x%X  Len: %d  ", 
        iphdr->ip_ttl, 
	ntohs(iphdr->ip_id), 
	iphdr->ip_tos, 
	ntohs(iphdr->ip_len));

    if(ntohs(iphdr->ip_off) & IP_DF)
        fprintf(stdout, "(DF)");

    fprintf(stdout, "\n");
}
