4.3bsd & XNS

Nathaniel Mishkin mishkin at apollo.COM
Mon Mar 13 23:44:00 AEST 1989


I'm running mt Xinu 4.3bsd on a VAXstation and I'm trying to get a simple
program that uses XNS (AF_NS) to work, and I can't.  I'd really appreciate
it if someone who's trod this path before can tell me what must be the
obvious thing I'm doing wrong.  Here's what I did:

I got "qe0" apparently configured right by doing:

    % ifconfig qe0 ns 0x29ce0.0x08002b02742e up
    ...
    % /etc/ifconfig qe0
    qe0: flags=43<UP,BROADCAST,RUNNING>
            inet 192.9.11.19 netmask ffffff00 broadcast 192.9.11.0
            ns 29CE0.8002B02742E 

I wrote a simple program to accept datagrams:

    #include <sys/time.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netns/ns.h>
    
    #define NULL 0l
    
    char buff[10 * 1024];
    
    main(argc, argv)
    char **argv;
    int argc;
    {
        int s;
        int cc, fromlen;
        struct sockaddr_ns name, xname, from;
        int len;
    
        if ((s = socket(AF_NS, SOCK_DGRAM, PF_UNSPEC)) < 0) {
            perror("Can't create socket");
            exit(1);
        }
    
        bzero(&name, sizeof name);
    
        if (bind(s, &name, sizeof name) < 0) {
            perror("Can't bind");
            exit(1);
        }
    
        len = sizeof xname;
        if (getsockname(s, &xname, &len) < 0) {
            perror("Can't get sock name");
            exit(1);
        }
    
        printf("local name = %s\n", ns_ntoa(xname.sns_addr));
    
        while (1) {
            fromlen = sizeof from;
    
            if ((cc = recvfrom(s, buff, sizeof buff, 0, &from, &fromlen)) < 0) {
                perror("Can't recv");
                exit(1);
            }
    
            printf("[%s] (%d)\n", ns_ntoa(from.sns_addr), cc);
        }
    }

and a simple program to send datagrams:

    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/socket.h>
    #include <netns/ns.h>
    #include <netdb.h>
    
    struct ns_addr ns_addr();
    char *ns_ntoa();
    
    char buff[1024];
    
    main(argc, argv)
    char **argv;
    int argc;
    {
        int s;
        int i;  
        struct sockaddr_ns name, xname;
        int cnt, len;
    
        if (argc < 4) {
            printf("usage: send <NS address> <# of msgs> <len of each msg>\n");
            exit(1);
        }
    
        if ((s = socket(AF_NS, SOCK_DGRAM, PF_UNSPEC)) < 0) {
            perror("Can't create socket");
            exit(1);
        }
    
        bzero(&name, sizeof name);
        name.sns_family = AF_NS;
    
        if (bind(s, &name, sizeof name) < 0) {
            perror("Can't bind socket");
            exit(1);
        }
    
        len = sizeof xname;
        if (getsockname(s, &xname, &len) < 0) {
            perror("Can't get sock name");
            exit(1);
        }
    
        printf("local name = %s\n", ns_ntoa(xname.sns_addr));
        bzero(&name, sizeof name);
    
        name.sns_family = AF_NS;
        name.sns_addr = ns_addr(argv[1]);
    
        printf("remote name = %s\n", ns_ntoa(name.sns_addr));
    
        cnt = atoi(argv[2]);
        len = atoi(argv[3]);
    
        for (i = 1; i <= cnt; i++)
            if (sendto(s, buff, len, 0, &name, sizeof name) < 0) {
                perror("Can't send");
                exit(1);
            }
    }

When I start the receiver I get:

    % rcv
    local name = 0.0.BC3

which looks OK.  I run the sender and get:

    % send 0x29ce0.0x8002b02742e.0xbc3 10 10
    local name = 0.0.BC4
    remote name = 29CE0.8002B02742E.BC3

but the receiver never sees any of the datagrams sent by the sender.

Are there any programs that use XNS datagrams (SOCK_DGRAM) that are part
of standard 4.3bsd?

                    -- Nat Mishkin
                       Apollo Computer Inc., Chelmsford, MA
                       mishkin at apollo.com

-- 
                    -- Nat Mishkin
                       Apollo Computer Inc., Chelmsford, MA
                       mishkin at apollo.com



More information about the Comp.unix.wizards mailing list