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
7 * $Author: warmenhoven $
9 * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
16 static char rcsid_ZSendPacket_c
[] =
17 "$Zephyr: /mit/zephyr/src/lib/RCS/ZSendPacket.c,v 1.29 91/03/21 11:57:08 raeburn Exp $";
21 #include <sys/socket.h>
23 static int wait_for_hmack();
25 Code_t
ZSendPacket(packet
, len
, waitforack
)
31 struct sockaddr_in dest
;
32 ZNotice_t notice
, acknotice
;
34 if (!packet
|| len
< 0)
37 if (len
> Z_MAXPKTLEN
)
41 if ((retval
= ZOpenPort((u_short
*)0)) != ZERR_NONE
)
44 dest
= ZGetDestAddr();
46 if (sendto(ZGetFD(), packet
, len
, 0, (struct sockaddr
*)&dest
,
53 if ((retval
= ZParseNotice(packet
, len
, ¬ice
)) != ZERR_NONE
)
56 retval
= Z_WaitForNotice (&acknotice
, wait_for_hmack
, ¬ice
.z_uid
,
58 if (retval
== ETIMEDOUT
)
60 if (retval
== ZERR_NONE
)
61 ZFreeNotice (&acknotice
);
65 static int wait_for_hmack(notice
, uid
)
69 return (notice
->z_kind
== HMACK
&& ZCompareUID(¬ice
->z_uid
, uid
));