1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZSendPacket function.
4 * Created by: Robert French
8 * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
14 static const char rcsid_ZSendPacket_c[] =
15 "$Zephyr: /mit/zephyr/src/lib/RCS/ZSendPacket.c,v 1.29 91/03/21 11:57:08 raeburn Exp $";
19 #include <sys/socket.h>
21 static int wait_for_hmack(ZNotice_t *, void *);
24 ZSendPacket(char *packet,
29 struct sockaddr_in dest;
30 ZNotice_t notice, acknotice;
32 if (!packet || len < 0)
35 if (len > Z_MAXPKTLEN)
39 if ((retval = ZOpenPort((u_short *)0)) != ZERR_NONE)
42 dest = ZGetDestAddr();
44 if (sendto(ZGetFD(), packet, len, 0, (struct sockaddr *)&dest,
51 if ((retval = ZParseNotice(packet, len, ¬ice)) != ZERR_NONE)
54 retval = Z_WaitForNotice(&acknotice, wait_for_hmack, ¬ice.z_uid,
56 if (retval == ETIMEDOUT)
58 if (retval == ZERR_NONE)
59 ZFreeNotice (&acknotice);
64 wait_for_hmack(ZNotice_t *notice,
67 return (notice->z_kind == HMACK && ZCompareUID(¬ice->z_uid, (ZUnique_Id_t *)uid));