X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnat%2Fnat_stun.h;h=8d1c2720fe96e461ebef643e54bb860770ac83af;hb=f40acfa927bb605c81c99ed250277d51bf951e25;hp=4c6c178fba1d36fd57ce22c1ad79fbcda827961e;hpb=2105059516320800eaa8fff1196b58f29a50ba7c;p=oweals%2Fgnunet.git diff --git a/src/nat/nat_stun.h b/src/nat/nat_stun.h index 4c6c178fb..8d1c2720f 100644 --- a/src/nat/nat_stun.h +++ b/src/nat/nat_stun.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2009, 2015 GNUnet e.V. + Copyright (C) 2009, 2015, 2016 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -70,7 +70,7 @@ struct stun_addr * Port number. */ uint16_t port; - + /** * IPv4 address. Should this be "struct in_addr"? */ @@ -79,7 +79,7 @@ struct stun_addr /** - * STUN message classes + * STUN message classes */ enum StunClasses { INVALID_CLASS = 0, @@ -135,23 +135,24 @@ enum StunAttributes { * @param msg the received message * @return the converted StunClass */ -static int -decode_class(int msg) +static enum StunClasses +decode_class (int msg) { /* Sorry for the magic, but this maps the class according to rfc5245 */ - return ((msg & 0x0010) >> 4) | ((msg & 0x0100) >> 7); + return (enum StunClasses) ((msg & 0x0010) >> 4) | ((msg & 0x0100) >> 7); } + /** * Convert a message to a StunMethod * * @param msg the received message * @return the converted StunMethod */ -static int -decode_method(int msg) +static enum StunMethods +decode_method (int msg) { - return (msg & 0x000f) | ((msg & 0x00e0) >> 1) | ((msg & 0x3e00) >> 2); + return (enum StunMethods) (msg & 0x000f) | ((msg & 0x00e0) >> 1) | ((msg & 0x3e00) >> 2); } @@ -161,6 +162,7 @@ decode_method(int msg) * @param msg * @return string with the message class and method */ +GNUNET_UNUSED static const char * stun_msg2str (int msg) { @@ -172,30 +174,31 @@ stun_msg2str (int msg) { STUN_INDICATION, "Indication" }, { STUN_RESPONSE, "Response" }, { STUN_ERROR_RESPONSE, "Error Response" }, - { 0, NULL } + { INVALID_CLASS, NULL } }; static const struct { enum StunMethods value; const char *name; } methods[] = { { STUN_BINDING, "Binding" }, - { 0, NULL } + { INVALID_METHOD, NULL } }; static char result[64]; const char *msg_class = NULL; const char *method = NULL; - int value; + enum StunClasses cvalue; + enum StunMethods mvalue; - value = decode_class (msg); + cvalue = decode_class (msg); for (unsigned int i = 0; classes[i].name; i++) - if (classes[i].value == value) + if (classes[i].value == cvalue) { msg_class = classes[i].name; break; } - value = decode_method (msg); + mvalue = decode_method (msg); for (unsigned int i = 0; methods[i].name; i++) - if (methods[i].value == value) + if (methods[i].value == mvalue) { method = methods[i].name; break; @@ -215,6 +218,7 @@ stun_msg2str (int msg) * @param msg with a attribute type * @return string with the attribute name */ +GNUNET_UNUSED static const char * stun_attr2str (enum StunAttributes msg) {