/*
 * Copyright (c) 2007, OpenFWTK Development Group
 * All rights reserved. See LICENSE.
 */


/*
 *      Test assumptions made by peername() function
 */

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>

int
main()
{
    struct sockaddr_un     sua;
    struct sockaddr_in     *sia = (struct sockaddr_in *)&sua;

    printf("Checking if sockaddr_structures are valid..");
    if ((sizeof(struct sockaddr_un) >= sizeof(struct sockaddr_in)) &&
	(sizeof(struct sockaddr_un) >= sizeof(struct sockaddr)) &&
	(&(sia->sin_family) == &(sua.sun_family))) {
		printf("fine.\n");
		exit(0);
    } else {
		printf("fatal: socket structures are not sane!\n");
		exit(1);
    }
}
