ftp.nice.ch/pub/next/developer/resources/libraries/eni.a.tar.gz#/examples/msend.c

This is msend.c in view mode; [Download] [Up]

#include <stdio.h>
#include <stdlib.h>
#include <mach.h>
#include <servers/netname.h>
#include <sys/message.h>
#include <net/etherdefs.h>
#include <sys/errno.h>
#include <string.h>
#include "eniutils.h"
#include "libeni.h"


extern int gethostname(char *name, int namelen) ;
	       

unsigned char edst[6] ;
unsigned char pack[ENI_PACKET_SIZE] ;

unsigned char data[] = "This is a test ethernet packet.  Wheeee!!!" ;

char *prog ;
char our_name[128] ;


#define ETHER_FILE "etherfile"


int main(int ac, char *av[])
{
    int rv ;


    prog = av[0] ;
    gethostname(our_name, sizeof our_name) ;
    if(ac != 2)
    {
	fprintf(stderr, "Usage: %s <dest-host>\n", prog) ;
	exit(1) ;
    }

    if( ! get_ether_addr(av[1], edst, ETHER_FILE))
    {
	fprintf(stderr, "%s: can't find address for %s.\n", av[0],
		 av[1]) ;
	exit(1) ;
    }

    if(eni_init() == -1)
    {
	fprintf(stderr, "%s: eni_init() failed.\n", prog) ;
	exit(1) ;
    } ;

    rv = eni_send_packet(edst, (u_short)77, (void *)data, sizeof data) ;
    printf("%s: eni_send_packet() returns %d.\n", prog, rv) ;

    exit(0) ;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.