diff --git a/mud.c b/mud.c index b38f144..d4e22c0 100644 --- a/mud.c +++ b/mud.c @@ -94,8 +94,8 @@ struct mud_path { uint64_t send_time; int remote; struct { - int remote; - int local; + size_t remote; + size_t local; } mtu; unsigned char kiss[MUD_SID_SIZE]; } conf; @@ -179,7 +179,7 @@ struct mud { int use_next; int aes; } crypto; - int mtu; + size_t mtu; int tc; struct { int set; @@ -646,11 +646,10 @@ mud_set_time_tolerance(struct mud *mud, unsigned long msec) return 0; } -int +size_t mud_get_mtu(struct mud *mud) { - int mtu = mud->mtu; - + size_t mtu = mud->mtu; struct mud_path *path; for (path = mud->path; path; path = path->next) { @@ -663,10 +662,10 @@ mud_get_mtu(struct mud *mud) return mtu; } -int -mud_set_mtu(struct mud *mud, int mtu) +size_t +mud_set_mtu(struct mud *mud, size_t mtu) { - if (mtu <= 0 || mtu > MUD_PACKET_MAX_SIZE) + if (mtu > MUD_PACKET_MAX_SIZE) mtu = MUD_PACKET_MAX_SIZE; if (mtu < sizeof(struct mud_packet)) @@ -686,7 +685,7 @@ mud_set_mtu(struct mud *mud, int mtu) if (!mud->mtu) mud->mtu = mtu; - return 0; + return mtu; } static int @@ -1243,7 +1242,7 @@ mud_send(struct mud *mud, const void *data, size_t size, int tc) if (!size) return 0; - if (size > (size_t)mud_get_mtu(mud)) { + if (size > mud_get_mtu(mud)) { errno = EMSGSIZE; return -1; } diff --git a/mud.h b/mud.h index bdb9d2f..9641cf2 100644 --- a/mud.h +++ b/mud.h @@ -13,8 +13,8 @@ int mud_get_fd (struct mud *); int mud_set_key (struct mud *, unsigned char *, size_t); int mud_get_key (struct mud *, unsigned char *, size_t *); -int mud_set_mtu (struct mud *, int mtu); -int mud_get_mtu (struct mud *); +size_t mud_set_mtu (struct mud *, size_t); +size_t mud_get_mtu (struct mud *); int mud_set_send_timeout (struct mud *, unsigned long); int mud_set_time_tolerance (struct mud *, unsigned long);