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
6 * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, see the file
15 #include <sys/socket.h>
18 static int wait_for_hmack(ZNotice_t
*notice
, void *uid
);
20 Code_t
ZSendPacket(packet
, len
, waitforack
)
26 struct sockaddr_in dest
;
27 ZNotice_t notice
, acknotice
;
29 if (!packet
|| len
< 0)
32 if (len
> Z_MAXPKTLEN
)
36 if ((retval
= ZOpenPort((unsigned short *)0)) != ZERR_NONE
)
39 dest
= ZGetDestAddr();
41 if (sendto(ZGetFD(), packet
, len
, 0, (struct sockaddr
*)&dest
,
48 if ((retval
= ZParseNotice(packet
, len
, ¬ice
)) != ZERR_NONE
)
51 retval
= Z_WaitForNotice (&acknotice
, wait_for_hmack
, ¬ice
.z_uid
,
53 if (retval
== ETIMEDOUT
)
55 if (retval
== ZERR_NONE
)
56 ZFreeNotice (&acknotice
);
60 static int wait_for_hmack(ZNotice_t
*notice
, void *uid
)
62 return (notice
->z_kind
== HMACK
&& ZCompareUID(¬ice
->z_uid
, (ZUnique_Id_t
*)uid
));