2 * $Id: atp_open.c,v 1.4 2001-06-29 14:14:46 rufustfirefly Exp $
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appears in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation, and that the name of The University
12 * of Michigan not be used in advertising or publicity pertaining to
13 * distribution of the software without specific, written prior
14 * permission. This software is supplied as is without expressed or
15 * implied warranties of any kind.
17 * Research Systems Unix Group
18 * The University of Michigan
20 * 535 W. William Street
23 * netatalk@itd.umich.edu
28 #endif /* HAVE_CONFIG_H */
32 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/socket.h>
37 #include <netatalk/at.h>
38 #include <netatalk/endian.h>
40 #include <atalk/netddp.h>
41 #include <atalk/ddp.h>
42 #include <atalk/atp.h>
44 #include "atp_internals.h"
46 ATP atp_open(port, saddr)
48 const struct at_addr *saddr;
50 struct sockaddr_at addr;
57 printf( "<%d> atp_open\n", getpid());
60 memset(&addr, 0, sizeof(addr));
63 memcpy(&addr.sat_addr, saddr, sizeof(struct at_addr));
64 if ((s = netddp_open(&addr, NULL)) < 0)
67 if (( atp = (ATP) atp_alloc_buf()) == NULL ) {
72 /* initialize the atp handle */
73 memset(atp, 0, sizeof( struct atp_handle ));
74 memcpy(&atp->atph_saddr, &addr, sizeof(addr));
78 gettimeofday( &tv, (struct timezone *) 0 );
80 atp->atph_tid = tv.tv_sec ^ ((( pid << 8 ) & 0xff00 ) | ( pid >> 8 ));