extern "C" {
#endif
-/**
- * Size of the ASCII representation of an EUI-64.
- */
+ /**
+ * Size of the ASCII representation of an EUI-64.
+ */
#define EUI64_SIZ 24
-/**
- * The number of bytes in an EUI-64.
- */
+ /**
+ * The number of bytes in an EUI-64.
+ */
#define EUI64_LEN 8
-/**
- * Structure of an IEEE EUI-64.
- */
-struct eui64 {
- u_char octet[EUI64_LEN];
-};
+ /**
+ * Structure of an IEEE EUI-64.
+ */
+ struct eui64 {
+ u_char octet[EUI64_LEN];
+ };
-int eui64_aton(const char *a, struct eui64 *e);
+ int eui64_aton(const char *a, struct eui64 *e);
#ifdef __cplusplus
}
#endif
if ((msg == NULL) || (strlen(prog) > 256)) {
/* FAIL */
-/*
- snprintf(dbuf, sizeof(dbuf), "%s: local_printfx() EPIC FAILURE.\n", prog);
- fputs(dbuf, stderr);
-*/
+ /*
+ snprintf(dbuf, sizeof(dbuf), "%s: local_printfx() EPIC FAILURE.\n", prog);
+ fputs(dbuf, stderr);
+ */
debug("local_printfx() EPIC FAIL.\n");
return;
}
memset(dbuf, '\0', strlen(dbuf));
} else {
/* FAIL */
-/*
- snprintf(bbuf, sz, "%s: local_printfx(%s) FAILURE: %zd\n", prog, dbuf, x);
- fputs(bbuf, stderr);
-*/
+ /*
+ snprintf(bbuf, sz, "%s: local_printfx(%s) FAILURE: %zd\n", prog, dbuf, x);
+ fputs(bbuf, stderr);
+ */
debug("local_printfx() FAILURE: %zd\n", x);
}
case 'u':
i++; /* Set Search Attribute */
if (argv[i] != NULL) {
- xstrncpy(edui_conf.attrib, argv[i], sizeof(edui_conf.attrib));
+ xstrncpy(edui_conf.attrib, argv[i], sizeof(edui_conf.attrib));
} else {
local_printfx("No parameters given for 'u'.\n");
DisplayUsage();
if (x != LDAP_ERR_SUCCESS) {
/* Unable to bind */
debug("BindLDAP() -> %s (LDAP: %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- continue;
+ local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
+ continue;
} else
debug("BindLDAP(-, %s, %s, (LDAP_AUTH_TLS)) -> %s\n", edui_conf.dn, edui_conf.passwd, ErrLDAP(x));
} else if (!(edui_ldap.status & LDAP_BIND_S)) {
if (x != LDAP_ERR_SUCCESS) {
/* Unable to bind */
debug("BindLDAP() -> %s (LDAP: %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- continue;
+ local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
+ continue;
} else
debug("BindLDAP(-, %s, %s, (LDAP_AUTH_SIMPLE)) -> %s\n", edui_conf.dn, edui_conf.passwd, ErrLDAP(x));
} else {
if (x != LDAP_ERR_SUCCESS) {
/* Unable to bind */
debug("BindLDAP() -> %s (LDAP: %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
- continue;
+ local_printfx("ERR (BindLDAP: %s - %s)\n", ErrLDAP(x), ldap_err2string(edui_ldap.err));
+ continue;
} else
debug("BindLDAP(-, -, -, (LDAP_AUTH_NONE)) -> %s\n", ErrLDAP(x));
}
#include "config.h"
#include "xstrto.h"
-/*
- * (C) 2000-2006 by the netfilter coreteam <coreteam@netfilter.org>:
+/*
+ * (C) 2000-2006 by the netfilter coreteam <coreteam@netfilter.org>:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if HAVE_ERRNO_H
unsigned long min, unsigned long max)
{
unsigned long v;
- char *my_end;
+ char *my_end;
errno = 0;
v = strtoul(s, &my_end, 0);
if (errno != ERANGE && min <= v && (max == 0 || v <= max)) {
if (value != NULL)
*value = v;
- if (end == NULL)
+ if (end == NULL)
return *my_end == '\0';
return true;
}
if (h->getByName("Opt-body-type").size()) {
// TODO: add a class to rate-limit such warnings using FadingCounter
debugs(93,DBG_IMPORTANT, "WARNING: Ignoring unsupported ICAP " <<
- "OPTIONS body; type: " << h->getByName("Opt-body-type"));
+ "OPTIONS body; type: " << h->getByName("Opt-body-type"));
// Do not set error, assuming the response headers are valid.
}
/// print the id
template <class Class>
inline
-std::ostream &operator <<(std::ostream &os, const InstanceId<Class> &id) {
+std::ostream &operator <<(std::ostream &os, const InstanceId<Class> &id)
+{
return id.print(os);
}
#if SO_MARK
nfmark_t mark = GetNfmarkToServer(request);
debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << int(tos)
- << ", netfilter mark " << mark);
+ << ", netfilter mark " << mark);
#else
nfmark_t mark = 0;
debugs(17, 3, "fwdConnectStart: got outgoing addr " << outgoing << ", tos " << int(tos));
// RFC 2616: do not cache replies to responses with no-store CC directive
if (request && request->cache_control &&
- EBIT_TEST(request->cache_control->mask, CC_NO_STORE) &&
- !REFRESH_OVERRIDE(ignore_no_store))
+ EBIT_TEST(request->cache_control->mask, CC_NO_STORE) &&
+ !REFRESH_OVERRIDE(ignore_no_store))
return 0;
if (!ignoreCacheControl) {
Ip::Qos::Config::isAclNfmarkActive() const
{
acl_nfmark * nfmarkAcls [] = { nfmarkToServer, nfmarkToClient };
-
+
for (int i=0; i<2; i++) {
while (nfmarkAcls[i]) {
acl_nfmark *l = nfmarkAcls[i];
if (l->nfmark > 0)
- return true;
+ return true;
nfmarkAcls[i] = l->next;
}
}
#if USE_QOS_TOS && _SQUID_LINUX_
/* Bug 2537: This part of ZPH only applies to patched Linux kernels. */
tos_t tos = 1;
- int tos_len = sizeof(tos);
+ int tos_len = sizeof(tos);
clientFde->tosFromServer = 0;
if (setsockopt(server_fd,SOL_IP,IP_RECVTOS,&tos,tos_len)==0) {
unsigned char buf[512];
struct in6_addr serv_fde_remote_ip6;
inet_pton(AF_INET6,servFde->ipaddr,(struct in6_addr*)&serv_fde_remote_ip6);
nfct_set_attr(ct, ATTR_IPV6_DST, serv_fde_remote_ip6.s6_addr);
- nfct_set_attr(ct, ATTR_IPV6_SRC, serv_fde_local_ip6.s6_addr);
+ nfct_set_attr(ct, ATTR_IPV6_SRC, serv_fde_local_ip6.s6_addr);
} else {
serv_fde_local_ip = ((struct sockaddr_in*)addr->ai_addr)->sin_addr;
nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
nfct_set_attr_u32(ct, ATTR_IPV4_DST, inet_addr(servFde->ipaddr));
- nfct_set_attr_u32(ct, ATTR_IPV4_SRC, serv_fde_local_ip.s_addr);
+ nfct_set_attr_u32(ct, ATTR_IPV4_SRC, serv_fde_local_ip.s_addr);
}
nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_TCP);
/* Open a handle to the conntrack */
if (struct nfct_handle *h = nfct_open(CONNTRACK, 0)) {
/* Register the callback. The callback function will record the mark value. */
- nfct_callback_register(h, NFCT_T_ALL, getNfMarkCallback, (void *)clientFde);
+ nfct_callback_register(h, NFCT_T_ALL, getNfMarkCallback, (void *)clientFde);
/* Query the conntrack table using the data previously set */
int x = nfct_query(h, NFCT_Q_GET, ct);
if (x == -1) {
debugs(17, 2, "QOS: Failed to retrieve connection mark: (" << x << ") " << strerror(errno)
- << " (Destination " << servFde->ipaddr << ":" << servFde->remote_port
- << ", source " << serv_fde_local_conn << ")" );
+ << " (Destination " << servFde->ipaddr << ":" << servFde->remote_port
+ << ", source " << serv_fde_local_conn << ")" );
}
-
+
nfct_close(h);
} else {
debugs(17, 2, "QOS: Failed to open conntrack handle for upstream netfilter mark retrieval.");
#if USE_LIBNETFILTERCONNTRACK
int
Ip::Qos::getNfMarkCallback(enum nf_conntrack_msg_type type,
- struct nf_conntrack *ct,
- void *data)
+ struct nf_conntrack *ct,
+ void *data)
{
- fde *clientFde = (fde *)data;
- clientFde->nfmarkFromServer = nfct_get_attr_u32(ct, ATTR_MARK);
- debugs(17, 3, "QOS: Retrieved connection mark value: " << clientFde->nfmarkFromServer);
+ fde *clientFde = (fde *)data;
+ clientFde->nfmarkFromServer = nfct_get_attr_u32(ct, ATTR_MARK);
+ debugs(17, 3, "QOS: Retrieved connection mark value: " << clientFde->nfmarkFromServer);
- return NFCT_CB_CONTINUE;
+ return NFCT_CB_CONTINUE;
}
#endif
# else // USE_LIBNETFILTERCONNTRACK
preserveMissMark = false;
debugs(3, DBG_IMPORTANT, "WARNING: Squid not compiled with Netfilter conntrack library. "
- << "Netfilter mark preservation not available.");
+ << "Netfilter mark preservation not available.");
#endif // USE_LIBNETFILTERCONNTRACK
#else // SO_MARK
debugs(3, DBG_CRITICAL, "ERROR: Invalid parameter 'mark' in qos_flows option. "
- << "Linux Netfilter marking not available.");
+ << "Linux Netfilter marking not available.");
self_destruct();
#endif // SO_MARK
} else if (strncmp(token, "tos",3) == 0) {
if (mark) {
if (!xstrtoui(&token[10], NULL, &markLocalHit, 0, std::numeric_limits<nfmark_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad mark local-hit value " << &token[10]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark local-hit value " << &token[10]);
+ self_destruct();
}
} else {
unsigned int v = 0;
if (!xstrtoui(&token[10], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad TOS local-hit value " << &token[10]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS local-hit value " << &token[10]);
+ self_destruct();
}
tosLocalHit = (tos_t)v;
}
if (mark) {
if (!xstrtoui(&token[12], NULL, &markSiblingHit, 0, std::numeric_limits<nfmark_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad mark sibling-hit value " << &token[12]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark sibling-hit value " << &token[12]);
+ self_destruct();
}
} else {
unsigned int v = 0;
if (!xstrtoui(&token[12], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad TOS sibling-hit value " << &token[12]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS sibling-hit value " << &token[12]);
+ self_destruct();
}
tosSiblingHit = (tos_t)v;
}
if (mark) {
if (!xstrtoui(&token[11], NULL, &markParentHit, 0, std::numeric_limits<nfmark_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad mark parent-hit value " << &token[11]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark parent-hit value " << &token[11]);
+ self_destruct();
}
} else {
unsigned int v = 0;
if (!xstrtoui(&token[11], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad TOS parent-hit value " << &token[11]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS parent-hit value " << &token[11]);
+ self_destruct();
}
tosParentHit = (tos_t)v;
}
if (mark) {
if (!xstrtoui(&token[5], NULL, &markMiss, 0, std::numeric_limits<nfmark_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss value " << &token[5]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss value " << &token[5]);
+ self_destruct();
}
} else {
unsigned int v = 0;
if (!xstrtoui(&token[5], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss value " << &token[5]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss value " << &token[5]);
+ self_destruct();
}
tosMiss = (tos_t)v;
}
if (mark && preserveMissMark) {
if (!xstrtoui(&token[10], NULL, &preserveMissMarkMask, 0, std::numeric_limits<nfmark_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss-mark value " << &token[10]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss-mark value " << &token[10]);
+ self_destruct();
}
} else if (preserveMissTos) {
unsigned int v = 0;
if (!xstrtoui(&token[10], NULL, &v, 0, std::numeric_limits<tos_t>::max())) {
- debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss-mark value " << &token[10]);
- self_destruct();
+ debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss-mark value " << &token[10]);
+ self_destruct();
}
preserveMissTosMask = (tos_t)v;
} else {
}
p += snprintf(p, 2, "\n");
}
-
+
if (isHitNfmarkActive()) {
p += snprintf(p, 11, "%s", name); // strlen("qos_flows ");
p += snprintf(p, 5, "%s", "mark");
namespace Qos
{
- /**
- * Function to retrieve the TOS value of the inbound packet.
- * Called by FwdState::dispatch if QOS options are enabled.
- * Bug 2537: This part of ZPH only applies to patched Linux kernels
- * @param server_fd Server side descriptor of connection to get TOS for
- * @param clientFde Pointer to client side fde instance to set tosFromServer in
- */
- void getTosFromServer(const int server_fd, fde *clientFde);
-
- /**
- * Function to retrieve the netfilter mark value of the connection
- * to the upstream server. Called by FwdState::dispatch if QOS
- * options are enabled.
- * @param server_fd Server side descriptor of connection to get mark for
- * @param servFde Pointer to server side fde instance to get mark for
- * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
- */
- void getNfmarkFromServer(const int server_fd, const fde *servFde, const fde *clientFde);
+/**
+* Function to retrieve the TOS value of the inbound packet.
+* Called by FwdState::dispatch if QOS options are enabled.
+* Bug 2537: This part of ZPH only applies to patched Linux kernels
+* @param server_fd Server side descriptor of connection to get TOS for
+* @param clientFde Pointer to client side fde instance to set tosFromServer in
+*/
+void getTosFromServer(const int server_fd, fde *clientFde);
+
+/**
+* Function to retrieve the netfilter mark value of the connection
+* to the upstream server. Called by FwdState::dispatch if QOS
+* options are enabled.
+* @param server_fd Server side descriptor of connection to get mark for
+* @param servFde Pointer to server side fde instance to get mark for
+* @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
+*/
+void getNfmarkFromServer(const int server_fd, const fde *servFde, const fde *clientFde);
#if USE_LIBNETFILTERCONNTRACK
- /**
- * Callback function to mark connection once it's been found.
- * This function is called by the libnetfilter_conntrack
- * libraries, during nfct_query in Ip::Qos::getNfmarkFromServer.
- * nfct_callback_register is used to register this function.
- * @param nf_conntrack_msg_type Type of conntrack message
- * @param nf_conntrack Pointer to the conntrack structure
- * @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
- */
- int getNfMarkCallback(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *clientFde);
+/**
+* Callback function to mark connection once it's been found.
+* This function is called by the libnetfilter_conntrack
+* libraries, during nfct_query in Ip::Qos::getNfmarkFromServer.
+* nfct_callback_register is used to register this function.
+* @param nf_conntrack_msg_type Type of conntrack message
+* @param nf_conntrack Pointer to the conntrack structure
+* @param clientFde Pointer to client side fde instance to set nfmarkFromServer in
+*/
+int getNfMarkCallback(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *clientFde);
#endif
- /**
- * Function to work out and then apply to the socket the appropriate
- * TOS value to set on packets when items have not been retrieved from
- * local cache. Called by clientReplyContext::sendMoreData if QOS is
- * enabled for TOS.
- * @param fd Descriptor of socket to set the TOS for
- * @param hierCode Hier code of request
- */
- int doTosLocalMiss(const int fd, const hier_code hierCode);
-
- /**
- * Function to work out and then apply to the socket the appropriate
- * netfilter mark value to set on packets when items have not been
- * retrieved from local cache. Called by clientReplyContext::sendMoreData
- * if QOS is enabled for TOS.
- * @param fd Descriptor of socket to set the mark for
- * @param hierCode Hier code of request
- */
- int doNfmarkLocalMiss(const int fd, const hier_code hierCode);
-
- /**
- * Function to work out and then apply to the socket the appropriate
- * TOS value to set on packets when items *have* been retrieved from
- * local cache. Called by clientReplyContext::doGetMoreData if QOS is
- * enabled for TOS.
- * @param fd Descriptor of socket to set the TOS for
- */
- int doTosLocalHit(const int fd);
-
- /**
- * Function to work out and then apply to the socket the appropriate
- * netfilter mark value to set on packets when items *have* been
- * retrieved from local cache. Called by clientReplyContext::doGetMoreData
- * if QOS is enabled for TOS.
- * @param fd Descriptor of socket to set the mark for
- */
- int doNfmarkLocalHit(const int fd);
-
- /**
- * Function to set the TOS value of packets. Sets the value on the socket
- * which then gets copied to the packets.
- * @param fd Descriptor of socket to set the TOS for
- */
- _SQUID_INLINE_ int setSockTos(int fd, tos_t tos);
-
- /**
- * Function to set the netfilter mark value of packets. Sets the value on the
- * socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
- * @param fd Descriptor of socket to set the mark for
- */
- _SQUID_INLINE_ int setSockNfmark(int fd, nfmark_t mark);
+/**
+* Function to work out and then apply to the socket the appropriate
+* TOS value to set on packets when items have not been retrieved from
+* local cache. Called by clientReplyContext::sendMoreData if QOS is
+* enabled for TOS.
+* @param fd Descriptor of socket to set the TOS for
+* @param hierCode Hier code of request
+*/
+int doTosLocalMiss(const int fd, const hier_code hierCode);
+
+/**
+* Function to work out and then apply to the socket the appropriate
+* netfilter mark value to set on packets when items have not been
+* retrieved from local cache. Called by clientReplyContext::sendMoreData
+* if QOS is enabled for TOS.
+* @param fd Descriptor of socket to set the mark for
+* @param hierCode Hier code of request
+*/
+int doNfmarkLocalMiss(const int fd, const hier_code hierCode);
+
+/**
+* Function to work out and then apply to the socket the appropriate
+* TOS value to set on packets when items *have* been retrieved from
+* local cache. Called by clientReplyContext::doGetMoreData if QOS is
+* enabled for TOS.
+* @param fd Descriptor of socket to set the TOS for
+*/
+int doTosLocalHit(const int fd);
+
+/**
+* Function to work out and then apply to the socket the appropriate
+* netfilter mark value to set on packets when items *have* been
+* retrieved from local cache. Called by clientReplyContext::doGetMoreData
+* if QOS is enabled for TOS.
+* @param fd Descriptor of socket to set the mark for
+*/
+int doNfmarkLocalHit(const int fd);
+
+/**
+* Function to set the TOS value of packets. Sets the value on the socket
+* which then gets copied to the packets.
+* @param fd Descriptor of socket to set the TOS for
+*/
+_SQUID_INLINE_ int setSockTos(int fd, tos_t tos);
+
+/**
+* Function to set the netfilter mark value of packets. Sets the value on the
+* socket which then gets copied to the packets. Called from Ip::Qos::doNfmarkLocalMiss
+* @param fd Descriptor of socket to set the mark for
+*/
+_SQUID_INLINE_ int setSockNfmark(int fd, nfmark_t mark);
/**
* QOS configuration class. Contains all the parameters for QOS functions as well
/// Whether we should modify TOS flags based on cache hits and misses.
_SQUID_INLINE_ bool isHitTosActive() const;
-
+
/// Whether we should modify netfilter marks based on cache hits and misses.
_SQUID_INLINE_ bool isHitNfmarkActive() const;
* to find out if any Netfilter marking is required.
* This function is used on initialisation to define capabilities required (Netfilter
* marking requires CAP_NET_ADMIN).
- */
+ */
_SQUID_INLINE_ bool isAclNfmarkActive() const;
/**
#if USE_QOS_NFMARK
int
Ip::Qos::GetNfMarkCallback(enum nf_conntrack_msg_type type,
- struct nf_conntrack *ct,
- void *data)
+ struct nf_conntrack *ct,
+ void *data)
{
fatal ("Not implemented");
}
{
fatal ("Not implemented");
}
-
+
int
Ip::Qos::doNfmarkLocalHit(const int fd) const
{