/* $Header: nipchk.c,v 1.2 87/09/22 16:09:05 mar Exp $
 *
 * Network Information Protocol module of netconfig
 */

#include <stdio.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <sys/ioctl.h>
#include <net/nit.h>
#include <net/nip.h>
#include "netconfig.h"


#define mkina(w, x, y, z) ((long) ((w << 24) | (x << 16) | (y << 8) | z))

main(argc, argv)
int	argc;
char	**argv;
{
    struct nipreq nr;
    int s;

    if ((s = socket(AF_NIT, SOCK_RAW, 0)) < 0)
      perror("socket");
    if (ioctl(s, SIOCGNIP, &nr) < 0)
      perror("ioctl");

    printf("NIP server is\t%s.\n", nr.nip_state ? "ON" : "OFF");
    printf("Net Address\t%s\n", inet_ntoa(nr.nip_data.np_netaddress));
    printf("Mask\t\t%s\n", inet_ntoa(nr.nip_data.np_netmask));
    printf("Broadcast\t%s\n", inet_ntoa(nr.nip_data.np_broadcast));
    printf("Lowest\t\t%s\n", inet_ntoa(nr.nip_data.np_lowest));
    printf("Highest\t\t%s\n", inet_ntoa(nr.nip_data.np_highest));
    printf("Recommend\t%s\n", inet_ntoa(nr.nip_data.np_recommend));
    printf("Gateway\t\t%s\n", inet_ntoa(nr.nip_data.np_gateway));
}
