X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcpacket.h;h=7d62a3b4210b754cada5dda1c3e50499ecad33ec;hb=cdedc07c65bab8467f6f5b1ef4b38982c2c77571;hp=3583e473927e5a952819b8422e0aa2ebad5bde23;hpb=2878ba34b8d864f89cfb785448e95cdd42297ee0;p=silc.git diff --git a/lib/silccore/silcpacket.h b/lib/silccore/silcpacket.h index 3583e473..7d62a3b4 100644 --- a/lib/silccore/silcpacket.h +++ b/lib/silccore/silcpacket.h @@ -370,14 +370,18 @@ do { \ * * DESCRIPTION * - * Returns the length of the padding in the packet. This is used + * Calculates the length of the padding in the packet. This is used * by various library routines to determine needed padding length. * * SOURCE */ -#define SILC_PACKET_PADLEN(__packetlen, __blocklen) \ - SILC_PACKET_DEFAULT_PADLEN - (__packetlen) % \ - ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN) +#define SILC_PACKET_PADLEN(__packetlen, __blocklen, __padlen) \ +do { \ + __padlen = (SILC_PACKET_DEFAULT_PADLEN - (__packetlen) % \ + ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN)); \ + if (__padlen < 8) \ + __padlen = ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN); \ +} while(0) /***/ /****d* silccore/SilcPacketAPI/SILC_PACKET_PADLEN_MAX @@ -389,13 +393,16 @@ do { \ * DESCRIPTION * * Returns the length of the padding up to the maximum length, which - * is 128 butes. This is used by various library routines to determine + * is 128 bytes. This is used by various library routines to determine * needed padding length. * * SOURCE */ -#define SILC_PACKET_PADLEN_MAX(__packetlen) \ - SILC_PACKET_MAX_PADLEN - (__packetlen) % SILC_PACKET_MAX_PADLEN +#define SILC_PACKET_PADLEN_MAX(__packetlen, __blocklen, __padlen) \ +do { \ + __padlen = (SILC_PACKET_MAX_PADLEN - (__packetlen) % \ + ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN)); \ +} while(0) /***/ /* Prototypes */