View | Details | Raw Unified | Return to bug 48361
Collapse All | Expand All

(-)server/listen.c (+52 lines)
Lines 36-41 Link Here
36
static int ap_listenbacklog;
36
static int ap_listenbacklog;
37
static int send_buffer_size;
37
static int send_buffer_size;
38
static int receive_buffer_size;
38
static int receive_buffer_size;
39
static int qos_marking = 0;
39
40
40
/* TODO: make_sock is just begging and screaming for APR abstraction */
41
/* TODO: make_sock is just begging and screaming for APR abstraction */
41
static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
42
static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server)
Lines 124-129 Link Here
124
            /* not a fatal error */
125
            /* not a fatal error */
125
        }
126
        }
126
    }
127
    }
128
#ifdef APR_SO_IPTOS
129
    if (qos_marking) {
130
        stat = apr_socket_opt_set(s, APR_SO_IPTOS, qos_marking);
131
        if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
132
            ap_log_perror(APLOG_MARK, APLOG_WARNING, stat, p,
133
                          "make_sock: failed to set IP ToS for "
134
                          "address %pI, using default",
135
                          server->bind_addr);
136
            /* not a fatal error */
137
        }
138
    }
139
#endif
127
140
128
#if APR_TCP_NODELAY_INHERITED
141
#if APR_TCP_NODELAY_INHERITED
129
    ap_sock_disable_nagle(s);
142
    ap_sock_disable_nagle(s);
Lines 721-723 Link Here
721
    receive_buffer_size = s;
734
    receive_buffer_size = s;
722
    return NULL;
735
    return NULL;
723
}
736
}
737
738
AP_DECLARE_NONSTD(const char *) ap_set_qos_marking(cmd_parms *cmd,
739
                                                   void *dummy,
740
                                                   const char *arg)
741
{
742
    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
743
    /* might be more legible to use netinet/ip.h constants here, but that
744
     * would be less portable for a long time to come.
745
     */
746
    static const char cs[8] = {0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0};
747
    static const char af[12] = {0x28, 0x30, 0x38,
748
                                0x48, 0x50, 0x58,
749
                                0x68, 0x70, 0x78,
750
                                0x88, 0x90, 0x98};
751
    static const char ef = 0xb8;
752
753
    if (err != NULL) {
754
        return err;
755
    }
756
757
#define __in_range(c,s,e) ((s) <= (c) && (c) <= (e))
758
759
    if (arg[0] == 'c' && arg[1] == 's' && __in_range(arg[2], '0', '7') &&
760
        arg[3] == '\0') {
761
	qos_marking = cs[arg[2] - '0'];
762
    } else if (arg[0] == 'a' && arg[1] == 'f' &&
763
               __in_range(arg[2], '1', '4') && __in_range(arg[3], '1', '3') &&
764
               arg[4] == '\0') {
765
	qos_marking = af[(3 * (arg[2] - '1')) + (arg[3] - '1')];
766
    } else if (arg[0] == 'e' && arg[1] == 'f' && arg[2] == '\0') {
767
	qos_marking = ef;
768
    } else {
769
        return "QoSMarking must be cs0..cs7, af11..af43, or ef";
770
    }
771
772
#undef __in_range
773
774
    return NULL;
775
}
(-)include/ap_listen.h (-1 / +5 lines)
Lines 116-121 Link Here
116
AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
116
AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
117
                                                           void *dummy,
117
                                                           void *dummy,
118
                                                           const char *arg);
118
                                                           const char *arg);
119
AP_DECLARE_NONSTD(const char *) ap_set_qos_marking(cmd_parms *cmd, void *dummy,
120
				    const char *arg);
119
121
120
#define LISTEN_COMMANDS	\
122
#define LISTEN_COMMANDS	\
121
AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
123
AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
Lines 125-131 Link Here
125
AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
127
AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
126
  "Send buffer size in bytes"), \
128
  "Send buffer size in bytes"), \
127
AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
129
AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
128
              RSRC_CONF, "Receive buffer size in bytes")
130
              RSRC_CONF, "Receive buffer size in bytes"), \
131
AP_INIT_TAKE1("QoSMarking", ap_set_qos_marking, NULL, RSRC_CONF, \
132
  "IP QoS marking as a DiffServ/DSCP code-point name")
129
133
130
#ifdef __cplusplus
134
#ifdef __cplusplus
131
}
135
}

Return to bug 48361