summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-11-20 15:19:38 +1100
committerDamien Miller <djm@mindrot.org>2010-11-20 15:19:38 +1100
commit0dac6fb6b228a96f4ab3717e3d73871595a291a8 (patch)
tree7eae6f1e6a39fb7d608a05250f4749a77a914814 /misc.c
parent4499f4cc20eee7e0f67b35f5a5c6078bf07dcbc0 (diff)
- djm@cvs.openbsd.org 2010/11/13 23:27:51
[clientloop.c misc.c misc.h packet.c packet.h readconf.c readconf.h] [servconf.c servconf.h session.c ssh.c ssh_config.5 sshd_config.5] allow ssh and sshd to set arbitrary TOS/DSCP/QoS values instead of hardcoding lowdelay/throughput. bz#1733 patch from philipp AT redfish-solutions.com; ok markus@ deraadt@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index ff09becf9..b88f5aaa8 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.82 2010/09/24 13:33:00 matthew Exp $ */ 1/* $OpenBSD: misc.c,v 1.83 2010/11/13 23:27:50 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -38,6 +38,8 @@
38#include <unistd.h> 38#include <unistd.h>
39 39
40#include <netinet/in.h> 40#include <netinet/in.h>
41#include <netinet/in_systm.h>
42#include <netinet/ip.h>
41#include <netinet/tcp.h> 43#include <netinet/tcp.h>
42 44
43#include <errno.h> 45#include <errno.h>
@@ -913,6 +915,58 @@ bandwidth_limit(struct bwlimit *bw, size_t read_len)
913 bw->lamt = 0; 915 bw->lamt = 0;
914 gettimeofday(&bw->bwstart, NULL); 916 gettimeofday(&bw->bwstart, NULL);
915} 917}
918
919static const struct {
920 const char *name;
921 int value;
922} ipqos[] = {
923 { "af11", IPTOS_DSCP_AF11 },
924 { "af12", IPTOS_DSCP_AF12 },
925 { "af13", IPTOS_DSCP_AF13 },
926 { "af14", IPTOS_DSCP_AF21 },
927 { "af22", IPTOS_DSCP_AF22 },
928 { "af23", IPTOS_DSCP_AF23 },
929 { "af31", IPTOS_DSCP_AF31 },
930 { "af32", IPTOS_DSCP_AF32 },
931 { "af33", IPTOS_DSCP_AF33 },
932 { "af41", IPTOS_DSCP_AF41 },
933 { "af42", IPTOS_DSCP_AF42 },
934 { "af43", IPTOS_DSCP_AF43 },
935 { "cs0", IPTOS_DSCP_CS0 },
936 { "cs1", IPTOS_DSCP_CS1 },
937 { "cs2", IPTOS_DSCP_CS2 },
938 { "cs3", IPTOS_DSCP_CS3 },
939 { "cs4", IPTOS_DSCP_CS4 },
940 { "cs5", IPTOS_DSCP_CS5 },
941 { "cs6", IPTOS_DSCP_CS6 },
942 { "cs7", IPTOS_DSCP_CS7 },
943 { "ef", IPTOS_DSCP_EF },
944 { "lowdelay", IPTOS_LOWDELAY },
945 { "throughput", IPTOS_THROUGHPUT },
946 { "reliability", IPTOS_RELIABILITY },
947 { NULL, -1 }
948};
949
950int
951parse_ipqos(const char *cp)
952{
953 u_int i;
954 char *ep;
955 long val;
956
957 if (cp == NULL)
958 return -1;
959 for (i = 0; ipqos[i].name != NULL; i++) {
960 if (strcasecmp(cp, ipqos[i].name) == 0)
961 return ipqos[i].value;
962 }
963 /* Try parsing as an integer */
964 val = strtol(cp, &ep, 0);
965 if (*cp == '\0' || *ep != '\0' || val < 0 || val > 255)
966 return -1;
967 return val;
968}
969
916void 970void
917sock_set_v6only(int s) 971sock_set_v6only(int s)
918{ 972{