eliminate KX short cut
[oweals/gnunet.git] / src / nat / nat_stun.h
index 4c6c178fba1d36fd57ce22c1ad79fbcda827961e..8d1c2720fe96e461ebef643e54bb860770ac83af 100644 (file)
@@ -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)
 {