If "PriorityInheritance = yes" is specified in tinc.conf, the value of the
[tinc] / src / net_packet.c
index 725789d..81d759a 100644 (file)
@@ -17,7 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id: net_packet.c,v 1.1.2.5 2002/02/26 23:26:41 guus Exp $
+    $Id: net_packet.c,v 1.1.2.6 2002/03/01 12:26:56 guus Exp $
 */
 
 #include "config.h"
@@ -190,6 +190,8 @@ void send_udppacket(node_t *n, vpn_packet_t *inpkt)
   long int complen = MTU + 12;
   EVP_CIPHER_CTX ctx;
   vpn_packet_t *copy;
+  static int priority = 0;
+  int origpriority;
 cp
   if(!n->status.validkey)
     {
@@ -212,6 +214,7 @@ cp
     }
 
   origlen = inpkt->len;
+  origpriority = inpkt->priority;
 
   /* Compress the packet */
 
@@ -258,6 +261,15 @@ cp
 
   /* Send the packet */
 
+  if(priorityinheritance && origpriority != priority)
+    {
+      priority = origpriority;
+      if(debug_lvl >= DEBUG_TRAFFIC)
+        syslog(LOG_DEBUG, _("Setting outgoing packet priority to %d"), priority);
+      if(setsockopt(udp_socket[0], SOL_IP, IP_TOS, &priority, sizeof(priority))) /* SO_PRIORITY doesn't seem to work */
+       syslog(LOG_ERR, _("System call `%s' failed: %s"), "setsockopt", strerror(errno));
+    }
+
   if((sendto(udp_socket[0], (char *)&inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa))) < 0)
     {
       syslog(LOG_ERR, _("Error sending packet to %s (%s): %s"),
@@ -362,7 +374,8 @@ cp
     {
       syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%s"),
              __FILE__, __LINE__, sock, strerror(errno));
-      return;
+      cp_trace();
+      exit(1);
     }
   if(x)
     {