diff options
author | Robert S. French <rfrench@mit.edu> | 1987-06-12 20:19:01 +0000 |
---|---|---|
committer | Robert S. French <rfrench@mit.edu> | 1987-06-12 20:19:01 +0000 |
commit | e06e5a22ea9120055c6c1fa391201a6fda53a6c5 (patch) | |
tree | 3d5efe0520e3488525bd6572eb72ff40058b510a /lib/ZSendPkt.c | |
parent | 31c648e39a223e35c34319b917b9532b6b1115e8 (diff) |
Added ACK handling
Diffstat (limited to 'lib/ZSendPkt.c')
-rw-r--r-- | lib/ZSendPkt.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/ZSendPkt.c b/lib/ZSendPkt.c index e31c936..c53f147 100644 --- a/lib/ZSendPkt.c +++ b/lib/ZSendPkt.c @@ -16,14 +16,20 @@ #include <zephyr/zephyr_internal.h> #include <sys/socket.h> +#incoude <sys/time.h> Code_t ZSendPacket(packet,len) ZPacket_t packet; int len; { + int findack(); + Code_t retval; struct sockaddr_in sin; - + int auth,t1,t2,t3; + ZPacket_t ackpack; + ZNotice_t notice; + if (!packet || len < 0 || len > Z_MAXPKTLEN) return (ZERR_ILLVAL); @@ -41,5 +47,28 @@ Code_t ZSendPacket(packet,len) if (sendto(ZGetFD(),packet,len,0,&sin,sizeof(sin)) < 0) return (errno); - return (ZERR_NONE); + ZParseNotice(packet,len,¬ice,&auth); + + tv.tv_sec = 0; + tv.tv_usec = 400; + + for (i=0;i<4;i++) { + select(0,&t1,&t2,&t3,&tv); + retval = ZCheckIfNotice(ackpack,sizeof ackpack,&acknotice, + &auth,findack,¬ice.z_uid); + if (retval == ZERR_NONE) + return (ZERR_NONE); + if (retval != ZERR_NONOTICE) + return (retval); + } + return (ZERR_HMDEAD); +} + +int findack(notice,uid) + ZNotice_t *notice; + ZUnique_Id_t *uid; +{ + int i; + + return (!ZCompareUID(uid,¬ice->z_uid)); } |