#if HAVE_ALLOCA_H
#include <alloca.h>
#else /* not __GNUC__ or HAVE_ALLOCA_H */
-#ifndef _AIX /* Already did AIX, up at the top. */
+#ifndef _AIX /* Already did AIX, up at the top. */
char *alloca();
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */
#define REGEX_ALLOCATE alloca
/* Assumes a `char *destination' variable. */
-#define REGEX_REALLOCATE(source, osize, nsize) \
- (destination = (char *) alloca (nsize), \
- memcpy (destination, source, osize), \
+#define REGEX_REALLOCATE(source, osize, nsize) \
+ (destination = (char *) alloca (nsize), \
+ memcpy (destination, source, osize), \
destination)
#endif /* not REGEX_MALLOC */
/* True if `size1' is non-NULL and PTR is pointing anywhere inside
* `string1' or just past its end. This works if PTR is NULL, which is
* a good thing. */
-#define FIRST_STRING_P(ptr) \
+#define FIRST_STRING_P(ptr) \
(size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
/* (Re)Allocate N items of type T using malloc, or fail. */
#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
-#define BYTEWIDTH 8 /* In bits. */
+#define BYTEWIDTH 8 /* In bits. */
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
-#if !defined(__MINGW32__) /* MinGW defines boolean */
+#if !defined(__MINGW32__) /* MinGW defines boolean */
typedef char boolean;
#endif
#define false 0
* bytes of number. */
set_number_at,
- wordchar, /* Matches any word-constituent character. */
- notwordchar, /* Matches any char that is not a word-constituent. */
+ wordchar, /* Matches any word-constituent character. */
+ notwordchar, /* Matches any char that is not a word-constituent. */
- wordbeg, /* Succeeds if at word beginning. */
- wordend, /* Succeeds if at word end. */
+ wordbeg, /* Succeeds if at word beginning. */
+ wordend, /* Succeeds if at word end. */
- wordbound, /* Succeeds if at a word boundary. */
- notwordbound /* Succeeds if not at a word boundary. */
+ wordbound, /* Succeeds if at a word boundary. */
+ notwordbound /* Succeeds if not at a word boundary. */
} re_opcode_t;
\f
/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
-#define STORE_NUMBER(destination, number) \
- do { \
- (destination)[0] = (number) & 0377; \
- (destination)[1] = (number) >> 8; \
+#define STORE_NUMBER(destination, number) \
+ do { \
+ (destination)[0] = (number) & 0377; \
+ (destination)[1] = (number) >> 8; \
} while (0)
/* Same as STORE_NUMBER, except increment DESTINATION to
* the byte after where the number is stored. Therefore, DESTINATION
* must be an lvalue. */
-#define STORE_NUMBER_AND_INCR(destination, number) \
- do { \
- STORE_NUMBER (destination, number); \
- (destination) += 2; \
+#define STORE_NUMBER_AND_INCR(destination, number) \
+ do { \
+ STORE_NUMBER (destination, number); \
+ (destination) += 2; \
} while (0)
/* Put into DESTINATION a number stored in two contiguous bytes starting
* at SOURCE. */
-#define EXTRACT_NUMBER(destination, source) \
- do { \
- (destination) = *(source) & 0377; \
- (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
+#define EXTRACT_NUMBER(destination, source) \
+ do { \
+ (destination) = *(source) & 0377; \
+ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
} while (0)
#ifdef DEBUG
*dest += temp << 8;
}
-#ifndef EXTRACT_MACROS /* To debug the macros. */
+#ifndef EXTRACT_MACROS /* To debug the macros. */
#undef EXTRACT_NUMBER
#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
#endif /* not EXTRACT_MACROS */
/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
* SOURCE must be an lvalue. */
-#define EXTRACT_NUMBER_AND_INCR(destination, source) \
- do { \
- EXTRACT_NUMBER (destination, source); \
- (source) += 2; \
+#define EXTRACT_NUMBER_AND_INCR(destination, source) \
+ do { \
+ EXTRACT_NUMBER (destination, source); \
+ (source) += 2; \
} while (0)
#ifdef DEBUG
#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
-#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
+#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
if (debug) print_partial_compiled_pattern (s, e)
-#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
+#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
if (debug) print_double_string (w, s1, sz1, s2, sz2)
extern void printchar();
/* This table gives an error message for each of the error codes listed
* in regex.h. Obviously the order here has to be same as there. */
-static const char *re_error_msg[] = {NULL, /* REG_NOERROR */
- "No match", /* REG_NOMATCH */
- "Invalid regular expression", /* REG_BADPAT */
- "Invalid collation character", /* REG_ECOLLATE */
- "Invalid character class name", /* REG_ECTYPE */
- "Trailing backslash", /* REG_EESCAPE */
- "Invalid back reference", /* REG_ESUBREG */
- "Unmatched [ or [^", /* REG_EBRACK */
- "Unmatched ( or \\(", /* REG_EPAREN */
- "Unmatched \\{", /* REG_EBRACE */
- "Invalid content of \\{\\}", /* REG_BADBR */
- "Invalid range end", /* REG_ERANGE */
- "Memory exhausted", /* REG_ESPACE */
- "Invalid preceding regular expression", /* REG_BADRPT */
- "Premature end of regular expression", /* REG_EEND */
- "Regular expression too big", /* REG_ESIZE */
- "Unmatched ) or \\)", /* REG_ERPAREN */
+static const char *re_error_msg[] = {NULL, /* REG_NOERROR */
+ "No match", /* REG_NOMATCH */
+ "Invalid regular expression", /* REG_BADPAT */
+ "Invalid collation character", /* REG_ECOLLATE */
+ "Invalid character class name", /* REG_ECTYPE */
+ "Trailing backslash", /* REG_EESCAPE */
+ "Invalid back reference", /* REG_ESUBREG */
+ "Unmatched [ or [^", /* REG_EBRACK */
+ "Unmatched ( or \\(", /* REG_EPAREN */
+ "Unmatched \\{", /* REG_EBRACE */
+ "Invalid content of \\{\\}", /* REG_BADBR */
+ "Invalid range end", /* REG_ERANGE */
+ "Memory exhausted", /* REG_ESPACE */
+ "Invalid preceding regular expression", /* REG_BADRPT */
+ "Premature end of regular expression", /* REG_EEND */
+ "Regular expression too big", /* REG_ESIZE */
+ "Unmatched ) or \\)", /* REG_ERPAREN */
};
\f
/* Subroutine declarations and macros for regex_compile. */
* if necessary. Also cast from a signed character in the constant
* string passed to us by the user to an unsigned char that we can use
* as an array index (in, e.g., `translate'). */
-#define PATFETCH(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
- if (translate) c = translate[c]; \
+#define PATFETCH(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (unsigned char) *p++; \
+ if (translate) c = translate[c]; \
} while (0)
/* Fetch the next character in the uncompiled pattern, with no
* translation. */
-#define PATFETCH_RAW(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
+#define PATFETCH_RAW(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (unsigned char) *p++; \
} while (0)
/* Go backwards one character in the pattern. */
#define INIT_BUF_SIZE 32
/* Make sure we have at least N more bytes of space in buffer. */
-#define GET_BUFFER_SPACE(n) \
- while (b - bufp->buffer + (n) > bufp->allocated) \
+#define GET_BUFFER_SPACE(n) \
+ while (b - bufp->buffer + (n) > bufp->allocated) \
EXTEND_BUFFER ()
/* Make sure we have one more byte of buffer space and then add C to it. */
-#define BUF_PUSH(c) \
- do { \
- GET_BUFFER_SPACE (1); \
- *b++ = (unsigned char) (c); \
+#define BUF_PUSH(c) \
+ do { \
+ GET_BUFFER_SPACE (1); \
+ *b++ = (unsigned char) (c); \
} while (0)
/* Ensure we have two more bytes of buffer space and then append C1 and C2. */
-#define BUF_PUSH_2(c1, c2) \
- do { \
- GET_BUFFER_SPACE (2); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
+#define BUF_PUSH_2(c1, c2) \
+ do { \
+ GET_BUFFER_SPACE (2); \
+ *b++ = (unsigned char) (c1); \
+ *b++ = (unsigned char) (c2); \
} while (0)
/* As with BUF_PUSH_2, except for three bytes. */
-#define BUF_PUSH_3(c1, c2, c3) \
- do { \
- GET_BUFFER_SPACE (3); \
- *b++ = (unsigned char) (c1); \
- *b++ = (unsigned char) (c2); \
- *b++ = (unsigned char) (c3); \
+#define BUF_PUSH_3(c1, c2, c3) \
+ do { \
+ GET_BUFFER_SPACE (3); \
+ *b++ = (unsigned char) (c1); \
+ *b++ = (unsigned char) (c2); \
+ *b++ = (unsigned char) (c3); \
} while (0)
/* Store a jump with opcode OP at LOC to location TO. We store a
* reset the pointers that pointed into the old block to point to the
* correct places in the new one. If extending the buffer results in it
* being larger than MAX_BUF_SIZE, then flag memory exhausted. */
-#define EXTEND_BUFFER() \
- do { \
- unsigned char *old_buffer = bufp->buffer; \
- if (bufp->allocated == MAX_BUF_SIZE) \
- return REG_ESIZE; \
- bufp->allocated <<= 1; \
- if (bufp->allocated > MAX_BUF_SIZE) \
- bufp->allocated = MAX_BUF_SIZE; \
+#define EXTEND_BUFFER() \
+ do { \
+ unsigned char *old_buffer = bufp->buffer; \
+ if (bufp->allocated == MAX_BUF_SIZE) \
+ return REG_ESIZE; \
+ bufp->allocated <<= 1; \
+ if (bufp->allocated > MAX_BUF_SIZE) \
+ bufp->allocated = MAX_BUF_SIZE; \
bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\
- if (bufp->buffer == NULL) \
- return REG_ESPACE; \
- /* If the buffer moved, move all the pointers into it. */ \
- if (old_buffer != bufp->buffer) \
- { \
- b = (b - old_buffer) + bufp->buffer; \
- begalt = (begalt - old_buffer) + bufp->buffer; \
- if (fixup_alt_jump) \
+ if (bufp->buffer == NULL) \
+ return REG_ESPACE; \
+ /* If the buffer moved, move all the pointers into it. */ \
+ if (old_buffer != bufp->buffer) \
+ { \
+ b = (b - old_buffer) + bufp->buffer; \
+ begalt = (begalt - old_buffer) + bufp->buffer; \
+ if (fixup_alt_jump) \
fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
- if (laststart) \
- laststart = (laststart - old_buffer) + bufp->buffer; \
- if (pending_exact) \
- pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
- } \
+ if (laststart) \
+ laststart = (laststart - old_buffer) + bufp->buffer; \
+ if (pending_exact) \
+ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
+ } \
} while (0)
/* Since we have one byte reserved for the register number argument to
typedef struct {
compile_stack_elt_t *stack;
unsigned size;
- unsigned avail; /* Offset of next open position. */
+ unsigned avail; /* Offset of next open position. */
} compile_stack_type;
static void store_op1(re_opcode_t op, unsigned char *loc, int arg);
|= 1 << (((unsigned char) c) % BYTEWIDTH))
/* Get the next unsigned number in the uncompiled pattern. */
-#define GET_UNSIGNED_NUMBER(num) \
- { if (p != pend) \
- { \
- PATFETCH (c); \
- while (ISDIGIT (c)) \
- { \
- if (num < 0) \
- num = 0; \
- num = num * 10 + c - '0'; \
- if (p == pend) \
- break; \
- PATFETCH (c); \
- } \
- } \
+#define GET_UNSIGNED_NUMBER(num) \
+ { if (p != pend) \
+ { \
+ PATFETCH (c); \
+ while (ISDIGIT (c)) \
+ { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ if (p == pend) \
+ break; \
+ PATFETCH (c); \
+ } \
+ } \
}
-#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
-#define IS_CHAR_CLASS(string) \
- (STREQ (string, "alpha") || STREQ (string, "upper") \
- || STREQ (string, "lower") || STREQ (string, "digit") \
- || STREQ (string, "alnum") || STREQ (string, "xdigit") \
- || STREQ (string, "space") || STREQ (string, "print") \
- || STREQ (string, "punct") || STREQ (string, "graph") \
+#define IS_CHAR_CLASS(string) \
+ (STREQ (string, "alpha") || STREQ (string, "upper") \
+ || STREQ (string, "lower") || STREQ (string, "digit") \
+ || STREQ (string, "alnum") || STREQ (string, "xdigit") \
+ || STREQ (string, "space") || STREQ (string, "print") \
+ || STREQ (string, "punct") || STREQ (string, "graph") \
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
\f
/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
#endif
if (bufp->allocated == 0) {
- if (bufp->buffer) { /* If zero allocated, but buffer is non-null, try to realloc
- * enough space. This loses if buffer's address is bogus, but
- * that is the user's responsibility. */
+ if (bufp->buffer) {
+ /* If zero allocated, but buffer is non-null, try to realloc
+ * enough space. This loses if buffer's address is bogus, but
+ * that is the user's responsibility. */
RETALLOC(bufp->buffer, INIT_BUF_SIZE, unsigned char);
- } else { /* Caller did not allocate a buffer. Do it for them. */
+ } else { /* Caller did not allocate a buffer. Do it for them. */
bufp->buffer = TALLOC(INIT_BUF_SIZE, unsigned char);
}
if (!bufp->buffer)
switch (c) {
case '^': {
- if ( /* If at start of pattern, it's an operator. */
+ if ( /* If at start of pattern, it's an operator. */
p == pattern + 1
/* If context independent, it's an operator. */
|| syntax & RE_CONTEXT_INDEP_ANCHORS
break;
case '$': {
- if ( /* If at end of pattern, it's an operator. */
+ if ( /* If at end of pattern, it's an operator. */
p == pend
/* If context independent, it's an operator. */
|| syntax & RE_CONTEXT_INDEP_ANCHORS
/* Now we know whether or not zero matches is allowed
* and also whether or not two or more matches is allowed. */
- if (many_times_ok) { /* More than one repetition is allowed, so put in at the
- * end a backward relative jump from `b' to before the next
- * jump we're going to put in below (which jumps from
- * laststart to after this jump).
- *
- * But if we are at the `*' in the exact sequence `.*\n',
- * insert an unconditional jump backwards to the .,
- * instead of the beginning of the loop. This way we only
- * push a failure point once, instead of every time
- * through the loop. */
+ if (many_times_ok) {
+ /* More than one repetition is allowed, so put in at the
+ * end a backward relative jump from `b' to before the next
+ * jump we're going to put in below (which jumps from
+ * laststart to after this jump).
+ *
+ * But if we are at the `*' in the exact sequence `.*\n',
+ * insert an unconditional jump backwards to the .,
+ * instead of the beginning of the loop. This way we only
+ * push a failure point once, instead of every time
+ * through the loop. */
assert(p - 1 > pattern);
/* Allocate the space for the jump. */
if (TRANSLATE(*(p - 2)) == TRANSLATE('.')
&& zero_times_ok
&& p < pend && TRANSLATE(*p) == TRANSLATE('\n')
- && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */
+ && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */
STORE_JUMP(jump, b, laststart);
keep_string_p = true;
} else
&& !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
&& *p != ']') {
reg_errcode_t ret
- = compile_range(&p, pend, translate, syntax, b);
+ = compile_range(&p, pend, translate, syntax, b);
if (ret != REG_NOERROR)
return ret;
- } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */
+ } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */
reg_errcode_t ret;
/* Move past the `-'. */
/* See if we're at the beginning of a possible character
* class. */
- else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null. */
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null. */
char str[CHAR_CLASS_MAX_LENGTH + 1];
PATFETCH(c);
* be valid. */
COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
COMPILE_STACK_TOP.fixup_alt_jump
- = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
+ = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
COMPILE_STACK_TOP.regnum = regnum;
return REG_ERPAREN;
}
handle_close:
- if (fixup_alt_jump) { /* Push a dummy failure point at the end of the
- * alternative for a possible future
- * `pop_failure_jump' to pop. See comments at
- * `push_dummy_failure' in `re_match_2'. */
+ if (fixup_alt_jump) {
+ /* Push a dummy failure point at the end of the
+ * alternative for a possible future
+ * `pop_failure_jump' to pop. See comments at
+ * `push_dummy_failure' in `re_match_2'. */
BUF_PUSH(push_dummy_failure);
/* We allocated space for this jump when we assigned
compile_stack.avail--;
begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
fixup_alt_jump
- = COMPILE_STACK_TOP.fixup_alt_jump
- ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
- : 0;
+ = COMPILE_STACK_TOP.fixup_alt_jump
+ ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
+ : 0;
laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
this_group_regnum = COMPILE_STACK_TOP.regnum;
/* If we've reached MAX_REGNUM groups, then this open
* groups were inside this one. */
if (this_group_regnum <= MAX_REGNUM) {
unsigned char *inner_group_loc
- = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
+ = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
*inner_group_loc = regnum - this_group_regnum;
BUF_PUSH_3(stop_memory, this_group_regnum,
}
break;
- case '|': /* `\|'. */
+ case '|': /* `\|'. */
if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
goto normal_backslash;
handle_alt:
* jump_n <succeed_n addr> <jump count>
* (The upper bound and `jump_n' are omitted if
* `upper_bound' is 1, though.) */
- else { /* If the upper bound is > 1, we need to insert
- * more at the end of the loop. */
+ else {
+ /* If the upper bound is > 1, we need to insert
+ * more at the end of the loop. */
unsigned nbytes = 10 + (upper_bound > 1) * 10;
GET_BUFFER_SPACE(nbytes);
insert_op2(set_number_at, laststart, 5, lower_bound, b);
b += 5;
- if (upper_bound > 1) { /* More than one repetition is allowed, so
- * append a backward jump to the `succeed_n'
- * that starts this interval.
- *
- * When we've reached this during matching,
- * we'll have matched the interval once, so
- * jump back only `upper_bound - 1' times. */
+ if (upper_bound > 1) {
+ /* More than one repetition is allowed, so
+ * append a backward jump to the `succeed_n'
+ * that starts this interval.
+ *
+ * When we've reached this during matching,
+ * we'll have matched the interval once, so
+ * jump back only `upper_bound - 1' times. */
STORE_JUMP2(jump_n, b, laststart + 5,
upper_bound - 1);
b += 5;
BUF_PUSH(c);
(*pending_exact)++;
break;
- } /* switch (c) */
- } /* while p != pend */
+ } /* switch (c) */
+ } /* while p != pend */
/* Through the pattern now. */
#endif /* DEBUG */
return REG_NOERROR;
-} /* regex_compile */
+} /* regex_compile */
\f
/* Subroutines for `regex_compile'. */
typedef struct {
fail_stack_elt_t *stack;
unsigned size;
- unsigned avail; /* Offset of next open position. */
+ unsigned avail; /* Offset of next open position. */
} fail_stack_type;
#define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */
-#define INIT_FAIL_STACK() \
- do { \
- fail_stack.stack = (fail_stack_elt_t *) \
- REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \
- \
- if (fail_stack.stack == NULL) \
- return -2; \
- \
- fail_stack.size = INIT_FAILURE_ALLOC; \
- fail_stack.avail = 0; \
+#define INIT_FAIL_STACK() \
+ do { \
+ fail_stack.stack = (fail_stack_elt_t *) \
+ REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \
+ \
+ if (fail_stack.stack == NULL) \
+ return -2; \
+ \
+ fail_stack.size = INIT_FAILURE_ALLOC; \
+ fail_stack.avail = 0; \
} while (0)
/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
*
* REGEX_REALLOCATE requires `destination' be declared. */
-#define DOUBLE_FAIL_STACK(fail_stack) \
- ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
- ? 0 \
- : ((fail_stack).stack = (fail_stack_elt_t *) \
- REGEX_REALLOCATE ((fail_stack).stack, \
- (fail_stack).size * sizeof (fail_stack_elt_t), \
- ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \
- \
- (fail_stack).stack == NULL \
- ? 0 \
- : ((fail_stack).size <<= 1, \
+#define DOUBLE_FAIL_STACK(fail_stack) \
+ ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
+ ? 0 \
+ : ((fail_stack).stack = (fail_stack_elt_t *) \
+ REGEX_REALLOCATE ((fail_stack).stack, \
+ (fail_stack).size * sizeof (fail_stack_elt_t), \
+ ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \
+ \
+ (fail_stack).stack == NULL \
+ ? 0 \
+ : ((fail_stack).size <<= 1, \
1)))
/* Push PATTERN_OP on FAIL_STACK.
*
* Return 1 if was able to do so and 0 if ran out of memory allocating
* space to do so. */
-#define PUSH_PATTERN_OP(pattern_op, fail_stack) \
- ((FAIL_STACK_FULL () \
- && !DOUBLE_FAIL_STACK (fail_stack)) \
- ? 0 \
- : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
+#define PUSH_PATTERN_OP(pattern_op, fail_stack) \
+ ((FAIL_STACK_FULL () \
+ && !DOUBLE_FAIL_STACK (fail_stack)) \
+ ? 0 \
+ : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
1))
/* This pushes an item onto the failure stack. Must be a four-byte
* value. Assumes the variable `fail_stack'. Probably should only
* be called from within `PUSH_FAILURE_POINT'. */
-#define PUSH_FAILURE_ITEM(item) \
+#define PUSH_FAILURE_ITEM(item) \
fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item
/* The complement operation. Assumes `fail_stack' is nonempty. */
*
* Does `return FAILURE_CODE' if runs out of memory. */
-#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
- do { \
- char *destination; \
- /* Must be int, so when we don't save any registers, the arithmetic \
- of 0 + -1 isn't done as unsigned. */ \
- int this_reg; \
- \
- DEBUG_STATEMENT (failure_id++); \
- DEBUG_STATEMENT (nfailure_points_pushed++); \
- DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
+#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
+ do { \
+ char *destination; \
+ /* Must be int, so when we don't save any registers, the arithmetic \
+ of 0 + -1 isn't done as unsigned. */ \
+ int this_reg; \
+ \
+ DEBUG_STATEMENT (failure_id++); \
+ DEBUG_STATEMENT (nfailure_points_pushed++); \
+ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\
DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\
- \
- DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \
- DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
- \
- /* Ensure we have enough space allocated for what we will push. */ \
- while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
- { \
- if (!DOUBLE_FAIL_STACK (fail_stack)) \
- return failure_code; \
- \
- DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
- (fail_stack).size); \
+ \
+ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \
+ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
+ \
+ /* Ensure we have enough space allocated for what we will push. */ \
+ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
+ { \
+ if (!DOUBLE_FAIL_STACK (fail_stack)) \
+ return failure_code; \
+ \
+ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
+ (fail_stack).size); \
DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
- } \
- \
- /* Push the info, starting with the registers. */ \
- DEBUG_PRINT1 ("\n"); \
- \
- for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
- this_reg++) \
- { \
- DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \
- DEBUG_STATEMENT (num_regs_pushed++); \
- \
- DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
- PUSH_FAILURE_ITEM (regstart[this_reg]); \
+ } \
+ \
+ /* Push the info, starting with the registers. */ \
+ DEBUG_PRINT1 ("\n"); \
+ \
+ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
+ this_reg++) \
+ { \
+ DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \
+ DEBUG_STATEMENT (num_regs_pushed++); \
+ \
+ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
+ PUSH_FAILURE_ITEM (regstart[this_reg]); \
\
- DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
- PUSH_FAILURE_ITEM (regend[this_reg]); \
- \
- DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \
- DEBUG_PRINT2 (" match_null=%d", \
- REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
- DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
- DEBUG_PRINT2 (" matched_something=%d", \
- MATCHED_SOMETHING (reg_info[this_reg])); \
- DEBUG_PRINT2 (" ever_matched=%d", \
- EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
- DEBUG_PRINT1 ("\n"); \
- PUSH_FAILURE_ITEM (reg_info[this_reg].word); \
- } \
- \
+ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
+ PUSH_FAILURE_ITEM (regend[this_reg]); \
+ \
+ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \
+ DEBUG_PRINT2 (" match_null=%d", \
+ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" matched_something=%d", \
+ MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" ever_matched=%d", \
+ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT1 ("\n"); \
+ PUSH_FAILURE_ITEM (reg_info[this_reg].word); \
+ } \
+ \
DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\
- PUSH_FAILURE_ITEM (lowest_active_reg); \
- \
+ PUSH_FAILURE_ITEM (lowest_active_reg); \
+ \
DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
- PUSH_FAILURE_ITEM (highest_active_reg); \
- \
- DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
- DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
- PUSH_FAILURE_ITEM (pattern_place); \
- \
- DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
+ PUSH_FAILURE_ITEM (highest_active_reg); \
+ \
+ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
+ PUSH_FAILURE_ITEM (pattern_place); \
+ \
+ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
- size2); \
- DEBUG_PRINT1 ("'\n"); \
- PUSH_FAILURE_ITEM (string_place); \
- \
- DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
- DEBUG_PUSH (failure_id); \
+ size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ PUSH_FAILURE_ITEM (string_place); \
+ \
+ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
+ DEBUG_PUSH (failure_id); \
} while (0)
/* This is the number of items that are pushed and popped on the stack
/* Individual items aside from the registers. */
#ifdef DEBUG
-#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
+#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
#else
#define NUM_NONREG_ITEMS 4
#endif
#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
/* We actually push this many items. */
-#define NUM_FAILURE_ITEMS \
- ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \
+#define NUM_FAILURE_ITEMS \
+ ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \
+ NUM_NONREG_ITEMS)
/* How many items can still be added to the stack without overflowing it. */
* `pend', `string1', `size1', `string2', and `size2'. */
#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
-{ \
- DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \
- int this_reg; \
- const unsigned char *string_temp; \
- \
- assert (!FAIL_STACK_EMPTY ()); \
- \
- /* Remove failure points and point to how many regs pushed. */ \
- DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
- DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
- DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
- \
- assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
- \
- DEBUG_POP (&failure_id); \
- DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
- \
- /* If the saved string location is NULL, it came from an \
- on_failure_keep_string_jump opcode, and we want to throw away the \
- saved NULL, thus retaining our current position in the string. */ \
- string_temp = POP_FAILURE_ITEM (); \
- if (string_temp != NULL) \
- str = (const char *) string_temp; \
- \
- DEBUG_PRINT2 (" Popping string 0x%x: `", str); \
- DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
- DEBUG_PRINT1 ("'\n"); \
- \
- pat = (unsigned char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
- DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
- \
- /* Restore register info. */ \
- high_reg = (unsigned long) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
- \
- low_reg = (unsigned long) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
- \
- for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
- { \
- DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
- \
- reg_info[this_reg].word = POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \
- \
- regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
- \
- regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \
- DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
- } \
- \
- DEBUG_STATEMENT (nfailure_points_popped++); \
-} /* POP_FAILURE_POINT */
+{ \
+ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \
+ int this_reg; \
+ const unsigned char *string_temp; \
+ \
+ assert (!FAIL_STACK_EMPTY ()); \
+ \
+ /* Remove failure points and point to how many regs pushed. */ \
+ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
+ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
+ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
+ \
+ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
+ \
+ DEBUG_POP (&failure_id); \
+ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
+ \
+ /* If the saved string location is NULL, it came from an \
+ on_failure_keep_string_jump opcode, and we want to throw away the \
+ saved NULL, thus retaining our current position in the string. */ \
+ string_temp = POP_FAILURE_ITEM (); \
+ if (string_temp != NULL) \
+ str = (const char *) string_temp; \
+ \
+ DEBUG_PRINT2 (" Popping string 0x%x: `", str); \
+ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ \
+ pat = (unsigned char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
+ \
+ /* Restore register info. */ \
+ high_reg = (unsigned long) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
+ \
+ low_reg = (unsigned long) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
+ \
+ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
+ { \
+ DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
+ \
+ reg_info[this_reg].word = POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \
+ \
+ regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
+ \
+ regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
+ } \
+ \
+ DEBUG_STATEMENT (nfailure_points_popped++); \
+} /* POP_FAILURE_POINT */
\f
/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
* BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible
assert(fastmap != NULL && p != NULL);
INIT_FAIL_STACK();
- memset(fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */
- bufp->fastmap_accurate = 1; /* It will be when we're done. */
+ memset(fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */
+ bufp->fastmap_accurate = 1; /* It will be when we're done. */
bufp->can_be_null = 0;
while (p != pend || !FAIL_STACK_EMPTY()) {
#endif
{
- /* I guess the idea here is to simply not bother with a fastmap
- * if a backreference is used, since it's too hard to figure out
- * the fastmap for the corresponding group. Setting
- * `can_be_null' stops `re_search_2' from using the fastmap, so
- * that is all we do. */
+ /* I guess the idea here is to simply not bother with a fastmap
+ * if a backreference is used, since it's too hard to figure out
+ * the fastmap for the corresponding group. Setting
+ * `can_be_null' stops `re_search_2' from using the fastmap, so
+ * that is all we do. */
case duplicate:
bufp->can_be_null = 1;
return 0;
- /* Following are the cases which match a character. These end
- * with `break'. */
+ /* Following are the cases which match a character. These end
+ * with `break'. */
case exactn:
fastmap[p[1]] = 1;
bufp->can_be_null = 1;
if (succeed_n_p) {
- EXTRACT_NUMBER_AND_INCR(k, p); /* Skip the n. */
+ EXTRACT_NUMBER_AND_INCR(k, p); /* Skip the n. */
succeed_n_p = false;
}
continue;
EXTRACT_NUMBER_AND_INCR(k, p);
if (k == 0) {
p -= 4;
- succeed_n_p = true; /* Spaghetti code alert. */
+ succeed_n_p = true; /* Spaghetti code alert. */
goto handle_on_failure_jump;
}
continue;
continue;
default:
- abort(); /* We have listed all the cases. */
- } /* switch *p++ */
+ abort(); /* We have listed all the cases. */
+ } /* switch *p++ */
/* Getting here means we have found the possible starting
* characters for one path of the pattern -- and that the empty
* does these things. */
path_can_be_null = false;
p = pend;
- } /* while p */
+ } /* while p */
/* Set `can_be_null' for the last path (also the first path, if the
* pattern is empty). */
bufp->can_be_null |= path_can_be_null;
return 0;
-} /* re_compile_fastmap */
+} /* re_compile_fastmap */
\f
/* Searching routines. */
* null string, however, we don't need to skip characters; we want
* the first null string. */
if (fastmap && startpos < total_size && !bufp->can_be_null) {
- if (range > 0) { /* Searching forwards. */
+ if (range > 0) { /* Searching forwards. */
register const char *d;
register int lim = 0;
int irange = range;
range--;
startpos += irange - range;
- } else { /* Searching backwards. */
+ } else { /* Searching backwards. */
register char c = (size1 == 0 || startpos >= size1
? string2[startpos - size1]
: string1[startpos]);
}
}
return -1;
-} /* re_search_2 */
+} /* re_search_2 */
\f
/* Declarations and macros for re_match_2. */
/* Call this when have matched a real character; it sets `matched' flags
* for the subexpressions which we are currently inside. Also records
* that those subexprs have matched. */
-#define SET_REGS_MATCHED() \
- do \
- { \
- unsigned r; \
- for (r = lowest_active_reg; r <= highest_active_reg; r++) \
- { \
- MATCHED_SOMETHING (reg_info[r]) \
- = EVER_MATCHED_SOMETHING (reg_info[r]) \
- = 1; \
- } \
- } \
+#define SET_REGS_MATCHED() \
+ do \
+ { \
+ unsigned r; \
+ for (r = lowest_active_reg; r <= highest_active_reg; r++) \
+ { \
+ MATCHED_SOMETHING (reg_info[r]) \
+ = EVER_MATCHED_SOMETHING (reg_info[r]) \
+ = 1; \
+ } \
+ } \
while (0)
/* This converts PTR, a pointer into one of the search strings `string1'
* and `string2' into an offset from the beginning of that string. */
-#define POINTER_TO_OFFSET(ptr) \
+#define POINTER_TO_OFFSET(ptr) \
(FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1)
/* Registers are set to a sentinel when they haven't yet matched. */
/* Call before fetching a character with *d. This switches over to
* string2 if necessary. */
-#define PREFETCH() \
- while (d == dend) \
- { \
- /* End of string2 => fail. */ \
- if (dend == end_match_2) \
- goto fail; \
- /* End of string1 => advance to string2. */ \
- d = string2; \
- dend = end_match_2; \
+#define PREFETCH() \
+ while (d == dend) \
+ { \
+ /* End of string2 => fail. */ \
+ if (dend == end_match_2) \
+ goto fail; \
+ /* End of string1 => advance to string2. */ \
+ d = string2; \
+ dend = end_match_2; \
}
/* Test if at very beginning or at very end of the virtual concatenation
* two special cases to check for: if past the end of string1, look at
* the first character in string2; and if before the beginning of
* string2, look at the last character in string1. */
-#define WORDCHAR_P(d) \
- (re_syntax_table[(d) == end1 ? *string2 \
- : (d) == string2 - 1 ? *(end1 - 1) : *(d)] \
+#define WORDCHAR_P(d) \
+ (re_syntax_table[(d) == end1 ? *string2 \
+ : (d) == string2 - 1 ? *(end1 - 1) : *(d)] \
== Sword)
static int
wordchar_p(const char *d, const char *end1, const char *string2)
/* Test if the character before D and the one at D differ with respect
* to being word-constituent. */
-#define AT_WORD_BOUNDARY(d) \
- (AT_STRINGS_BEG (d) || at_strings_end(d,end2) \
+#define AT_WORD_BOUNDARY(d) \
+ (AT_STRINGS_BEG (d) || at_strings_end(d,end2) \
|| WORDCHAR_P (d - 1) != WORDCHAR_P (d))
/* Free everything we malloc. */
#ifdef REGEX_MALLOC
#define FREE_VAR(var) if (var) free (var); var = NULL
-#define FREE_VARIABLES() \
- do { \
- FREE_VAR (fail_stack.stack); \
- FREE_VAR (regstart); \
- FREE_VAR (regend); \
- FREE_VAR (old_regstart); \
- FREE_VAR (old_regend); \
- FREE_VAR (best_regstart); \
- FREE_VAR (best_regend); \
- FREE_VAR (reg_info); \
- FREE_VAR (reg_dummy); \
- FREE_VAR (reg_info_dummy); \
+#define FREE_VARIABLES() \
+ do { \
+ FREE_VAR (fail_stack.stack); \
+ FREE_VAR (regstart); \
+ FREE_VAR (regend); \
+ FREE_VAR (old_regstart); \
+ FREE_VAR (old_regend); \
+ FREE_VAR (best_regstart); \
+ FREE_VAR (best_regend); \
+ FREE_VAR (reg_info); \
+ FREE_VAR (reg_dummy); \
+ FREE_VAR (reg_info_dummy); \
} while (0)
#else /* not REGEX_MALLOC */
/* Some MIPS systems (at least) want this to free alloca'd storage. */
for (;;) {
DEBUG_PRINT2("\n0x%x: ", p);
- if (p == pend) { /* End of pattern means we might have succeeded. */
+ if (p == pend) { /* End of pattern means we might have succeeded. */
DEBUG_PRINT1("end of pattern ... ");
/* If we haven't matched the entire string, and we want the
if (d != end_match_2) {
DEBUG_PRINT1("backtracking.\n");
- if (!FAIL_STACK_EMPTY()) { /* More failure points to try. */
+ if (!FAIL_STACK_EMPTY()) { /* More failure points to try. */
boolean same_str_p = (FIRST_STRING_P(match_end)
== MATCHING_IN_FIRST_STRING);
regend[mcnt] = best_regend[mcnt];
}
}
- } /* d != end_match_2 */
+ } /* d != end_match_2 */
DEBUG_PRINT1("Accepting match.\n");
/* If caller wants register contents data back, do it. */
if (regs && !bufp->no_sub) {
/* Have the register data arrays been allocated? */
- if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one
- * extra element beyond `num_regs' for the `-1' marker
- * GNU code uses. */
+ if (bufp->regs_allocated == REGS_UNALLOCATED) {
+ /* No. So allocate them with malloc. We need one
+ * extra element beyond `num_regs' for the `-1' marker
+ * GNU code uses. */
regs->num_regs = max(RE_NREGS, num_regs + 1);
regs->start = TALLOC(regs->num_regs, regoff_t);
regs->end = TALLOC(regs->num_regs, regoff_t);
if (regs->start == NULL || regs->end == NULL)
return -2;
bufp->regs_allocated = REGS_REALLOCATE;
- } else if (bufp->regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already
- * allocated, reallocate them. If we need fewer, just
- * leave it alone. */
+ } else if (bufp->regs_allocated == REGS_REALLOCATE) {
+ /* Yes. If we need more elements than were already
+ * allocated, reallocate them. If we need fewer, just
+ * leave it alone. */
if (regs->num_regs < num_regs + 1) {
regs->num_regs = num_regs + 1;
RETALLOC(regs->start, regs->num_regs, regoff_t);
* -1 at the end. */
for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
regs->start[mcnt] = regs->end[mcnt] = -1;
- } /* regs && !bufp->no_sub */
+ } /* regs && !bufp->no_sub */
FREE_VARIABLES();
DEBUG_PRINT4("%u failure points pushed, %u popped (%u remain).\n",
nfailure_points_pushed, nfailure_points_popped,
switch ((re_opcode_t) * p++)
#endif
{
- /* Ignore these. Used to ignore the n of succeed_n's which
- * currently have n == 0. */
+ /* Ignore these. Used to ignore the n of succeed_n's which
+ * currently have n == 0. */
case no_op:
DEBUG_PRINT1("EXECUTING no_op.\n");
break;
- /* Match the next n pattern characters exactly. The following
- * byte in the pattern defines n, and the n bytes after that
- * are the characters to match. */
+ /* Match the next n pattern characters exactly. The following
+ * byte in the pattern defines n, and the n bytes after that
+ * are the characters to match. */
case exactn:
mcnt = *p++;
DEBUG_PRINT2("EXECUTING exactn %d.\n", mcnt);
SET_REGS_MATCHED();
break;
- /* Match any character except possibly a newline or a null. */
+ /* Match any character except possibly a newline or a null. */
case anychar:
DEBUG_PRINT1("EXECUTING anychar.\n");
DEBUG_PRINT2("EXECUTING charset%s.\n", not ? "_not" : "");
PREFETCH();
- c = TRANSLATE(*d); /* The character to match. */
+ c = TRANSLATE(*d); /* The character to match. */
/* Cast to `unsigned' instead of `unsigned char' in case the
* bit list is a full 32 bytes long. */
DEBUG_PRINT3("EXECUTING start_memory %d (%d):\n", *p, p[1]);
/* Find out if this group can match the empty string. */
- p1 = p; /* To send to group_match_null_string_p. */
+ p1 = p; /* To send to group_match_null_string_p. */
if (REG_MATCH_NULL_STRING_P(reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
REG_MATCH_NULL_STRING_P(reg_info[*p])
- = group_match_null_string_p(&p1, pend, reg_info);
+ = group_match_null_string_p(&p1, pend, reg_info);
/* Save the position in the string where we were the last time
* we were at this open-group operator in case the group is
* the string in case this attempt to match fails. */
old_regstart[*p] = REG_MATCH_NULL_STRING_P(reg_info[*p])
? REG_UNSET(regstart[*p]) ? d : regstart[*p]
- : regstart[*p];
+ : regstart[*p];
DEBUG_PRINT2(" old_regstart: %d\n",
POINTER_TO_OFFSET(old_regstart[*p]));
p += 2;
break;
- /* The stop_memory opcode represents the end of a group. Its
- * arguments are the same as start_memory's: the register
- * number, and the number of inner groups. */
+ /* The stop_memory opcode represents the end of a group. Its
+ * arguments are the same as start_memory's: the register
+ * number, and the number of inner groups. */
case stop_memory:
DEBUG_PRINT3("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
* the string in case this attempt to match fails. */
old_regend[*p] = REG_MATCH_NULL_STRING_P(reg_info[*p])
? REG_UNSET(regend[*p]) ? d : regend[*p]
- : regend[*p];
+ : regend[*p];
DEBUG_PRINT2(" old_regend: %d\n",
POINTER_TO_OFFSET(old_regend[*p]));
if (lowest_active_reg == highest_active_reg) {
lowest_active_reg = NO_LOWEST_ACTIVE_REG;
highest_active_reg = NO_HIGHEST_ACTIVE_REG;
- } else { /* We must scan for the new highest active register, since
- * it isn't necessarily one less than now: consider
- * (a(b)c(d(e)f)g). When group 3 ends, after the f), the
- * new highest active register is 1. */
+ } else {
+ /* We must scan for the new highest active register, since
+ * it isn't necessarily one less than now: consider
+ * (a(b)c(d(e)f)g). When group 3 ends, after the f), the
+ * new highest active register is 1. */
unsigned char r = *p - 1;
while (r > 0 && !IS_ACTIVE(reg_info[r]))
r--;
p += 2;
break;
- /* \<digit> has been turned into a `duplicate' command which is
- * followed by the numeric value of <digit> as the register number. */
+ /* \<digit> has been turned into a `duplicate' command which is
+ * followed by the numeric value of <digit> as the register number. */
case duplicate: {
register const char *d2, *dend2;
- int regno = *p++; /* Get which register to match against. */
+ int regno = *p++; /* Get which register to match against. */
DEBUG_PRINT2("EXECUTING duplicate %d.\n", regno);
/* Can't back reference a group which we've never matched. */
/* In all other cases, we fail. */
goto fail;
- /* endline is the dual of begline. */
+ /* endline is the dual of begline. */
case endline:
DEBUG_PRINT1("EXECUTING endline.\n");
}
goto fail;
- /* Match at the very beginning of the data. */
+ /* Match at the very beginning of the data. */
case begbuf:
DEBUG_PRINT1("EXECUTING begbuf.\n");
if (AT_STRINGS_BEG(d))
break;
goto fail;
- /* Match at the very end of the data. */
+ /* Match at the very end of the data. */
case endbuf:
DEBUG_PRINT1("EXECUTING endbuf.\n");
if (at_strings_end(d,end2))
break;
goto fail;
- /* on_failure_keep_string_jump is used to optimize `.*\n'. It
- * pushes NULL as the value for the string on the stack. Then
- * `pop_failure_point' will keep the current value for the
- * string, instead of restoring it. To see why, consider
- * matching `foo\nbar' against `.*\n'. The .* matches the foo;
- * then the . fails against the \n. But the next thing we want
- * to do is match the \n against the \n; if we restored the
- * string value, we would be back at the foo.
- *
- * Because this is used only in specific cases, we don't need to
- * check all the things that `on_failure_jump' does, to make
- * sure the right things get saved on the stack. Hence we don't
- * share its code. The only reason to push anything on the
- * stack at all is that otherwise we would have to change
- * `anychar's code to do something besides goto fail in this
- * case; that seems worse than this. */
+ /* on_failure_keep_string_jump is used to optimize `.*\n'. It
+ * pushes NULL as the value for the string on the stack. Then
+ * `pop_failure_point' will keep the current value for the
+ * string, instead of restoring it. To see why, consider
+ * matching `foo\nbar' against `.*\n'. The .* matches the foo;
+ * then the . fails against the \n. But the next thing we want
+ * to do is match the \n against the \n; if we restored the
+ * string value, we would be back at the foo.
+ *
+ * Because this is used only in specific cases, we don't need to
+ * check all the things that `on_failure_jump' does, to make
+ * sure the right things get saved on the stack. Hence we don't
+ * share its code. The only reason to push anything on the
+ * stack at all is that otherwise we would have to change
+ * `anychar's code to do something besides goto fail in this
+ * case; that seems worse than this. */
case on_failure_keep_string_jump:
DEBUG_PRINT1("EXECUTING on_failure_keep_string_jump");
PUSH_FAILURE_POINT(p + mcnt, NULL, -2);
break;
- /* Uses of on_failure_jump:
- *
- * Each alternative starts with an on_failure_jump that points
- * to the beginning of the next alternative. Each alternative
- * except the last ends with a jump that in effect jumps past
- * the rest of the alternatives. (They really jump to the
- * ending jump of the following alternative, because tensioning
- * these jumps is a hassle.)
- *
- * Repeats start with an on_failure_jump that points past both
- * the repetition text and either the following jump or
- * pop_failure_jump back to this on_failure_jump. */
+ /* Uses of on_failure_jump:
+ *
+ * Each alternative starts with an on_failure_jump that points
+ * to the beginning of the next alternative. Each alternative
+ * except the last ends with a jump that in effect jumps past
+ * the rest of the alternatives. (They really jump to the
+ * ending jump of the following alternative, because tensioning
+ * these jumps is a hassle.)
+ *
+ * Repeats start with an on_failure_jump that points past both
+ * the repetition text and either the following jump or
+ * pop_failure_jump back to this on_failure_jump. */
case on_failure_jump:
on_failure:
DEBUG_PRINT1("EXECUTING on_failure_jump");
PUSH_FAILURE_POINT(p + mcnt, d, -2);
break;
- /* A smart repeat ends with `maybe_pop_jump'.
- * We change it to either `pop_failure_jump' or `jump'. */
+ /* A smart repeat ends with `maybe_pop_jump'.
+ * We change it to either `pop_failure_jump' or `jump'. */
case maybe_pop_jump:
EXTRACT_NUMBER_AND_INCR(mcnt, p);
DEBUG_PRINT2("EXECUTING maybe_pop_jump %d.\n", mcnt);
while (p2 + 2 < pend
&& ((re_opcode_t) * p2 == stop_memory
|| (re_opcode_t) * p2 == start_memory))
- p2 += 3; /* Skip over args, too. */
+ p2 += 3; /* Skip over args, too. */
/* If we're at the end of the pattern, we can change. */
if (p2 == pend) {
} else if ((re_opcode_t) * p2 == exactn
|| (bufp->newline_anchor && (re_opcode_t) * p2 == endline)) {
register unsigned char c
- = *p2 == (unsigned char) endline ? '\n' : p2[2];
+ = *p2 == (unsigned char) endline ? '\n' : p2[2];
p1 = p + mcnt;
/* p1[0] ... p1[2] are the `on_failure_jump' corresponding
}
}
}
- p -= 2; /* Point at relative address again. */
+ p -= 2; /* Point at relative address again. */
if ((re_opcode_t) p[-1] != pop_failure_jump) {
p[-1] = (unsigned char) jump;
DEBUG_PRINT1(" Match => jump.\n");
goto unconditional_jump;
}
- /* Note fall through. */
-
- /* The end of a simple repeat has a pop_failure_jump back to
- * its matching on_failure_jump, where the latter will push a
- * failure point. The pop_failure_jump takes off failure
- * points put on by this pop_failure_jump's matching
- * on_failure_jump; we got through the pattern to here from the
- * matching on_failure_jump, so didn't fail. */
+ /* Note fall through. */
+
+ /* The end of a simple repeat has a pop_failure_jump back to
+ * its matching on_failure_jump, where the latter will push a
+ * failure point. The pop_failure_jump takes off failure
+ * points put on by this pop_failure_jump's matching
+ * on_failure_jump; we got through the pattern to here from the
+ * matching on_failure_jump, so didn't fail. */
case pop_failure_jump: {
/* We need to pass separate storage for the lowest and
* highest registers, even though we don't care about the
/* Unconditionally jump (without popping any failure points). */
case jump:
unconditional_jump:
- EXTRACT_NUMBER_AND_INCR(mcnt, p); /* Get the amount to jump. */
+ EXTRACT_NUMBER_AND_INCR(mcnt, p); /* Get the amount to jump. */
DEBUG_PRINT2("EXECUTING jump %d ", mcnt);
- p += mcnt; /* Do the jump. */
+ p += mcnt; /* Do the jump. */
DEBUG_PRINT2("(to 0x%x).\n", p);
break;
- /* We need this opcode so we can detect where alternatives end
- * in `group_match_null_string_p' et al. */
+ /* We need this opcode so we can detect where alternatives end
+ * in `group_match_null_string_p' et al. */
case jump_past_alt:
DEBUG_PRINT1("EXECUTING jump_past_alt.\n");
goto unconditional_jump;
- /* Normally, the on_failure_jump pushes a failure point, which
- * then gets popped at pop_failure_jump. We will end up at
- * pop_failure_jump, also, and with a pattern of, say, `a+', we
- * are skipping over the on_failure_jump, so we have to push
- * something meaningless for pop_failure_jump to pop. */
+ /* Normally, the on_failure_jump pushes a failure point, which
+ * then gets popped at pop_failure_jump. We will end up at
+ * pop_failure_jump, also, and with a pattern of, say, `a+', we
+ * are skipping over the on_failure_jump, so we have to push
+ * something meaningless for pop_failure_jump to pop. */
case dummy_failure_jump:
DEBUG_PRINT1("EXECUTING dummy_failure_jump.\n");
/* It doesn't matter what we push for the string here. What
PUSH_FAILURE_POINT(0, 0, -2);
goto unconditional_jump;
- /* At the end of an alternative, we need to push a dummy failure
- * point in case we are followed by a `pop_failure_jump', because
- * we don't want the failure point for the alternative to be
- * popped. For example, matching `(a|ab)*' against `aab'
- * requires that we match the `ab' alternative. */
+ /* At the end of an alternative, we need to push a dummy failure
+ * point in case we are followed by a `pop_failure_jump', because
+ * we don't want the failure point for the alternative to be
+ * popped. For example, matching `(a|ab)*' against `aab'
+ * requires that we match the `ab' alternative. */
case push_dummy_failure:
DEBUG_PRINT1("EXECUTING push_dummy_failure.\n");
/* See comments just above at `dummy_failure_jump' about the
PUSH_FAILURE_POINT(0, 0, -2);
break;
- /* Have to succeed matching what follows at least n times.
- * After that, handle like `on_failure_jump'. */
+ /* Have to succeed matching what follows at least n times.
+ * After that, handle like `on_failure_jump'. */
case succeed_n:
EXTRACT_NUMBER(mcnt, p + 2);
DEBUG_PRINT2("EXECUTING succeed_n %d.\n", mcnt);
default:
abort();
}
- continue; /* Successfully executed one pattern command; keep going. */
+ continue; /* Successfully executed one pattern command; keep going. */
/* We goto here if a matching operation fails. */
fail:
- if (!FAIL_STACK_EMPTY()) { /* A restart point is known. Restore to that state. */
+ if (!FAIL_STACK_EMPTY()) { /* A restart point is known. Restore to that state. */
DEBUG_PRINT1("\nFAIL:\n");
POP_FAILURE_POINT(d, p,
lowest_active_reg, highest_active_reg,
if (d >= string1 && d <= end1)
dend = end_match_1;
} else
- break; /* Matching at this starting point really fails. */
- } /* for (;;) */
+ break; /* Matching at this starting point really fails. */
+ } /* for (;;) */
if (best_regs_set)
goto restore_best_regs;
FREE_VARIABLES();
- return -1; /* Failure to match. */
-} /* re_match_2 */
+ return -1; /* Failure to match. */
+} /* re_match_2 */
\f
/* Subroutine definitions for re_match_2. */
* matching stop_memory. */
switch ((re_opcode_t) * p1) {
- /* Could be either a loop or a series of alternatives. */
+ /* Could be either a loop or a series of alternatives. */
case on_failure_jump:
p1++;
EXTRACT_NUMBER_AND_INCR(mcnt, p1);
if (!alt_match_null_string_p(p1, p1 + mcnt, reg_info))
return false;
- p1 += mcnt; /* Get past the n-th alternative. */
- } /* if mcnt > 0 */
+ p1 += mcnt; /* Get past the n-th alternative. */
+ } /* if mcnt > 0 */
break;
case stop_memory:
if (!common_op_match_null_string_p(&p1, end, reg_info))
return false;
}
- } /* while p1 < end */
+ } /* while p1 < end */
return false;
-} /* group_match_null_string_p */
+} /* group_match_null_string_p */
/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
* It expects P to be the first byte of a single alternative and END one
* to one that can't. */
switch ((re_opcode_t) * p1) {
- /* It's a loop. */
+ /* It's a loop. */
case on_failure_jump:
p1++;
EXTRACT_NUMBER_AND_INCR(mcnt, p1);
if (!common_op_match_null_string_p(&p1, end, reg_info))
return false;
}
- } /* while p1 < end */
+ } /* while p1 < end */
return true;
-} /* alt_match_null_string_p */
+} /* alt_match_null_string_p */
/* Deals with the ops common to group_match_null_string_p and
* alt_match_null_string_p.
return false;
break;
- /* If this is an optimized succeed_n for zero times, make the jump. */
+ /* If this is an optimized succeed_n for zero times, make the jump. */
case jump:
EXTRACT_NUMBER_AND_INCR(mcnt, p1);
if (mcnt >= 0)
*p = p1;
return true;
-} /* common_op_match_null_string_p */
+} /* common_op_match_null_string_p */
/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
* bytes; nonzero otherwise. */
{
reg_errcode_t ret;
unsigned syntax
- = (cflags & REG_EXTENDED) ?
- RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
+ = (cflags & REG_EXTENDED) ?
+ RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
/* regex_compile will allocate the space for the compiled pattern. */
preg->buffer = 0;
preg->translate = NULL;
/* If REG_NEWLINE is set, newlines are treated differently. */
- if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */
+ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */
syntax &= ~RE_DOT_NEWLINE;
syntax |= RE_HAT_LISTS_NOT_NEWLINE;
/* It also changes the matching behavior. */
if (!msg)
msg = "Success";
- msg_size = strlen(msg) + 1; /* Includes the null. */
+ msg_size = strlen(msg) + 1; /* Includes the null. */
if (errbuf_size != 0) {
if (msg_size > errbuf_size) {
* trim-versions-without-asking: nil
* End:
*/
+
extern "C" {
#endif
- /* Definitions for data structures and routines for the regular
- * expression library, version 0.12.
- *
- * Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
- *
- * 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
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */
-
- /* POSIX says that <sys/types.h> must be included (by the caller) before
- * <regex.h>. */
-
- /* The following bits are used to determine the regexp syntax we
- * recognize. The set/not-set meanings are chosen so that Emacs syntax
- * remains the value 0. The bits are given in alphabetical order, and
- * the definitions shifted by one from the previous bit; thus, when we
- * add or remove a bit, only one other definition need change. */
- typedef unsigned reg_syntax_t;
-
- /* If this bit is not set, then \ inside a bracket expression is literal.
- * If set, then such a \ quotes the following character. */
+/* Definitions for data structures and routines for the regular
+ * expression library, version 0.12.
+ *
+ * Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+ *
+ * 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
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */
+
+/* POSIX says that <sys/types.h> must be included (by the caller) before
+ * <regex.h>. */
+
+/* The following bits are used to determine the regexp syntax we
+ * recognize. The set/not-set meanings are chosen so that Emacs syntax
+ * remains the value 0. The bits are given in alphabetical order, and
+ * the definitions shifted by one from the previous bit; thus, when we
+ * add or remove a bit, only one other definition need change. */
+typedef unsigned reg_syntax_t;
+
+/* If this bit is not set, then \ inside a bracket expression is literal.
+ * If set, then such a \ quotes the following character. */
#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
- /* If this bit is not set, then + and ? are operators, and \+ and \? are
- * literals.
- * If set, then \+ and \? are operators and + and ? are literals. */
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+ * literals.
+ * If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
- /* If this bit is set, then character classes are supported. They are:
- * [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- * [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- * If not set, then character classes are not supported. */
+/* If this bit is set, then character classes are supported. They are:
+ * [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
+ * [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+ * If not set, then character classes are not supported. */
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
- /* If this bit is set, then ^ and $ are always anchors (outside bracket
- * expressions, of course).
- * If this bit is not set, then it depends:
- * ^ is an anchor if it is at the beginning of a regular
- * expression or after an open-group or an alternation operator;
- * $ is an anchor if it is at the end of a regular expression, or
- * before a close-group or an alternation operator.
- *
- * This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
- * POSIX draft 11.2 says that * etc. in leading positions is undefined.
- * We already implemented a previous draft which made those constructs
- * invalid, though, so we haven't changed the code back. */
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+ * expressions, of course).
+ * If this bit is not set, then it depends:
+ * ^ is an anchor if it is at the beginning of a regular
+ * expression or after an open-group or an alternation operator;
+ * $ is an anchor if it is at the end of a regular expression, or
+ * before a close-group or an alternation operator.
+ *
+ * This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+ * POSIX draft 11.2 says that * etc. in leading positions is undefined.
+ * We already implemented a previous draft which made those constructs
+ * invalid, though, so we haven't changed the code back. */
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
- /* If this bit is set, then special characters are always special
- * regardless of where they are in the pattern.
- * If this bit is not set, then special characters are special only in
- * some contexts; otherwise they are ordinary. Specifically,
- * * + ? and intervals are only special when not after the beginning,
- * open-group, or alternation operator. */
+/* If this bit is set, then special characters are always special
+ * regardless of where they are in the pattern.
+ * If this bit is not set, then special characters are special only in
+ * some contexts; otherwise they are ordinary. Specifically,
+ * * + ? and intervals are only special when not after the beginning,
+ * open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
- /* If this bit is set, then *, +, ?, and { cannot be first in an re or
- * immediately after an alternation or begin-group operator. */
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+ * immediately after an alternation or begin-group operator. */
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
- /* If this bit is set, then . matches newline.
- * If not set, then it doesn't. */
+/* If this bit is set, then . matches newline.
+ * If not set, then it doesn't. */
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
- /* If this bit is set, then . doesn't match NUL.
- * If not set, then it does. */
+/* If this bit is set, then . doesn't match NUL.
+ * If not set, then it does. */
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
- /* If this bit is set, nonmatching lists [^...] do not match newline.
- * If not set, they do. */
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+ * If not set, they do. */
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
- /* If this bit is set, either \{...\} or {...} defines an
- * interval, depending on RE_NO_BK_BRACES.
- * If not set, \{, \}, {, and } are literals. */
+/* If this bit is set, either \{...\} or {...} defines an
+ * interval, depending on RE_NO_BK_BRACES.
+ * If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
- /* If this bit is set, +, ? and | aren't recognized as operators.
- * If not set, they are. */
+/* If this bit is set, +, ? and | aren't recognized as operators.
+ * If not set, they are. */
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
- /* If this bit is set, newline is an alternation operator.
- * If not set, newline is literal. */
+/* If this bit is set, newline is an alternation operator.
+ * If not set, newline is literal. */
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
- /* If this bit is set, then `{...}' defines an interval, and \{ and \}
- * are literals.
- * If not set, then `\{...\}' defines an interval. */
+/* If this bit is set, then `{...}' defines an interval, and \{ and \}
+ * are literals.
+ * If not set, then `\{...\}' defines an interval. */
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
- /* If this bit is set, (...) defines a group, and \( and \) are literals.
- * If not set, \(...\) defines a group, and ( and ) are literals. */
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+ * If not set, \(...\) defines a group, and ( and ) are literals. */
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
- /* If this bit is set, then \<digit> matches <digit>.
- * If not set, then \<digit> is a back-reference. */
+/* If this bit is set, then \<digit> matches <digit>.
+ * If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
- /* If this bit is set, then | is an alternation operator, and \| is literal.
- * If not set, then \| is an alternation operator, and | is literal. */
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+ * If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
- /* If this bit is set, then an ending range point collating higher
- * than the starting range point, as in [z-a], is invalid.
- * If not set, then when ending range point collates higher than the
- * starting range point, the range is ignored. */
+/* If this bit is set, then an ending range point collating higher
+ * than the starting range point, as in [z-a], is invalid.
+ * If not set, then when ending range point collates higher than the
+ * starting range point, the range is ignored. */
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
- /* If this bit is set, then an unmatched ) is ordinary.
- * If not set, then an unmatched ) is invalid. */
+/* If this bit is set, then an unmatched ) is ordinary.
+ * If not set, then an unmatched ) is invalid. */
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
- /* Define combinations of the above bits for the standard possibilities.
- * (The [[[ comments delimit what gets put into the Texinfo file, so
- * don't delete them!) */
- /* [[[begin syntaxes]]] */
+/* Define combinations of the above bits for the standard possibilities.
+ * (The [[[ comments delimit what gets put into the Texinfo file, so
+ * don't delete them!) */
+/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
-#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
+#define RE_SYNTAX_AWK \
+ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
-#define RE_SYNTAX_POSIX_AWK \
+#define RE_SYNTAX_POSIX_AWK \
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-#define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
+#define RE_SYNTAX_GREP \
+ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
+ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
| RE_NEWLINE_ALT)
-#define RE_SYNTAX_EGREP \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
+#define RE_SYNTAX_EGREP \
+ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
+ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
| RE_NO_BK_VBAR)
-#define RE_SYNTAX_POSIX_EGREP \
+#define RE_SYNTAX_POSIX_EGREP \
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
- /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
- /* Syntax bits common to both basic and extended POSIX regex syntax. */
-#define _RE_SYNTAX_POSIX_COMMON \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
+/* Syntax bits common to both basic and extended POSIX regex syntax. */
+#define _RE_SYNTAX_POSIX_COMMON \
+ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
-#define RE_SYNTAX_POSIX_BASIC \
+#define RE_SYNTAX_POSIX_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
- /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
- * RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
- * isn't minimal, since other operators, such as \`, aren't disabled. */
-#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+ * RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
+ * isn't minimal, since other operators, such as \`, aren't disabled. */
+#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
-#define RE_SYNTAX_POSIX_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+#define RE_SYNTAX_POSIX_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
- /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
- * replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
-#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
- /* [[[end syntaxes]]] */
- \f
- /* Maximum number of duplicates an interval can allow. Some systems
- * (erroneously) define this in other header files, but we want our
- * value, so remove any previous define. */
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
+ * replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
+#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+\f
+/* Maximum number of duplicates an interval can allow. Some systems
+ * (erroneously) define this in other header files, but we want our
+ * value, so remove any previous define. */
#ifdef RE_DUP_MAX
#undef RE_DUP_MAX
#endif
#define RE_DUP_MAX ((1 << 15) - 1)
- /* POSIX `cflags' bits (i.e., information for `regcomp'). */
+/* POSIX `cflags' bits (i.e., information for `regcomp'). */
- /* If this bit is set, then use extended regular expression syntax.
- * If not set, then use basic regular expression syntax. */
+/* If this bit is set, then use extended regular expression syntax.
+ * If not set, then use basic regular expression syntax. */
#define REG_EXTENDED 1
- /* If this bit is set, then ignore case when matching.
- * If not set, then case is significant. */
+/* If this bit is set, then ignore case when matching.
+ * If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
- /* If this bit is set, then anchors do not match at newline
- * characters in the string.
- * If not set, then anchors do match at newlines. */
+/* If this bit is set, then anchors do not match at newline
+ * characters in the string.
+ * If not set, then anchors do match at newlines. */
#define REG_NEWLINE (REG_ICASE << 1)
- /* If this bit is set, then report only success or fail in regexec.
- * If not set, then returns differ between not matching and errors. */
+/* If this bit is set, then report only success or fail in regexec.
+ * If not set, then returns differ between not matching and errors. */
#define REG_NOSUB (REG_NEWLINE << 1)
- /* POSIX `eflags' bits (i.e., information for regexec). */
+/* POSIX `eflags' bits (i.e., information for regexec). */
- /* If this bit is set, then the beginning-of-line operator doesn't match
- * the beginning of the string (presumably because it's not the
- * beginning of a line).
- * If not set, then the beginning-of-line operator does match the
- * beginning of the string. */
+/* If this bit is set, then the beginning-of-line operator doesn't match
+ * the beginning of the string (presumably because it's not the
+ * beginning of a line).
+ * If not set, then the beginning-of-line operator does match the
+ * beginning of the string. */
#define REG_NOTBOL 1
- /* Like REG_NOTBOL, except for the end-of-line. */
+/* Like REG_NOTBOL, except for the end-of-line. */
#define REG_NOTEOL (1 << 1)
- /* If any error codes are removed, changed, or added, update the
- * `re_error_msg' table in regex.c. */
- typedef enum {
- REG_NOERROR = 0, /* Success. */
- REG_NOMATCH, /* Didn't find a match (for regexec). */
-
- /* POSIX regcomp return error codes. (In the order listed in the
- * standard.) */
- REG_BADPAT, /* Invalid pattern. */
- REG_ECOLLATE, /* Not implemented. */
- REG_ECTYPE, /* Invalid character class name. */
- REG_EESCAPE, /* Trailing backslash. */
- REG_ESUBREG, /* Invalid back reference. */
- REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
- REG_EBRACE, /* Unmatched \{. */
- REG_BADBR, /* Invalid contents of \{\}. */
- REG_ERANGE, /* Invalid range end. */
- REG_ESPACE, /* Ran out of memory. */
- REG_BADRPT, /* No preceding re for repetition op. */
-
- /* Error codes we've added. */
- REG_EEND, /* Premature end. */
- REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
- REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
- } reg_errcode_t;
- \f
- /* This data structure represents a compiled pattern. Before calling
- * the pattern compiler, the fields `buffer', `allocated', `fastmap',
- * `translate', and `no_sub' can be set. After the pattern has been
- * compiled, the `re_nsub' field is available. All other fields are
- * private to the regex routines. */
-
- struct re_pattern_buffer {
- /* [[[begin pattern_buffer]]] */
- /* Space that holds the compiled pattern. It is declared as
- * `unsigned char *' because its elements are
- * sometimes used as array indexes. */
- unsigned char *buffer;
-
- /* Number of bytes to which `buffer' points. */
- unsigned long allocated;
-
- /* Number of bytes actually used in `buffer'. */
- unsigned long used;
-
- /* Syntax setting with which the pattern was compiled. */
- reg_syntax_t syntax;
-
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses
- * the fastmap, if there is one, to skip over impossible
- * starting points for matches. */
- char *fastmap;
-
- /* Either a translate table to apply to all characters before
- * comparing them, or zero for no translation. The translation
- * is applied to a pattern when it is compiled and to a string
- * when it is matched. */
- char *translate;
-
- /* Number of subexpressions found by the compiler. */
- size_t re_nsub;
-
- /* Zero if this pattern cannot match the empty string, one else.
- * Well, in truth it's used only in `re_search_2', to see
- * whether or not we should use the fastmap, so we don't set
- * this absolutely perfectly; see `re_compile_fastmap' (the
- * `duplicate' case). */
- unsigned can_be_null:1;
-
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- * for `max (RE_NREGS, re_nsub + 1)' groups.
- * If REGS_REALLOCATE, reallocate space if necessary.
- * If REGS_FIXED, use what's there. */
+/* If any error codes are removed, changed, or added, update the
+ * `re_error_msg' table in regex.c. */
+typedef enum {
+ REG_NOERROR = 0, /* Success. */
+ REG_NOMATCH, /* Didn't find a match (for regexec). */
+
+ /* POSIX regcomp return error codes. (In the order listed in the
+ * standard.) */
+ REG_BADPAT, /* Invalid pattern. */
+ REG_ECOLLATE, /* Not implemented. */
+ REG_ECTYPE, /* Invalid character class name. */
+ REG_EESCAPE, /* Trailing backslash. */
+ REG_ESUBREG, /* Invalid back reference. */
+ REG_EBRACK, /* Unmatched left bracket. */
+ REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EBRACE, /* Unmatched \{. */
+ REG_BADBR, /* Invalid contents of \{\}. */
+ REG_ERANGE, /* Invalid range end. */
+ REG_ESPACE, /* Ran out of memory. */
+ REG_BADRPT, /* No preceding re for repetition op. */
+
+ /* Error codes we've added. */
+ REG_EEND, /* Premature end. */
+ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
+ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
+} reg_errcode_t;
+\f
+/* This data structure represents a compiled pattern. Before calling
+ * the pattern compiler, the fields `buffer', `allocated', `fastmap',
+ * `translate', and `no_sub' can be set. After the pattern has been
+ * compiled, the `re_nsub' field is available. All other fields are
+ * private to the regex routines. */
+
+struct re_pattern_buffer {
+ /* [[[begin pattern_buffer]]] */
+ /* Space that holds the compiled pattern. It is declared as
+ * `unsigned char *' because its elements are
+ * sometimes used as array indexes. */
+ unsigned char *buffer;
+
+ /* Number of bytes to which `buffer' points. */
+ unsigned long allocated;
+
+ /* Number of bytes actually used in `buffer'. */
+ unsigned long used;
+
+ /* Syntax setting with which the pattern was compiled. */
+ reg_syntax_t syntax;
+
+ /* Pointer to a fastmap, if any, otherwise zero. re_search uses
+ * the fastmap, if there is one, to skip over impossible
+ * starting points for matches. */
+ char *fastmap;
+
+ /* Either a translate table to apply to all characters before
+ * comparing them, or zero for no translation. The translation
+ * is applied to a pattern when it is compiled and to a string
+ * when it is matched. */
+ char *translate;
+
+ /* Number of subexpressions found by the compiler. */
+ size_t re_nsub;
+
+ /* Zero if this pattern cannot match the empty string, one else.
+ * Well, in truth it's used only in `re_search_2', to see
+ * whether or not we should use the fastmap, so we don't set
+ * this absolutely perfectly; see `re_compile_fastmap' (the
+ * `duplicate' case). */
+ unsigned can_be_null:1;
+
+ /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+ * for `max (RE_NREGS, re_nsub + 1)' groups.
+ * If REGS_REALLOCATE, reallocate space if necessary.
+ * If REGS_FIXED, use what's there. */
#define REGS_UNALLOCATED 0
#define REGS_REALLOCATE 1
#define REGS_FIXED 2
- unsigned regs_allocated:2;
+ unsigned regs_allocated:2;
- /* Set to zero when `regex_compile' compiles a pattern; set to one
- * by `re_compile_fastmap' if it updates the fastmap. */
- unsigned fastmap_accurate:1;
+ /* Set to zero when `regex_compile' compiles a pattern; set to one
+ * by `re_compile_fastmap' if it updates the fastmap. */
+ unsigned fastmap_accurate:1;
- /* If set, `re_match_2' does not return information about
- * subexpressions. */
- unsigned no_sub:1;
+ /* If set, `re_match_2' does not return information about
+ * subexpressions. */
+ unsigned no_sub:1;
- /* If set, a beginning-of-line anchor doesn't match at the
- * beginning of the string. */
- unsigned not_bol:1;
+ /* If set, a beginning-of-line anchor doesn't match at the
+ * beginning of the string. */
+ unsigned not_bol:1;
- /* Similarly for an end-of-line anchor. */
- unsigned not_eol:1;
+ /* Similarly for an end-of-line anchor. */
+ unsigned not_eol:1;
- /* If true, an anchor at a newline matches. */
- unsigned newline_anchor:1;
+ /* If true, an anchor at a newline matches. */
+ unsigned newline_anchor:1;
- /* [[[end pattern_buffer]]] */
- };
+ /* [[[end pattern_buffer]]] */
+};
- typedef struct re_pattern_buffer regex_t;
+typedef struct re_pattern_buffer regex_t;
- /* search.c (search_buffer) in Emacs needs this one opcode value. It is
- * defined both in `regex.c' and here. */
+/* search.c (search_buffer) in Emacs needs this one opcode value. It is
+ * defined both in `regex.c' and here. */
#define RE_EXACTN_VALUE 1
- \f
- /* Type for byte offsets within the string. POSIX mandates this. */
- typedef int regoff_t;
-
- /* This is the structure we store register match data in. See
- * regex.texinfo for a full description of what registers match. */
- struct re_registers {
- unsigned num_regs;
- regoff_t *start;
- regoff_t *end;
- };
-
- /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
- * `re_match_2' returns information about at least this many registers
- * the first time a `regs' structure is passed. */
+\f
+/* Type for byte offsets within the string. POSIX mandates this. */
+typedef int regoff_t;
+
+/* This is the structure we store register match data in. See
+ * regex.texinfo for a full description of what registers match. */
+struct re_registers {
+ unsigned num_regs;
+ regoff_t *start;
+ regoff_t *end;
+};
+
+/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+ * `re_match_2' returns information about at least this many registers
+ * the first time a `regs' structure is passed. */
#ifndef RE_NREGS
#define RE_NREGS 30
#endif
- /* POSIX specification for registers. Aside from the different names than
- * `re_registers', POSIX uses an array of structures, instead of a
- * structure of arrays. */
- typedef struct {
- regoff_t rm_so; /* Byte offset from string's start to substring's start. */
- regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
- } regmatch_t;
- \f
- /* Declarations for routines. */
-
- /* To avoid duplicating every routine declaration -- once with a
- * prototype (if we are ANSI), and once without (if we aren't) -- we
- * use the following macro to declare argument types. This
- * unfortunately clutters up the declarations a bit, but I think it's
- * worth it. */
-
- /* POSIX compatibility. */
- extern int regcomp(regex_t * preg, const char *pattern, int cflags);
- extern int regexec(const regex_t * preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
- extern size_t regerror(int errcode, const regex_t * preg, char *errbuf, size_t errbuf_size);
- extern void regfree(regex_t * preg);
+/* POSIX specification for registers. Aside from the different names than
+ * `re_registers', POSIX uses an array of structures, instead of a
+ * structure of arrays. */
+typedef struct {
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+\f
+/* Declarations for routines. */
+
+/* To avoid duplicating every routine declaration -- once with a
+ * prototype (if we are ANSI), and once without (if we aren't) -- we
+ * use the following macro to declare argument types. This
+ * unfortunately clutters up the declarations a bit, but I think it's
+ * worth it. */
+
+/* POSIX compatibility. */
+extern int regcomp(regex_t * preg, const char *pattern, int cflags);
+extern int regexec(const regex_t * preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
+extern size_t regerror(int errcode, const regex_t * preg, char *errbuf, size_t errbuf_size);
+extern void regfree(regex_t * preg);
#ifdef __cplusplus
}
* trim-versions-without-asking: nil
* End:
*/
+
fprintf(stderr, "assertion failed: %s:%d: \"%s\"\n", file, line, expr);
abort();
}
+
xassert(const char *, const char *, int);
#endif /* SQUID_ASSERT_H */
+
#endif
#endif /* SQUID_COMPAT_CMSG_H */
+
#include "compat.h"
void (*failure_notify) (const char *) = NULL;
+
#include "compat/cppunit.h"
#endif /* _SQUID_COMPAT_H */
+
#endif
#endif /* _SQUID_COMPAT_SHARED_H */
+
#endif /* HAVE_UNIQUE_PTR */
#endif /* HAVE_CPPUNIT_EXTENSIONS_HELPERMACROS_H */
#endif /* SQUID_COMPAT_CPPUNIT_H */
+
#endif /* HAVE_CPU_AFFINITY */
#endif /* SQUID_COMPAT_CPU_H */
+
}
#endif /* __GNUC__ */
+
#endif
#endif /* COMPAT_DEBUG_H */
+
#if !HAVE_DRAND48
-#define N 16
-#define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1)
-#define LOW(x) ((unsigned)(x) & MASK)
-#define HIGH(x) LOW((x) >> N)
-#define MUL(x, y, z) { long l = (long)(x) * (long)(y); \
- (z)[0] = LOW(l); (z)[1] = HIGH(l); }
-#define CARRY(x, y) ((long)(x) + (long)(y) > MASK)
-#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y)))
-#define X0 0x330E
-#define X1 0xABCD
-#define X2 0x1234
-#define A0 0xE66D
-#define A1 0xDEEC
-#define A2 0x5
-#define C 0xB
+#define N 16
+#define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1)
+#define LOW(x) ((unsigned)(x) & MASK)
+#define HIGH(x) LOW((x) >> N)
+#define MUL(x, y, z) { long l = (long)(x) * (long)(y); \
+ (z)[0] = LOW(l); (z)[1] = HIGH(l); }
+#define CARRY(x, y) ((long)(x) + (long)(y) > MASK)
+#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y)))
+#define X0 0x330E
+#define X1 0xABCD
+#define X2 0x1234
+#define A0 0xE66D
+#define A1 0xDEEC
+#define A2 0x5
+#define C 0xB
static void next(void);
static unsigned x[3] = {X0, X1, X2}, a[3] = {A0, A1, A2}, c = C;
}
#endif /* HAVE_DRAND48 */
+
}
#endif /* !SQUID_EUI64_ATON */
+
#define SQUID_EUI64_ATON 1
- /**
- * 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 {
- uint8_t octet[EUI64_LEN];
- };
+/**
+ * Structure of an IEEE EUI-64.
+ */
+struct eui64 {
+ uint8_t octet[EUI64_LEN];
+};
- int eui64_aton(const char *a, struct eui64 *e);
+int eui64_aton(const char *a, struct eui64 *e);
#if defined(__cplusplus)
}
#endif
#endif /* !_SYS_EUI64_H */
#endif /* HAVE_SYS_EUI64_H */
#endif /* SQUID_COMPAT_EUI64_ATON_H */
+
/* FD_SETSIZE must be redefined before including sys/types.h */
#if 0
/* AYJ: would dearly like to use this to enforce include order
- but at present some helpers don't follow the squid include methodology.
- that will need fixing later.
+ but at present some helpers don't follow the squid include methodology.
+ that will need fixing later.
*/
#ifdef _SYS_TYPES_H
#error squid_fdsetsize.h for FDSETSIZE must be included before sys/types.h
#endif
#endif /* SQUID_FDSETSIZE_H */
+
* Update/Maintenance History:
*
* 15-Aug-2007 : Copied from fetchmail 6.3.8
- * - added protection around libray headers
+ * - added protection around libray headers
*
* 16-Aug-2007 : Altered configure checks
* Un-hacked slightly to use system gethostbyname()
{
static const char *eai_descr[] = {
"no error",
- "address family for nodename not supported", /* EAI_ADDRFAMILY */
- "temporary failure in name resolution", /* EAI_AGAIN */
- "invalid value for ai_flags", /* EAI_BADFLAGS */
- "non-recoverable failure in name resolution", /* EAI_FAIL */
- "ai_family not supported", /* EAI_FAMILY */
- "memory allocation failure", /* EAI_MEMORY */
- "no address associated with nodename", /* EAI_NODATA */
- "nodename nor servname provided, or not known", /* EAI_NONAME */
- "servname not supported for ai_socktype", /* EAI_SERVICE */
- "ai_socktype not supported", /* EAI_SOCKTYPE */
- "system error returned in errno", /* EAI_SYSTEM */
- "argument buffer overflow", /* EAI_OVERFLOW */
+ "address family for nodename not supported", /* EAI_ADDRFAMILY */
+ "temporary failure in name resolution", /* EAI_AGAIN */
+ "invalid value for ai_flags", /* EAI_BADFLAGS */
+ "non-recoverable failure in name resolution", /* EAI_FAIL */
+ "ai_family not supported", /* EAI_FAMILY */
+ "memory allocation failure", /* EAI_MEMORY */
+ "no address associated with nodename", /* EAI_NODATA */
+ "nodename nor servname provided, or not known", /* EAI_NONAME */
+ "servname not supported for ai_socktype", /* EAI_SERVICE */
+ "ai_socktype not supported", /* EAI_SOCKTYPE */
+ "system error returned in errno", /* EAI_SYSTEM */
+ "argument buffer overflow", /* EAI_OVERFLOW */
};
if (ecode < 0 || ecode > (int) (sizeof eai_descr/ sizeof eai_descr[0]))
}
#endif /* HAVE_GETADDRINFO */
+
* Update/Maintenance History:
*
* 15-Aug-2007 : Copied from fetchmail 6.3.8
- * - added protection around libray headers
+ * - added protection around libray headers
*
* 16-Aug-2007 : Altered configure checks
* Un-hacked slightly to use system gethostbyname()
this could be needed on some other platform */
#if 0
struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- socklen_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for nodename */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ socklen_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for nodename */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
};
/* Supposed to be defined in <netdb.h> */
/* RFC 2553 / Posix resolver */
SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res);
-#define getaddrinfo xgetaddrinfo
+#define getaddrinfo xgetaddrinfo
/* Free addrinfo structure and associated storage */
SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai);
-#define freeaddrinfo xfreeaddrinfo
+#define freeaddrinfo xfreeaddrinfo
/* Convert error return from getaddrinfo() to string */
SQUIDCEXTERN const char *xgai_strerror (int code);
#if !defined(gai_strerror)
-#define gai_strerror xgai_strerror
+#define gai_strerror xgai_strerror
#endif
#endif /* HAVE_GETADDRINFO */
#endif /* _getaddrinfo_h */
+
*/
#include "squid.h"
-/* KAME: getnameinfo.c,v 1.72 2005/01/13 04:12:03 itojun Exp */
+/* KAME: getnameinfo.c,v 1.72 2005/01/13 04:12:03 itojun Exp */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
int a_portoff;
} afdl [] = {
#if INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
+ { PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr),
- offsetof(struct sockaddr_in6, sin6_port)},
+ offsetof(struct sockaddr_in6, sin6_port)
+ },
#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr),
- offsetof(struct sockaddr_in, sin_port)},
+ { PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
+ offsetof(struct sockaddr_in, sin_addr),
+ offsetof(struct sockaddr_in, sin_port)
+ },
{0, 0, 0, 0, 0},
};
if (sa == NULL)
return EAI_FAIL;
-#if HAVE_SA_LEN /*XXX*/
+#if HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return EAI_FAIL;
#endif
}
#endif /* INET6 */
#endif
+
char *serv,
size_t servlen,
int flags );
-#define getnameinfo xgetnameinfo
+#define getnameinfo xgetnameinfo
#endif /* HAVE_GETNAMEINFO */
#endif /* _getnameinfo_h */
+
* Update/Maintenance History:
*
* 24-Sep-2007 : Copied from bind 9.3.3
- * - Added protection around libray headers
- * - Altered configure checks
- * - Un-hacked slightly to use system gethostbyname()
+ * - Added protection around libray headers
+ * - Altered configure checks
+ * - Un-hacked slightly to use system gethostbyname()
*
* 06-Oct-2007 : Various fixes to allow the build on MinGW
*
/* char *
* inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
+ * convert a network format address to presentation format.
* return:
- * pointer to presentation format address (`dst'), or NULL (see errno).
+ * pointer to presentation format address (`dst'), or NULL (see errno).
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
const char *
xinet_ntop(af, src, dst, size)
/* const char *
* inet_ntop4(src, dst, size)
- * format an IPv4 address
+ * format an IPv4 address
* return:
- * `dst' (as a const)
+ * `dst' (as a const)
* notes:
- * (1) uses no statics
- * (2) takes a u_char* not an in_addr as input
+ * (1) uses no statics
+ * (2) takes a u_char* not an in_addr as input
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
static const char *
inet_ntop4(src, dst, size)
/* const char *
* inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
+ * convert IPv6 binary address into presentation (printable) format
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
static const char *
inet_ntop6(src, dst, size)
/*
* Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++)
}
#endif /* HAVE_INET_NTOP */
+
#endif
#endif /* _INC_INET_NTOP_H */
+
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
-static int inet_pton4 (const char *src, u_char *dst);
-static int inet_pton6 (const char *src, u_char *dst);
+static int inet_pton4 (const char *src, u_char *dst);
+static int inet_pton6 (const char *src, u_char *dst);
/* int
* inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
+ * convert from presentation format (which usually means ASCII printable)
+ * to network format (which is usually some kind of binary format).
* return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
+ * 1 if the address was valid for the specified address family
+ * 0 if the address wasn't valid (`dst' is untouched in this case)
+ * -1 if some other error occurred (`dst' is untouched in this case, too)
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
int
xinet_pton(af, src, dst)
/* int
* inet_pton4(src, dst)
- * like inet_aton() but without all the hexadecimal and shorthand.
+ * like inet_aton() but without all the hexadecimal and shorthand.
* return:
- * 1 if `src' is a valid dotted quad, else 0.
+ * 1 if `src' is a valid dotted quad, else 0.
* notice:
- * does not touch `dst' unless it's returning 1.
+ * does not touch `dst' unless it's returning 1.
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
static int
inet_pton4(src, dst)
/* int
* inet_pton6(src, dst)
- * convert presentation level address to network order binary form.
+ * convert presentation level address to network order binary form.
* return:
- * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
* notice:
- * (1) does not touch `dst' unless it's returning 1.
- * (2) :: in a full address is silently ignored.
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
* credit:
- * inspired by Mark Andrews.
+ * inspired by Mark Andrews.
* author:
- * Paul Vixie, 1996.
+ * Paul Vixie, 1996.
*/
static int
inet_pton6(src, dst)
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
seen_xdigits = 0;
- break; /* '\0' was seen by inet_pton4(). */
+ break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
}
#endif /* HAVE_INET_PTON */
+
#endif
#endif /* _INC_INET_NTOP_H */
+
#endif
#endif /* SQUID_INITGROPS_H */
+
const unsigned char *cp;
if (n != 0) {
- cp = (unsigned char *)s + n;
- do {
- if (*(--cp) == (unsigned char)c)
- return((void *)cp);
- } while (--n != 0);
+ cp = (unsigned char *)s + n;
+ do {
+ if (*(--cp) == (unsigned char)c)
+ return((void *)cp);
+ } while (--n != 0);
}
return((void *)0);
}
#endif
+
#endif
#endif /* SQUID_COMPAT_MEMRCHR_H */
+
_osfhnd(filehandle) = (long) INVALID_HANDLE_VALUE;
return (0);
} else {
- errno = EBADF; /* bad handle */
- _doserrno = 0L; /* not an OS error */
+ errno = EBADF; /* bad handle */
+ _doserrno = 0L; /* not an OS error */
return -1;
}
}
/* note: this is all MSWindows-specific code; all of it should be conditional */
#endif /* _SQUID_WINDOWS_ */
+
#endif /* _SQUID_AIX_ */
#endif /* SQUID_OS_AIX_H */
+
#endif /* _SQUID_ANDROID_ */
#endif /* SQUID_OS_ANDROID_H */
+
#endif /* _SQUID_DRAGONFLY_ */
#endif /* SQUID_OS_DRAGONFLY_H */
+
#endif /* _SQUID_FREEBSD_ */
#endif /* SQUID_OS_FREEBSD_H */
+
#endif /* _SQUID_HPUX_ */
#endif /* SQUID_OS_HPUX_H */
+
#endif /* _SQUID_LINUX_ */
#endif /* SQUID_OS_LINUX_H */
+
#endif /* _SQUID_APPLE_ */
#endif /* SQUID_OS_MACOSX_H */
+
#endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
-# define __USE_FILE_OFFSET64 1
+# define __USE_FILE_OFFSET64 1
#endif
#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
#define O_RANDOM _O_RANDOM
#endif
#ifndef O_NDELAY
-#define O_NDELAY 0
+#define O_NDELAY 0
#endif
#ifndef S_IFMT
#endif
#if defined(_MSC_VER)
-#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
+#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
#endif
-#define SIGHUP 1 /* hangup */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
-#define SIGBUS 10 /* bus error */
-#define SIGPIPE 13 /* write on a pipe with no one to read it */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGUSR1 30 /* user defined signal 1 */
-#define SIGUSR2 31 /* user defined signal 2 */
+#define SIGHUP 1 /* hangup */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
#if _SQUID_MINGW_
typedef unsigned char boolean;
#if !HAVE_GETTIMEOFDAY
struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
};
#endif
#else /* #ifdef __cplusplus */
#define connect(s,n,l) \
- (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
- (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
+ (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
+ (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
#define gethostbyname(n) \
- (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
- (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
+ (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
+ (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
#define gethostname(n,l) \
- (SOCKET_ERROR == gethostname(n,l) ? \
- (errno = WSAGetLastError()), -1 : 0)
+ (SOCKET_ERROR == gethostname(n,l) ? \
+ (errno = WSAGetLastError()), -1 : 0)
#define recv(s,b,l,f) \
- (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
- (errno = WSAGetLastError()), -1 : ws32_result)
+ (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
+ (errno = WSAGetLastError()), -1 : ws32_result)
#define sendto(s,b,l,f,t,tl) \
- (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
- (errno = WSAGetLastError()), -1 : ws32_result)
+ (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
+ (errno = WSAGetLastError()), -1 : ws32_result)
#define select(n,r,w,e,t) \
- (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
- (errno = WSAGetLastError()), -1 : ws32_result)
+ (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
+ (errno = WSAGetLastError()), -1 : ws32_result)
#define socket(f,t,p) \
- (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
- ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
- (SOCKET)_open_osfhandle(ws32_result,0))
+ (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
+ ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+ (SOCKET)_open_osfhandle(ws32_result,0))
#define write _write /* Needed in util.c */
#define open _open /* Needed in win32lib.c */
#endif /* #ifdef __cplusplus */
#if HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#else
-#define RUSAGE_SELF 0 /* calling process */
-#define RUSAGE_CHILDREN -1 /* terminated child processes */
+#define RUSAGE_SELF 0 /* calling process */
+#define RUSAGE_CHILDREN -1 /* terminated child processes */
struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
- long ru_maxrss; /* integral max resident set size */
- long ru_ixrss; /* integral shared text memory size */
- long ru_idrss; /* integral unshared data size */
- long ru_isrss; /* integral unshared stack size */
- long ru_minflt; /* page reclaims */
- long ru_majflt; /* page faults */
- long ru_nswap; /* swaps */
- long ru_inblock; /* block input operations */
- long ru_oublock; /* block output operations */
- long ru_msgsnd; /* messages sent */
- long ru_msgrcv; /* messages received */
- long ru_nsignals; /* signals received */
- long ru_nvcsw; /* voluntary context switches */
- long ru_nivcsw; /* involuntary context switches */
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ long ru_maxrss; /* integral max resident set size */
+ long ru_ixrss; /* integral shared text memory size */
+ long ru_idrss; /* integral unshared data size */
+ long ru_isrss; /* integral unshared stack size */
+ long ru_minflt; /* page reclaims */
+ long ru_majflt; /* page faults */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary context switches */
};
#endif /* HAVE_SYS_RESOURCE_H */
#endif /* _SQUID_WINDOWS_ */
#endif /* SQUID_OS_MSWINDOWS_H */
+
#endif /* _SQUID_NETBSD_ */
#endif /* SQUID_OS_NETBSD_H */
+
#endif /* _SQUID_NEXT_ */
#endif /* SQUID_OS_NEXT_H */
+
#endif /* _SQUID_OPENBSD_ */
#endif /* SQUID_OS_OPENBSD_H */
+
* Use is subject to license terms.
*/
-/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
+/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
/*
* BIND 4.9.3:
*
* Copyright (c) 1980, 1983, 1988, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*/
#ifndef _NETDB_H
-#define _NETDB_H
+#define _NETDB_H
#include <sys/types.h>
#include <netinet/in.h>
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
#include <sys/feature_tests.h>
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
-#define _PATH_HEQUIV "/etc/hosts.equiv"
-#define _PATH_HOSTS "/etc/hosts"
-#define _PATH_IPNODES "/etc/inet/ipnodes"
-#define _PATH_IPSECALGS "/etc/inet/ipsecalgs"
-#define _PATH_NETMASKS "/etc/netmasks"
-#define _PATH_NETWORKS "/etc/networks"
-#define _PATH_PROTOCOLS "/etc/protocols"
-#define _PATH_SERVICES "/etc/services"
-
- struct hostent {
- char *h_name; /* official name of host */
- char **h_aliases; /* alias list */
- int h_addrtype; /* host address type */
- int h_length; /* length of address */
- char **h_addr_list; /* list of addresses from name server */
-#define h_addr h_addr_list[0] /* address, for backward compatiblity */
- };
-
- /*
- * addrinfo introduced with IPv6 for Protocol-Independent Hostname
- * and Service Name Translation.
- */
+#define _PATH_HEQUIV "/etc/hosts.equiv"
+#define _PATH_HOSTS "/etc/hosts"
+#define _PATH_IPNODES "/etc/inet/ipnodes"
+#define _PATH_IPSECALGS "/etc/inet/ipsecalgs"
+#define _PATH_NETMASKS "/etc/netmasks"
+#define _PATH_NETWORKS "/etc/networks"
+#define _PATH_PROTOCOLS "/etc/protocols"
+#define _PATH_SERVICES "/etc/services"
+
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* length of address */
+ char **h_addr_list; /* list of addresses from name server */
+#define h_addr h_addr_list[0] /* address, for backward compatiblity */
+};
+
+/*
+ * addrinfo introduced with IPv6 for Protocol-Independent Hostname
+ * and Service Name Translation.
+ */
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
- struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, ... */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME, ... */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
#ifdef __sparcv9
- int _ai_pad; /* for backwards compat with old size_t */
+ int _ai_pad; /* for backwards compat with old size_t */
#endif /* __sparcv9 */
- socklen_t ai_addrlen;
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
- };
-
- /* addrinfo flags */
-#define AI_PASSIVE 0x0008 /* intended for bind() + listen() */
-#define AI_CANONNAME 0x0010 /* return canonical version of host */
-#define AI_NUMERICHOST 0x0020 /* use numeric node address string */
-#define AI_NUMERICSERV 0x0040 /* servname is assumed numeric */
-
- /* getipnodebyname() flags */
-#define AI_V4MAPPED 0x0001 /* IPv4 mapped addresses if no IPv6 */
-#define AI_ALL 0x0002 /* IPv6 and IPv4 mapped addresses */
-#define AI_ADDRCONFIG 0x0004 /* AAAA or A records only if IPv6/IPv4 cnfg'd */
-
- /*
- * These were defined in RFC 2553 but not SUSv3
- * or RFC 3493 which obsoleted 2553.
- */
+ socklen_t ai_addrlen;
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+
+/* addrinfo flags */
+#define AI_PASSIVE 0x0008 /* intended for bind() + listen() */
+#define AI_CANONNAME 0x0010 /* return canonical version of host */
+#define AI_NUMERICHOST 0x0020 /* use numeric node address string */
+#define AI_NUMERICSERV 0x0040 /* servname is assumed numeric */
+
+/* getipnodebyname() flags */
+#define AI_V4MAPPED 0x0001 /* IPv4 mapped addresses if no IPv6 */
+#define AI_ALL 0x0002 /* IPv6 and IPv4 mapped addresses */
+#define AI_ADDRCONFIG 0x0004 /* AAAA or A records only if IPv6/IPv4 cnfg'd */
+
+/*
+ * These were defined in RFC 2553 but not SUSv3
+ * or RFC 3493 which obsoleted 2553.
+ */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
-#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
+#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
- /* addrinfo errors */
-#define EAI_ADDRFAMILY 1 /* address family not supported */
-#define EAI_NODATA 7 /* no address */
+/* addrinfo errors */
+#define EAI_ADDRFAMILY 1 /* address family not supported */
+#define EAI_NODATA 7 /* no address */
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
-#define EAI_AGAIN 2 /* DNS temporary failure */
-#define EAI_BADFLAGS 3 /* invalid ai_flags */
-#define EAI_FAIL 4 /* DNS non-recoverable failure */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NONAME 8 /* host/servname not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error in errno */
-#define EAI_OVERFLOW 12 /* argument buffer overflow */
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
-
- /* getnameinfo flags */
-#define NI_NOFQDN 0x0001
-#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
-#define NI_NAMEREQD 0x0004 /* request DNS name */
-#define NI_NUMERICSERV 0x0008
-#define NI_DGRAM 0x0010
+#define EAI_AGAIN 2 /* DNS temporary failure */
+#define EAI_BADFLAGS 3 /* invalid ai_flags */
+#define EAI_FAIL 4 /* DNS non-recoverable failure */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NONAME 8 /* host/servname not known */
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error in errno */
+#define EAI_OVERFLOW 12 /* argument buffer overflow */
+#define EAI_PROTOCOL 13
+#define EAI_MAX 14
+
+/* getnameinfo flags */
+#define NI_NOFQDN 0x0001
+#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
+#define NI_NAMEREQD 0x0004 /* request DNS name */
+#define NI_NUMERICSERV 0x0008
+#define NI_DGRAM 0x0010
#if !defined(_XPG6) || defined(__EXTENSIONS__)
- /* Not listed in any standards document */
-#define NI_WITHSCOPEID 0x0020
-#define NI_NUMERICSCOPE 0x0040
+/* Not listed in any standards document */
+#define NI_WITHSCOPEID 0x0020
+#define NI_NUMERICSCOPE 0x0040
- /* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
-#define NI_MAXHOST 1025
-#define NI_MAXSERV 32
+/* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
- /*
- * Scope delimit character
- */
-#define SCOPE_DELIMITER '%'
+/*
+ * Scope delimit character
+ */
+#define SCOPE_DELIMITER '%'
- /*
- * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
- * and algorithms.
- */
+/*
+ * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
+ * and algorithms.
+ */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
- typedef struct ipsecalgent {
- char **a_names; /* algorithm names */
- int a_proto_num; /* protocol number */
- int a_alg_num; /* algorithm number */
- char *a_mech_name; /* encryption framework mechanism name */
- int *a_block_sizes; /* supported block sizes */
- int *a_key_sizes; /* supported key sizes */
- int a_key_increment; /* key size increment */
- int *a_mech_params; /* mechanism specific parameters */
- int a_alg_flags; /* algorithm flags */
- } ipsecalgent_t;
-
- /* well-known IPsec protocol numbers */
-
-#define IPSEC_PROTO_AH 2
-#define IPSEC_PROTO_ESP 3
+typedef struct ipsecalgent {
+ char **a_names; /* algorithm names */
+ int a_proto_num; /* protocol number */
+ int a_alg_num; /* algorithm number */
+ char *a_mech_name; /* encryption framework mechanism name */
+ int *a_block_sizes; /* supported block sizes */
+ int *a_key_sizes; /* supported key sizes */
+ int a_key_increment; /* key size increment */
+ int *a_mech_params; /* mechanism specific parameters */
+ int a_alg_flags; /* algorithm flags */
+} ipsecalgent_t;
+
+/* well-known IPsec protocol numbers */
+
+#define IPSEC_PROTO_AH 2
+#define IPSEC_PROTO_ESP 3
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
- /*
- * Assumption here is that a network number
- * fits in 32 bits -- probably a poor one.
- */
- struct netent {
- char *n_name; /* official name of net */
- char **n_aliases; /* alias list */
- int n_addrtype; /* net address type */
- in_addr_t n_net; /* network # */
- };
-
- struct protoent {
- char *p_name; /* official protocol name */
- char **p_aliases; /* alias list */
- int p_proto; /* protocol # */
- };
-
- struct servent {
- char *s_name; /* official service name */
- char **s_aliases; /* alias list */
- int s_port; /* port # */
- char *s_proto; /* protocol to use */
- };
-
-#ifdef __STDC__
+/*
+ * Assumption here is that a network number
+ * fits in 32 bits -- probably a poor one.
+ */
+struct netent {
+ char *n_name; /* official name of net */
+ char **n_aliases; /* alias list */
+ int n_addrtype; /* net address type */
+ in_addr_t n_net; /* network # */
+};
+
+struct protoent {
+ char *p_name; /* official protocol name */
+ char **p_aliases; /* alias list */
+ int p_proto; /* protocol # */
+};
+
+struct servent {
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
+ int s_port; /* port # */
+ char *s_proto; /* protocol to use */
+};
+
+#ifdef __STDC__
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
- struct hostent *gethostbyname_r
- (const char *, struct hostent *, char *, int, int *h_errnop);
- struct hostent *gethostbyaddr_r
- (const char *, int, int, struct hostent *, char *, int, int *h_errnop);
- struct hostent *getipnodebyname(const char *, int, int, int *);
- struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
- void freehostent(struct hostent *);
- struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop);
-
- struct servent *getservbyname_r
- (const char *name, const char *, struct servent *, char *, int);
- struct servent *getservbyport_r
- (int port, const char *, struct servent *, char *, int);
- struct servent *getservent_r(struct servent *, char *, int);
-
- struct netent *getnetbyname_r
- (const char *, struct netent *, char *, int);
- struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int);
- struct netent *getnetent_r(struct netent *, char *, int);
-
- struct protoent *getprotobyname_r
- (const char *, struct protoent *, char *, int);
- struct protoent *getprotobynumber_r
- (int, struct protoent *, char *, int);
- struct protoent *getprotoent_r(struct protoent *, char *, int);
-
- int getnetgrent_r(char **, char **, char **, char *, int);
- int innetgr(const char *, const char *, const char *, const char *);
+struct hostent *gethostbyname_r
+(const char *, struct hostent *, char *, int, int *h_errnop);
+struct hostent *gethostbyaddr_r
+(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
+struct hostent *getipnodebyname(const char *, int, int, int *);
+struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
+void freehostent(struct hostent *);
+struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop);
+
+struct servent *getservbyname_r
+(const char *name, const char *, struct servent *, char *, int);
+struct servent *getservbyport_r
+(int port, const char *, struct servent *, char *, int);
+struct servent *getservent_r(struct servent *, char *, int);
+
+struct netent *getnetbyname_r
+(const char *, struct netent *, char *, int);
+struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int);
+struct netent *getnetent_r(struct netent *, char *, int);
+
+struct protoent *getprotobyname_r
+(const char *, struct protoent *, char *, int);
+struct protoent *getprotobynumber_r
+(int, struct protoent *, char *, int);
+struct protoent *getprotoent_r(struct protoent *, char *, int);
+
+int getnetgrent_r(char **, char **, char **, char *, int);
+int innetgr(const char *, const char *, const char *, const char *);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
- /* Old interfaces that return a pointer to a static area; MT-unsafe */
- struct hostent *gethostbyname(const char *);
- struct hostent *gethostent(void);
- struct netent *getnetbyaddr(in_addr_t, int);
- struct netent *getnetbyname(const char *);
- struct netent *getnetent(void);
- struct protoent *getprotobyname(const char *);
- struct protoent *getprotobynumber(int);
- struct protoent *getprotoent(void);
- struct servent *getservbyname(const char *, const char *);
- struct servent *getservbyport(int, const char *);
- struct servent *getservent(void);
-
- /* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
+/* Old interfaces that return a pointer to a static area; MT-unsafe */
+struct hostent *gethostbyname(const char *);
+struct hostent *gethostent(void);
+struct netent *getnetbyaddr(in_addr_t, int);
+struct netent *getnetbyname(const char *);
+struct netent *getnetent(void);
+struct protoent *getprotobyname(const char *);
+struct protoent *getprotobynumber(int);
+struct protoent *getprotoent(void);
+struct servent *getservbyname(const char *, const char *);
+struct servent *getservbyport(int, const char *);
+struct servent *getservent(void);
+
+/* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
- struct hostent *gethostbyaddr(const void *, socklen_t, int);
+struct hostent *gethostbyaddr(const void *, socklen_t, int);
#else
- struct hostent *gethostbyaddr(const void *, size_t, int);
+struct hostent *gethostbyaddr(const void *, size_t, int);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
- int endhostent(void);
- int endnetent(void);
- int endprotoent(void);
- int endservent(void);
- int sethostent(int);
- int setnetent(int);
- int setprotoent(int);
- int setservent(int);
+int endhostent(void);
+int endnetent(void);
+int endprotoent(void);
+int endservent(void);
+int sethostent(int);
+int setnetent(int);
+int setprotoent(int);
+int setservent(int);
#else
- void endhostent(void);
- void endnetent(void);
- void endprotoent(void);
- void endservent(void);
- void sethostent(int);
- void setnetent(int);
- void setprotoent(int);
- void setservent(int);
+void endhostent(void);
+void endnetent(void);
+void endprotoent(void);
+void endservent(void);
+void sethostent(int);
+void setnetent(int);
+void setprotoent(int);
+void setservent(int);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
-#ifdef _XPG6
-#ifdef __PRAGMA_REDEFINE_EXTNAME
+#ifdef _XPG6
+#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getaddrinfo __xnet_getaddrinfo
-#else /* __PRAGMA_REDEFINE_EXTNAME */
-#define getaddrinfo __xnet_getaddrinfo
-#endif /* __PRAGMA_REDEFINE_EXTNAME */
-#endif /* _XPG6 */
-
- int getaddrinfo(const char *_RESTRICT_KYWD1,
- const char *_RESTRICT_KYWD2,
- const struct addrinfo *_RESTRICT_KYWD3,
- struct addrinfo **_RESTRICT_KYWD4);
- void freeaddrinfo(struct addrinfo *);
- const char *gai_strerror(int);
- int getnameinfo(const struct sockaddr *_RESTRICT_KYWD1,
- socklen_t, char *_RESTRICT_KYWD2, socklen_t,
- char *_RESTRICT_KYWD3, socklen_t, int);
+#else /* __PRAGMA_REDEFINE_EXTNAME */
+#define getaddrinfo __xnet_getaddrinfo
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+#endif /* _XPG6 */
+
+int getaddrinfo(const char *_RESTRICT_KYWD1,
+ const char *_RESTRICT_KYWD2,
+ const struct addrinfo *_RESTRICT_KYWD3,
+ struct addrinfo **_RESTRICT_KYWD4);
+void freeaddrinfo(struct addrinfo *);
+const char *gai_strerror(int);
+int getnameinfo(const struct sockaddr *_RESTRICT_KYWD1,
+ socklen_t, char *_RESTRICT_KYWD2, socklen_t,
+ char *_RESTRICT_KYWD3, socklen_t, int);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
- int getnetgrent(char **, char **, char **);
- int setnetgrent(const char *);
- int endnetgrent(void);
- int rcmd(char **, unsigned short,
- const char *, const char *, const char *, int *);
- int rcmd_af(char **, unsigned short,
- const char *, const char *, const char *, int *, int);
- int rresvport_af(int *, int);
- int rresvport_addr(int *, struct sockaddr_storage *);
- int rexec(char **, unsigned short,
- const char *, const char *, const char *, int *);
- int rexec_af(char **, unsigned short,
- const char *, const char *, const char *, int *, int);
- int rresvport(int *);
- int ruserok(const char *, int, const char *, const char *);
- /* BIND */
- struct hostent *gethostbyname2(const char *, int);
- void herror(const char *);
- const char *hstrerror(int);
- /* End BIND */
-
- /* IPsec algorithm prototype definitions */
- struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
- struct ipsecalgent *getipsecalgbynum(int, int, int *);
- int getipsecprotobyname(const char *doi_name);
- char *getipsecprotobynum(int doi_domain);
- void freeipsecalgent(struct ipsecalgent *ptr);
- /* END IPsec algorithm prototype definitions */
+int getnetgrent(char **, char **, char **);
+int setnetgrent(const char *);
+int endnetgrent(void);
+int rcmd(char **, unsigned short,
+ const char *, const char *, const char *, int *);
+int rcmd_af(char **, unsigned short,
+ const char *, const char *, const char *, int *, int);
+int rresvport_af(int *, int);
+int rresvport_addr(int *, struct sockaddr_storage *);
+int rexec(char **, unsigned short,
+ const char *, const char *, const char *, int *);
+int rexec_af(char **, unsigned short,
+ const char *, const char *, const char *, int *, int);
+int rresvport(int *);
+int ruserok(const char *, int, const char *, const char *);
+/* BIND */
+struct hostent *gethostbyname2(const char *, int);
+void herror(const char *);
+const char *hstrerror(int);
+/* End BIND */
+
+/* IPsec algorithm prototype definitions */
+struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
+struct ipsecalgent *getipsecalgbynum(int, int, int *);
+int getipsecprotobyname(const char *doi_name);
+char *getipsecprotobynum(int doi_domain);
+void freeipsecalgent(struct ipsecalgent *ptr);
+/* END IPsec algorithm prototype definitions */
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
-#else /* __STDC__ */
- struct hostent *gethostbyname_r();
- struct hostent *gethostbyaddr_r();
- struct hostent *getipnodebyname();
- struct hostent *getipnodebyaddr();
- void freehostent();
- struct hostent *gethostent_r();
- struct servent *getservbyname_r();
- struct servent *getservbyport_r();
- struct servent *getservent_r();
- struct netent *getnetbyname_r();
- struct netent *getnetbyaddr_r();
- struct netent *getnetent_r();
- struct protoent *getprotobyname_r();
- struct protoent *getprotobynumber_r();
- struct protoent *getprotoent_r();
- int getnetgrent_r();
- int innetgr();
-
- /* Old interfaces that return a pointer to a static area; MT-unsafe */
- struct hostent *gethostbyname();
- struct hostent *gethostbyaddr();
- struct hostent *gethostent();
- struct netent *getnetbyname();
- struct netent *getnetbyaddr();
- struct netent *getnetent();
- struct servent *getservbyname();
- struct servent *getservbyport();
- struct servent *getservent();
- struct protoent *getprotobyname();
- struct protoent *getprotobynumber();
- struct protoent *getprotoent();
- int getnetgrent();
-
- int sethostent();
- int endhostent();
- int setnetent();
- int endnetent();
- int setservent();
- int endservent();
- int setprotoent();
- int endprotoent();
- int setnetgrent();
- int endnetgrent();
- int rcmd();
- int rcmd_af();
- int rexec();
- int rexec_af();
- int rresvport();
- int rresvport_af();
- int rresvport_addr();
- int ruserok();
- /* BIND */
- struct hostent *gethostbyname2();
- void herror();
- char *hstrerror();
- /* IPv6 prototype definitons */
- int getaddrinfo();
- void freeaddrinfo();
- const char *gai_strerror();
- int getnameinfo();
- /* END IPv6 prototype definitions */
- /* End BIND */
+#else /* __STDC__ */
+struct hostent *gethostbyname_r();
+struct hostent *gethostbyaddr_r();
+struct hostent *getipnodebyname();
+struct hostent *getipnodebyaddr();
+void freehostent();
+struct hostent *gethostent_r();
+struct servent *getservbyname_r();
+struct servent *getservbyport_r();
+struct servent *getservent_r();
+struct netent *getnetbyname_r();
+struct netent *getnetbyaddr_r();
+struct netent *getnetent_r();
+struct protoent *getprotobyname_r();
+struct protoent *getprotobynumber_r();
+struct protoent *getprotoent_r();
+int getnetgrent_r();
+int innetgr();
+
+/* Old interfaces that return a pointer to a static area; MT-unsafe */
+struct hostent *gethostbyname();
+struct hostent *gethostbyaddr();
+struct hostent *gethostent();
+struct netent *getnetbyname();
+struct netent *getnetbyaddr();
+struct netent *getnetent();
+struct servent *getservbyname();
+struct servent *getservbyport();
+struct servent *getservent();
+struct protoent *getprotobyname();
+struct protoent *getprotobynumber();
+struct protoent *getprotoent();
+int getnetgrent();
+
+int sethostent();
+int endhostent();
+int setnetent();
+int endnetent();
+int setservent();
+int endservent();
+int setprotoent();
+int endprotoent();
+int setnetgrent();
+int endnetgrent();
+int rcmd();
+int rcmd_af();
+int rexec();
+int rexec_af();
+int rresvport();
+int rresvport_af();
+int rresvport_addr();
+int ruserok();
+/* BIND */
+struct hostent *gethostbyname2();
+void herror();
+char *hstrerror();
+/* IPv6 prototype definitons */
+int getaddrinfo();
+void freeaddrinfo();
+const char *gai_strerror();
+int getnameinfo();
+/* END IPv6 prototype definitions */
+/* End BIND */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
- /* IPsec algorithm prototype definitions */
- struct ipsecalgent *getalgbyname();
- struct ipsecalgent *getalgbydoi();
- int getdoidomainbyname();
- const char *getdoidomainbynum();
- void freealgent();
- /* END IPsec algorithm prototype definitions */
+/* IPsec algorithm prototype definitions */
+struct ipsecalgent *getalgbyname();
+struct ipsecalgent *getalgbydoi();
+int getdoidomainbyname();
+const char *getdoidomainbynum();
+void freealgent();
+/* END IPsec algorithm prototype definitions */
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
-#endif /* __STDC__ */
+#endif /* __STDC__ */
- /*
- * Error return codes from gethostbyname() and gethostbyaddr()
- * (when using the resolver)
- */
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (when using the resolver)
+ */
- extern int h_errno;
+extern int h_errno;
-#ifdef _REENTRANT
-#ifdef __STDC__
- extern int *__h_errno(void);
+#ifdef _REENTRANT
+#ifdef __STDC__
+extern int *__h_errno(void);
#else
- extern int *__h_errno();
-#endif /* __STDC__ */
-
- /* Only #define h_errno if there is no conflict with other use */
-#ifdef H_ERRNO_IS_FUNCTION
-#define h_errno (*__h_errno())
-#endif /* NO_H_ERRNO_DEFINE */
-#endif /* _REENTRANT */
-
- /*
- * Error return codes from gethostbyname() and gethostbyaddr()
- * (left in extern int h_errno).
- */
-#define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */
-#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
-#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
-#define NO_DATA 4 /* Valid name, no data record of requested type */
+extern int *__h_errno();
+#endif /* __STDC__ */
+
+/* Only #define h_errno if there is no conflict with other use */
+#ifdef H_ERRNO_IS_FUNCTION
+#define h_errno (*__h_errno())
+#endif /* NO_H_ERRNO_DEFINE */
+#endif /* _REENTRANT */
+
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in extern int h_errno).
+ */
+#define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */
+#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
+#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define NO_DATA 4 /* Valid name, no data record of requested type */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
-#define NO_ADDRESS NO_DATA /* no address, look for MX record */
+#define NO_ADDRESS NO_DATA /* no address, look for MX record */
- /* BIND */
-#define NETDB_INTERNAL -1 /* see errno */
-#define NETDB_SUCCESS 0 /* no problem */
- /* End BIND */
+/* BIND */
+#define NETDB_INTERNAL -1 /* see errno */
+#define NETDB_SUCCESS 0 /* no problem */
+/* End BIND */
-#define MAXHOSTNAMELEN 256
+#define MAXHOSTNAMELEN 256
-#define MAXALIASES 35
-#define MAXADDRS 35
+#define MAXALIASES 35
+#define MAXADDRS 35
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
-#endif /* _NETDB_H */
+#endif /* _NETDB_H */
+
#endif /* _SQUID_OS2_ */
#endif /* SQUID_OS_OS2_H */
+
#endif /* _SQUID_QNX_ */
#endif /* SQUID_OS_QNX_H */
+
****************************************************************************/
#if !defined(_SVR4_SOURCE)
-#define _SVR4_SOURCE /* for tempnam(3) */
+#define _SVR4_SOURCE /* for tempnam(3) */
#endif
#if USE_ASYNC_IO
#endif /* _SQUID_SGI_ */
#endif /* SQUID_OS_SGI_H */
+
#if defined(i386) || defined(__i386)
#if !HAVE_PAD128_T
typedef union {
- long double _q;
- int32_t _l[4];
+ long double _q;
+ int32_t _l[4];
} pad128_t;
#endif
#if !HAVE_UPAD128_T
typedef union {
- long double _q;
- uint32_t _l[4];
+ long double _q;
+ uint32_t _l[4];
} upad128_t;
#endif
#endif
#endif /* _SQUID_SOLARIS_ */
#endif /* SQUID_OS_SOALRIS_H */
+
#endif /* _SQUID_SUNOS_ */
#endif /* SQUID_OS_SUNOS_H */
+
#define _SQUID_SUNOS_ 1
#endif /* __SVR4 */
-#elif defined(__hpux) /* HP-UX - SysV-like? */
+#elif defined(__hpux) /* HP-UX - SysV-like? */
#define _SQUID_HPUX_ 1
-#elif defined(__osf__) /* OSF/1 */
+#elif defined(__osf__) /* OSF/1 */
#define _SQUID_OSF_ 1
-#elif defined(_AIX) /* AIX */
+#elif defined(_AIX) /* AIX */
#define _SQUID_AIX_ 1
-#elif defined(__linux__) /* Linux. WARNING: solaris-x86 also sets this */
+#elif defined(__linux__) /* Linux. WARNING: solaris-x86 also sets this */
#define _SQUID_LINUX_ 1
-#elif defined(__FreeBSD__) /* FreeBSD */
+#elif defined(__FreeBSD__) /* FreeBSD */
#define _SQUID_FREEBSD_ 1
#elif defined(__FreeBSD_kernel__) /* GNU/kFreeBSD */
#define _SQUID_KFREEBSD_ 1
-#elif defined(__sgi__) || defined(sgi) || defined(__sgi) /* SGI */
+#elif defined(__sgi__) || defined(sgi) || defined(__sgi) /* SGI */
#define _SQUID_SGI_ 1
#elif defined(__NeXT__)
#endif /* OS automatic detection */
#endif /* SQUID_COMPAT_OSDETECT_H */
+
else
fputs( "(unknown)\n", stderr );
}
+
extern void psignal(int sig, const char* msg);
#endif /* __SQUID_PSIGNAL_H */
+
bool shm_portable_segment_name_is_path();
#endif /* SQUID_COMPAT_CPU_H */
+
}
#endif /* HAVE_STATVFS */
+
#endif
#endif /* !HAVE_STATVFS */
-
#if HAVE_STATVFS
#define xstatvfs statvfs
#endif
#endif /* _SQUID_COMPAT_XSTATVFS_H */
+
#endif
#endif /* _SQUID_COMPAT_STDIO_H */
+
#endif
#endif /* _SQUID_STDVARARGS_H */
+
{
return sys_errlist[ern];
}
+
SQUIDCEXTERN const char *strnrchr(const char *s, size_t count, int c);
#endif /* COMPAT_STRNRCHR_H_ */
+
* Update/Maintenance History:
*
* 26-Apr-2008 : Copied from FreeBSD via OpenGrok
- * - added protection around libray headers
- * - added squid_ prefix for uniqueness
- * so we can use it where OS copy is broken.
+ * - added protection around libray headers
+ * - added squid_ prefix for uniqueness
+ * so we can use it where OS copy is broken.
*
* Original License and code follows.
*/
/*-
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)strstr.c 8.1 (Berkeley) 6/4/93
+ * @(#)strstr.c 8.1 (Berkeley) 6/4/93
* $FreeBSD: src/lib/libc/string/strnstr.c,v 1.2.2.1 2001/12/09 06:50:03 mike Exp $
* $DragonFly: src/lib/libc/string/strnstr.c,v 1.4 2006/03/20 17:24:20 dillon Exp $
*/
#endif /* !HAVE_STRNSTR */
#endif /* SQUID_COMPAT_STRNSTR_CC_ */
+
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
#endif /* !HAVE_STRTOLL */
#endif /* _SQUID_COMPAT_STRTOLL_H */
+
#undef TMP_MAX
-#define _tmp "/tmp/"
-#define lengthof_tmp 5
+#define _tmp "/tmp/"
+#define lengthof_tmp 5
#ifndef LONG_BIT
-#define LONG_BIT (CHAR_BIT * 4) /* assume sizeof(long) == 4 */
+#define LONG_BIT (CHAR_BIT * 4) /* assume sizeof(long) == 4 */
#endif
-#define L_tmpmin (lengthof_tmp + 5) /* 5 chars for pid. */
+#define L_tmpmin (lengthof_tmp + 5) /* 5 chars for pid. */
#if (L_tmpnam > L_tmpmin)
-#if (L_tmpnam > L_tmpmin + LONG_BIT / 6) /* base 64 */
-#define TMP_MAX ULONG_MAX
+#if (L_tmpnam > L_tmpmin + LONG_BIT / 6) /* base 64 */
+#define TMP_MAX ULONG_MAX
#else
-#define TMP_MAX ((1L << (6 * (L_tmpnam - L_tmpmin))) - 1)
+#define TMP_MAX ((1L << (6 * (L_tmpnam - L_tmpmin))) - 1)
#endif
#else
#ifndef L_tmpnam
static const char digits[] =
#if (L_tmpnam >= L_tmpmin + LONG_BIT / 4)
"0123456789abcdef";
-#define TMP_BASE 16
+#define TMP_BASE 16
#else
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
-#define TMP_BASE 64
+#define TMP_BASE 64
#endif
static unsigned long lastcount = 0;
static char buffer[L_tmpnam + 1];
pid_t pid = getpid();
if (sizeof(_tmp) - 1 != lengthof_tmp)
- abort(); /* Consistency error. */
+ abort(); /* Consistency error. */
for (;;) {
register int i = L_tmpnam;
return 1;
}
#endif
+
extern char *tempnam(const char *, const char *);
#endif /* SQUID_TEMPNAM_H */
+
};
#endif /* SQUID_COMPAT_TESTS_TESTPRECOMPILER_H */
+
#endif
#endif /* SQUID_TYPES_H */
+
#endif /* WITH_VALGRIND */
#endif /* SQUID_CONFIG_H */
+
PROF_stop(free);
PROF_stop(free_const);
}
+
extern "C" {
#endif
- /**
- * xcalloc() - same as calloc(3). Used for portability.
- * Never returns NULL; fatal on error.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- void *xcalloc(size_t n, size_t sz);
+/**
+ * xcalloc() - same as calloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xcalloc(size_t n, size_t sz);
- /**
- * xmalloc() - same as malloc(3). Used for portability.
- * Never returns NULL; fatal on error.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- void *xmalloc(size_t sz);
+/**
+ * xmalloc() - same as malloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xmalloc(size_t sz);
- /**
- * xrealloc() - same as realloc(3). Used for portability.
- * Never returns NULL; fatal on error.
- */
- void *xrealloc(void *s, size_t sz);
+/**
+ * xrealloc() - same as realloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ */
+void *xrealloc(void *s, size_t sz);
- /**
- * free_const() - Same as free(3). Used for portability.
- * Accepts pointers to dynamically allocated const data.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- void free_const(const void *s);
+/**
+ * free_const() - Same as free(3). Used for portability.
+ * Accepts pointers to dynamically allocated const data.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void free_const(const void *s);
- /**
- * xfree() - same as free(3). Used for portability.
- * Accepts pointers to dynamically allocated const data.
- * Will not call free(3) if the pointer is NULL.
- *
- * Pointer is left with a value on completion.
- * Use safe_free() if the pointer needs to be set to NULL afterward.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- static inline void xfree(const void *p) { if (p) free_const(p); }
+/**
+ * xfree() - same as free(3). Used for portability.
+ * Accepts pointers to dynamically allocated const data.
+ * Will not call free(3) if the pointer is NULL.
+ *
+ * Pointer is left with a value on completion.
+ * Use safe_free() if the pointer needs to be set to NULL afterward.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+static inline void xfree(const void *p) { if (p) free_const(p); }
- /**
- * safe_free() - same as free(3). Used for portability.
- * Accepts pointers to dynamically allocated const data.
- * Will not call free(3) if the pointer is NULL.
- * Sets the pointer to NULL on completion.
- *
- * Use xfree() if the pointer does not need to be set afterward.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
+/**
+ * safe_free() - same as free(3). Used for portability.
+ * Accepts pointers to dynamically allocated const data.
+ * Will not call free(3) if the pointer is NULL.
+ * Sets the pointer to NULL on completion.
+ *
+ * Use xfree() if the pointer does not need to be set afterward.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
#define safe_free(x) while ((x)) { free_const((x)); (x) = NULL; }
#ifdef __cplusplus
#endif
#endif /* _SQUID_COMPAT_XALLOC_H */
+
#define xisgraph(x) isgraph((unsigned char)x)
#endif /* _SQUID_COMPAT_XIS_H */
+
return xstrerror_buf;
}
+
extern const char * xstrerr(int error);
#endif /* _SQUID_COMPAT_XSTRERROR_H */
+
p = xstrncpy((char *)xmalloc(sz), s, sz);
return p;
}
+
extern "C" {
#endif
- /**
- * xstrdup() - same as strdup(3). Used for portability.
- * Never returns NULL; fatal on error.
- *
- * Sets errno to EINVAL if a NULL pointer is passed.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- char *xstrdup(const char *s);
+/**
+ * xstrdup() - same as strdup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrdup(const char *s);
#ifdef strdup
#undef strdup
#endif
#define strdup(X) xstrdup((X))
- /*
- * xstrncpy() - similar to strncpy(3) but terminates string
- * always with '\0' if (n != 0 and dst != NULL),
- * and doesn't do padding
- */
- char *xstrncpy(char *dst, const char *src, size_t n);
+/*
+ * xstrncpy() - similar to strncpy(3) but terminates string
+ * always with '\0' if (n != 0 and dst != NULL),
+ * and doesn't do padding
+ */
+char *xstrncpy(char *dst, const char *src, size_t n);
- /**
- * xstrndup() - same as strndup(3). Used for portability.
- * Never returns NULL; fatal on error.
- *
- * Sets errno to EINVAL if a NULL pointer or negative
- * length is passed.
- *
- * Define failure_notify to receive error message.
- * otherwise perror() is used to display it.
- */
- char *xstrndup(const char *s, size_t n);
+/**
+ * xstrndup() - same as strndup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer or negative
+ * length is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrndup(const char *s, size_t n);
#ifdef strndup
#undef strndup
#endif
#endif /* SQUID_COMPAT_XSTRING_H */
+
* Update/Maintenance History:
*
* 12-Sep-2010 : Copied from iptables xtables.c
- * - xtables_strtoui renamed to xstrtoui
- * - xtables_strtoul renamed to xstrtoul
+ * - xtables_strtoui renamed to xstrtoui
+ * - xtables_strtoul renamed to xstrtoul
*
* Original License and code follows.
*/
}
#endif /* SQUID_XSTRTO_C_ */
+
#endif /* __cplusplus */
#endif /* _SQUID_XSTRTO_H */
+
* Please see the COPYING and CONTRIBUTORS files for details.
*/
+
section 00 Announcement Server
section 00 Client Database
section 00 Debug Routines
fprintf(stderr, "ERROR: Your LDAP library does not have URI support\n");
exit(1);
#endif
- /* Fall thru to -h */
+ /* Fall thru to -h */
case 'h':
if (ldapServer) {
int len = strlen(ldapServer) + 1 + strlen(value) + 1;
return 0;
}
+
static int init = 0;
/* shared */
-char Allowuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
+char Allowuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
int
Read_allowusers(void)
{
Check_forfilechange(&AllowUsers);
}
+
#define MAXSERVERS 5
#define NTHOSTLEN 65
-extern char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
+extern char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
extern char Allowuserpath[MAXPATHLEN];
typedef struct _ServerTuple {
char domain[NTHOSTLEN];
} ServerTuple;
-ServerTuple ServerArray[MAXSERVERS]; /* Array of servers to query */
-int Serversqueried = 0; /* Number of servers queried */
+ServerTuple ServerArray[MAXSERVERS]; /* Array of servers to query */
+int Serversqueried = 0; /* Number of servers queried */
/* Declarations */
OpenConfigFile(void)
{
FILE *ConfigFile;
- char Confbuf[2049]; /* Line reading buffer */
+ char Confbuf[2049]; /* Line reading buffer */
/* Initialise defaults */
result = Valid_User(username, password, ServerArray[x].pdc,
ServerArray[x].bdc, ServerArray[x].domain);
- switch (result) { /* Write any helpful syslog messages */
+ switch (result) { /* Write any helpful syslog messages */
case 0:
break;
case 1:
* 2 - Protocol error.
* 3 - Logon error; Incorrect password or username given.
*/
+
static int init = 0;
/* shared */
-char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
+char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */
int
Read_denyusers(void)
void
Checktimer()
{
- static time_t Lasttime; /* The last time the timer was checked */
- static time_t Currenttime; /* The current time */
+ static time_t Lasttime; /* The last time the timer was checked */
+ static time_t Currenttime; /* The current time */
Currenttime = time(NULL);
Lasttime = Currenttime;
}
}
+
puts("ERR");
continue;
}
- Checktimer(); /* Check if the user lists have changed */
+ Checktimer(); /* Check if the user lists have changed */
rfc1738_unescape(username);
rfc1738_unescape(password);
return 0;
}
+
extern void Check_forallowchange(void);
#endif /* _SQUID_HELPERS_BASIC_AUTH_MSNT_MSNTAUTH_H */
+
#include "usersfile.h"
-#define NAMELEN 50 /* Maximum username length */
+#define NAMELEN 50 /* Maximum username length */
static int
name_cmp(const void *a, const void *b)
void
Check_forfilechange(usersfile * uf)
{
- struct stat ChkBuf; /* Stat data buffer */
+ struct stat ChkBuf; /* Stat data buffer */
/* Stat the allowed users file. If it cannot be accessed, return. */
if (errno == ENOENT) {
uf->LMT = 0;
free_names(uf);
- } else { /* Report error when accessing file */
+ } else { /* Report error when accessing file */
syslog(LOG_ERR, "%s: %s", uf->path, strerror(errno));
}
return;
syslog(LOG_INFO, "Check_forfilechange: Reloading user list '%s'.", uf->path);
Read_usersfile(NULL, uf);
}
+
int Read_usersfile(const char *path, usersfile * uf);
int Check_userlist(usersfile * uf, char *User);
void Check_forfilechange(usersfile * uf);
+
SMB_Init();
con = SMB_Connect_Server(NULL, SERVER, DOMAIN);
- if (con == NULL) { /* Error ... */
+ if (con == NULL) { /* Error ... */
con = SMB_Connect_Server(NULL, BACKUP, DOMAIN);
if (con == NULL) {
return (NTV_SERVER_ERROR);
}
}
- if (SMB_Negotiate(con, supportedDialects) < 0) { /* An error */
+ if (SMB_Negotiate(con, supportedDialects) < 0) { /* An error */
SMB_Discon(con, 0);
return (NTV_PROTOCOL_ERROR);
}
SMB_Discon(con, 0);
return (NTV_NO_ERROR);
}
+
int Valid_User(char *USERNAME, char *PASSWORD, char *SERVER, char *BACKUP, char *DOMAIN);
#endif
+
}
while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) {
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if (stat(argv[1], &sb) == 0) {
if (sb.st_mtime != change_time) {
read_passwd_file(argv[1]);
}
exit(0);
}
+
#include <cstring>
-static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
+static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static void md5to64(char *s, unsigned long v, int n)
char *md5sum(const char *s);
#endif /* _CRYPT_MD5_H */
+
while (fgets(buf, 256, stdin) != NULL) {
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if ((user = strtok(buf, " ")) == NULL) {
printf("ERR\n");
}
exit(0);
}
+
#include "nis_support.h"
-#define NO_YPERR 0 /* There is no error */
+#define NO_YPERR 0 /* There is no error */
char *
get_nis_password(char *user, char *nisdomain, char *nismap)
case YPERR_YPBIND:
syslog(LOG_ERR, "Squid Authentication through ypbind failure: can't communicate with ypbind");
return NULL;
- case YPERR_KEY: /* No such key in map */
+ case YPERR_KEY: /* No such key in map */
return NULL;
default:
return NULL;
}
}
+
-/*\r
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors\r
- *\r
- * Squid software is distributed under GPLv2+ license and includes\r
- * contributions from numerous individuals and organizations.\r
- * Please see the COPYING and CONTRIBUTORS files for details.\r
- */\r
-\r
-extern char * get_nis_password(char *user, char *nisdomain, char *nismap);\r
+/*
+ * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+extern char * get_nis_password(char *user, char *nisdomain, char *nismap);
+
*
* Version 2.0, 2002-01-07
* One shot mode, command line options
- * man page
+ * man page
*
* Version 1.3, 1999-12-10
- * Bugfix release 1.3 to work around Solaris 2.6
+ * Bugfix release 1.3 to work around Solaris 2.6
* brokenness (not sending arguments to conversation
* functions)
*
* Version 1.2, internal release
*
* Version 1.1, 1999-05-11
- * Initial version
+ * Initial version
*/
#include "squid.h"
#include "helpers/defines.h"
#endif
#if _SQUID_SOLARIS_
-static char *password = NULL; /* Workaround for Solaris 2.6 brokenness */
+static char *password = NULL; /* Workaround for Solaris 2.6 brokenness */
#endif
extern "C" int password_conversation(int num_msg, PAM_CONV_FUNC_CONST_PARM struct pam_message **msg,
++password_buf;
rfc1738_unescape(user);
rfc1738_unescape(password_buf);
- conv.appdata_ptr = (char *) password_buf; /* from buf above. not allocated */
+ conv.appdata_ptr = (char *) password_buf; /* from buf above. not allocated */
if (no_realm) {
/* Remove DOMAIN\.. and ...@domain from the user name in case the user
}
return 0;
}
+
#endif
/* AYJ: helper input buffer may be a lot larger than this used to expect... */
-#define MAXPWNAM 254
-#define MAXPASS 254
-#define MAXLINE 254
+#define MAXPWNAM 254
+#define MAXPASS 254
+#define MAXLINE 254
static void md5_calc(uint8_t out[16], void *in, size_t len);
}
FD_ZERO(&readfds);
FD_SET(socket_fd, &readfds);
- if (select(socket_fd + 1, &readfds, NULL, NULL, &tv) == 0) /* Select timeout */
+ if (select(socket_fd + 1, &readfds, NULL, NULL, &tv) == 0) /* Select timeout */
break;
salen = sizeof(saremote);
len = recvfrom(socket_fd, recv_buffer, sizeof(i_recv_buffer),
close(sockfd);
exit(1);
}
+
// 2008-05-14: rename to radius-util.* to avoid name clashes with squid util.*
/*
*
- * RADIUS
- * Remote Authentication Dial In User Service
+ * RADIUS
+ * Remote Authentication Dial In User Service
*
*
- * Livingston Enterprises, Inc.
- * 6920 Koll Center Parkway
- * Pleasanton, CA 94566
+ * Livingston Enterprises, Inc.
+ * 6920 Koll Center Parkway
+ * Pleasanton, CA 94566
*
- * Copyright 1992 Livingston Enterprises, Inc.
- * Copyright 1997 Cistron Internet Services B.V.
+ * Copyright 1992 Livingston Enterprises, Inc.
+ * Copyright 1997 Cistron Internet Services B.V.
*
- * Permission to use, copy, modify, and distribute this software for any
- * purpose and without fee is hereby granted, provided that this
- * copyright and permission notice appear on all copies and supporting
- * documentation, the name of Livingston Enterprises, Inc. not be used
- * in advertising or publicity pertaining to distribution of the
- * program without specific prior permission, and notice be given
- * in supporting documentation that copying and distribution is by
- * permission of Livingston Enterprises, Inc.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that this
+ * copyright and permission notice appear on all copies and supporting
+ * documentation, the name of Livingston Enterprises, Inc. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * program without specific prior permission, and notice be given
+ * in supporting documentation that copying and distribution is by
+ * permission of Livingston Enterprises, Inc.
*
- * Livingston Enterprises, Inc. makes no representations about
- * the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
+ * Livingston Enterprises, Inc. makes no representations about
+ * the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
*
*/
/*
- * util.c Miscellanous generic functions.
+ * util.c Miscellanous generic functions.
*
*/
#endif
/*
- * Check for valid IP address in standard dot notation.
+ * Check for valid IP address in standard dot notation.
*/
static int good_ipaddr(char *addr)
{
- int dot_count;
- int digit_count;
+ int dot_count;
+ int digit_count;
dot_count = 0;
digit_count = 0;
}
/*
- * Return an IP address in host long notation from
- * one supplied in standard dot notation.
+ * Return an IP address in host long notation from
+ * one supplied in standard dot notation.
*/
static uint32_t ipstr2long(char *ip_str)
{
- char buf[6];
- char *ptr;
- int i;
- int count;
- uint32_t ipaddr;
- int cur_byte;
+ char buf[6];
+ char *ptr;
+ int i;
+ int count;
+ uint32_t ipaddr;
+ int cur_byte;
ipaddr = (uint32_t)0;
for (i = 0; i < 4; ++i) {
}
/*
- * Return an IP address in host long notation from a host
- * name or address in dot notation.
+ * Return an IP address in host long notation from a host
+ * name or address in dot notation.
*/
uint32_t get_ipaddr(char *host)
{
- struct hostent *hp;
+ struct hostent *hp;
if (good_ipaddr(host) == 0) {
return(ipstr2long(host));
}
return(ntohl(*(uint32_t *)hp->h_addr));
}
+
#include "util.h"
/* util.c */
-uint32_t get_ipaddr (char *);
+uint32_t get_ipaddr (char *);
+
/*
*
- * RADIUS
- * Remote Authentication Dial In User Service
+ * RADIUS
+ * Remote Authentication Dial In User Service
*
*
- * Livingston Enterprises, Inc.
- * 6920 Koll Center Parkway
- * Pleasanton, CA 94566
+ * Livingston Enterprises, Inc.
+ * 6920 Koll Center Parkway
+ * Pleasanton, CA 94566
*
- * Copyright 1992 Livingston Enterprises, Inc.
+ * Copyright 1992 Livingston Enterprises, Inc.
*
- * Permission to use, copy, modify, and distribute this software for any
- * purpose and without fee is hereby granted, provided that this
- * copyright and permission notice appear on all copies and supporting
- * documentation, the name of Livingston Enterprises, Inc. not be used
- * in advertising or publicity pertaining to distribution of the
- * program without specific prior permission, and notice be given
- * in supporting documentation that copying and distribution is by
- * permission of Livingston Enterprises, Inc.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose and without fee is hereby granted, provided that this
+ * copyright and permission notice appear on all copies and supporting
+ * documentation, the name of Livingston Enterprises, Inc. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * program without specific prior permission, and notice be given
+ * in supporting documentation that copying and distribution is by
+ * permission of Livingston Enterprises, Inc.
*
- * Livingston Enterprises, Inc. makes no representations about
- * the suitability of this software for any purpose. It is
- * provided "as is" without express or implied warranty.
+ * Livingston Enterprises, Inc. makes no representations about
+ * the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
*
*/
/*
- * @(#)radius.h 2.0 03-Aug-1996
+ * @(#)radius.h 2.0 03-Aug-1996
*/
-#define AUTH_VECTOR_LEN 16
-#define AUTH_PASS_LEN 16
-#define AUTH_STRING_LEN 128 /* maximum of 254 */
+#define AUTH_VECTOR_LEN 16
+#define AUTH_PASS_LEN 16
+#define AUTH_STRING_LEN 128 /* maximum of 254 */
typedef struct pw_auth_hdr {
- u_char code;
- u_char id;
- uint16_t length;
- u_char vector[AUTH_VECTOR_LEN];
- u_char data[2];
+ u_char code;
+ u_char id;
+ uint16_t length;
+ u_char vector[AUTH_VECTOR_LEN];
+ u_char data[2];
} AUTH_HDR;
-#define AUTH_HDR_LEN 20
-#define CHAP_VALUE_LENGTH 16
-
-#define PW_AUTH_UDP_PORT 1812
-#define PW_ACCT_UDP_PORT 1813
-
-#define VENDORPEC_USR 429
-
-#define PW_TYPE_STRING 0
-#define PW_TYPE_INTEGER 1
-#define PW_TYPE_IPADDR 2
-#define PW_TYPE_DATE 3
-
-#define PW_AUTHENTICATION_REQUEST 1
-#define PW_AUTHENTICATION_ACK 2
-#define PW_AUTHENTICATION_REJECT 3
-#define PW_ACCOUNTING_REQUEST 4
-#define PW_ACCOUNTING_RESPONSE 5
-#define PW_ACCOUNTING_STATUS 6
-#define PW_PASSWORD_REQUEST 7
-#define PW_PASSWORD_ACK 8
-#define PW_PASSWORD_REJECT 9
-#define PW_ACCOUNTING_MESSAGE 10
-#define PW_ACCESS_CHALLENGE 11
-
-#define PW_USER_NAME 1
-#define PW_PASSWORD 2
-#define PW_CHAP_PASSWORD 3
-#define PW_NAS_IP_ADDRESS 4
-#define PW_NAS_PORT_ID 5
-#define PW_SERVICE_TYPE 6
-#define PW_FRAMED_PROTOCOL 7
-#define PW_FRAMED_IP_ADDRESS 8
-#define PW_FRAMED_IP_NETMASK 9
-#define PW_FRAMED_ROUTING 10
-#define PW_FILTER_ID 11
-#define PW_FRAMED_MTU 12
-#define PW_FRAMED_COMPRESSION 13
-#define PW_LOGIN_IP_HOST 14
-#define PW_LOGIN_SERVICE 15
-#define PW_LOGIN_TCP_PORT 16
-#define PW_OLD_PASSWORD 17
-#define PW_REPLY_MESSAGE 18
-#define PW_CALLBACK_NUMBER 19
-#define PW_CALLBACK_ID 20
-#define PW_EXPIRATION 21
-#define PW_FRAMED_ROUTE 22
-#define PW_FRAMED_IPXNET 23
-#define PW_STATE 24
-#define PW_CLASS 25
-#define PW_VENDOR_SPECIFIC 26
-#define PW_SESSION_TIMEOUT 27
-#define PW_IDLE_TIMEOUT 28
-#define PW_CALLED_STATION_ID 30
-#define PW_CALLING_STATION_ID 31
-#define PW_NAS_ID 32
-#define PW_PROXY_STATE 33
-
-#define PW_ACCT_STATUS_TYPE 40
-#define PW_ACCT_DELAY_TIME 41
-#define PW_ACCT_INPUT_OCTETS 42
-#define PW_ACCT_OUTPUT_OCTETS 43
-#define PW_ACCT_SESSION_ID 44
-#define PW_ACCT_AUTHENTIC 45
-#define PW_ACCT_SESSION_TIME 46
-#define PW_ACCT_INPUT_PACKETS 47
-#define PW_ACCT_OUTPUT_PACKETS 48
-
-#define PW_CHAP_CHALLENGE 60
-#define PW_NAS_PORT_TYPE 61
-#define PW_PORT_LIMIT 62
-#define PW_CONNECT_INFO 77
-
-#define PW_HUNTGROUP_NAME 221
-#define PW_AUTHTYPE 1000
-#define PW_PREFIX 1003
-#define PW_SUFFIX 1004
-#define PW_GROUP 1005
-#define PW_CRYPT_PASSWORD 1006
-#define PW_CONNECT_RATE 1007
-#define PW_USER_CATEGORY 1029
-#define PW_GROUP_NAME 1030
-#define PW_SIMULTANEOUS_USE 1034
-#define PW_STRIP_USERNAME 1035
-#define PW_FALL_THROUGH 1036
-#define PW_ADD_PORT_TO_IP_ADDRESS 1037
-#define PW_EXEC_PROGRAM 1038
-#define PW_EXEC_PROGRAM_WAIT 1039
-#define PW_HINT 1040
-#define PAM_AUTH_ATTR 1041
-#define PW_LOGIN_TIME 1042
+#define AUTH_HDR_LEN 20
+#define CHAP_VALUE_LENGTH 16
+
+#define PW_AUTH_UDP_PORT 1812
+#define PW_ACCT_UDP_PORT 1813
+
+#define VENDORPEC_USR 429
+
+#define PW_TYPE_STRING 0
+#define PW_TYPE_INTEGER 1
+#define PW_TYPE_IPADDR 2
+#define PW_TYPE_DATE 3
+
+#define PW_AUTHENTICATION_REQUEST 1
+#define PW_AUTHENTICATION_ACK 2
+#define PW_AUTHENTICATION_REJECT 3
+#define PW_ACCOUNTING_REQUEST 4
+#define PW_ACCOUNTING_RESPONSE 5
+#define PW_ACCOUNTING_STATUS 6
+#define PW_PASSWORD_REQUEST 7
+#define PW_PASSWORD_ACK 8
+#define PW_PASSWORD_REJECT 9
+#define PW_ACCOUNTING_MESSAGE 10
+#define PW_ACCESS_CHALLENGE 11
+
+#define PW_USER_NAME 1
+#define PW_PASSWORD 2
+#define PW_CHAP_PASSWORD 3
+#define PW_NAS_IP_ADDRESS 4
+#define PW_NAS_PORT_ID 5
+#define PW_SERVICE_TYPE 6
+#define PW_FRAMED_PROTOCOL 7
+#define PW_FRAMED_IP_ADDRESS 8
+#define PW_FRAMED_IP_NETMASK 9
+#define PW_FRAMED_ROUTING 10
+#define PW_FILTER_ID 11
+#define PW_FRAMED_MTU 12
+#define PW_FRAMED_COMPRESSION 13
+#define PW_LOGIN_IP_HOST 14
+#define PW_LOGIN_SERVICE 15
+#define PW_LOGIN_TCP_PORT 16
+#define PW_OLD_PASSWORD 17
+#define PW_REPLY_MESSAGE 18
+#define PW_CALLBACK_NUMBER 19
+#define PW_CALLBACK_ID 20
+#define PW_EXPIRATION 21
+#define PW_FRAMED_ROUTE 22
+#define PW_FRAMED_IPXNET 23
+#define PW_STATE 24
+#define PW_CLASS 25
+#define PW_VENDOR_SPECIFIC 26
+#define PW_SESSION_TIMEOUT 27
+#define PW_IDLE_TIMEOUT 28
+#define PW_CALLED_STATION_ID 30
+#define PW_CALLING_STATION_ID 31
+#define PW_NAS_ID 32
+#define PW_PROXY_STATE 33
+
+#define PW_ACCT_STATUS_TYPE 40
+#define PW_ACCT_DELAY_TIME 41
+#define PW_ACCT_INPUT_OCTETS 42
+#define PW_ACCT_OUTPUT_OCTETS 43
+#define PW_ACCT_SESSION_ID 44
+#define PW_ACCT_AUTHENTIC 45
+#define PW_ACCT_SESSION_TIME 46
+#define PW_ACCT_INPUT_PACKETS 47
+#define PW_ACCT_OUTPUT_PACKETS 48
+
+#define PW_CHAP_CHALLENGE 60
+#define PW_NAS_PORT_TYPE 61
+#define PW_PORT_LIMIT 62
+#define PW_CONNECT_INFO 77
+
+#define PW_HUNTGROUP_NAME 221
+#define PW_AUTHTYPE 1000
+#define PW_PREFIX 1003
+#define PW_SUFFIX 1004
+#define PW_GROUP 1005
+#define PW_CRYPT_PASSWORD 1006
+#define PW_CONNECT_RATE 1007
+#define PW_USER_CATEGORY 1029
+#define PW_GROUP_NAME 1030
+#define PW_SIMULTANEOUS_USE 1034
+#define PW_STRIP_USERNAME 1035
+#define PW_FALL_THROUGH 1036
+#define PW_ADD_PORT_TO_IP_ADDRESS 1037
+#define PW_EXEC_PROGRAM 1038
+#define PW_EXEC_PROGRAM_WAIT 1039
+#define PW_HINT 1040
+#define PAM_AUTH_ATTR 1041
+#define PW_LOGIN_TIME 1042
/*
- * INTEGER TRANSLATIONS
+ * INTEGER TRANSLATIONS
*/
-/* USER TYPES */
+/* USER TYPES */
-#define PW_LOGIN_USER 1
-#define PW_FRAMED_USER 2
-#define PW_DIALBACK_LOGIN_USER 3
-#define PW_DIALBACK_FRAMED_USER 4
+#define PW_LOGIN_USER 1
+#define PW_FRAMED_USER 2
+#define PW_DIALBACK_LOGIN_USER 3
+#define PW_DIALBACK_FRAMED_USER 4
-/* FRAMED PROTOCOLS */
+/* FRAMED PROTOCOLS */
-#define PW_PPP 1
-#define PW_SLIP 2
+#define PW_PPP 1
+#define PW_SLIP 2
-/* FRAMED ROUTING VALUES */
+/* FRAMED ROUTING VALUES */
-#define PW_NONE 0
-#define PW_BROADCAST 1
-#define PW_LISTEN 2
-#define PW_BROADCAST_LISTEN 3
+#define PW_NONE 0
+#define PW_BROADCAST 1
+#define PW_LISTEN 2
+#define PW_BROADCAST_LISTEN 3
-/* FRAMED COMPRESSION TYPES */
+/* FRAMED COMPRESSION TYPES */
-#define PW_VAN_JACOBSEN_TCP_IP 1
+#define PW_VAN_JACOBSEN_TCP_IP 1
-/* LOGIN SERVICES */
+/* LOGIN SERVICES */
-#define PW_TELNET 0
-#define PW_RLOGIN 1
-#define PW_TCP_CLEAR 2
-#define PW_PORTMASTER 3
+#define PW_TELNET 0
+#define PW_RLOGIN 1
+#define PW_TCP_CLEAR 2
+#define PW_PORTMASTER 3
-/* AUTHENTICATION LEVEL */
+/* AUTHENTICATION LEVEL */
-#define PW_AUTHTYPE_LOCAL 0
-#define PW_AUTHTYPE_SYSTEM 1
-#define PW_AUTHTYPE_SECURID 2
-#define PW_AUTHTYPE_CRYPT 3
-#define PW_AUTHTYPE_REJECT 4
-#define PW_AUTHTYPE_PAM 253
-#define PW_AUTHTYPE_ACCEPT 254
+#define PW_AUTHTYPE_LOCAL 0
+#define PW_AUTHTYPE_SYSTEM 1
+#define PW_AUTHTYPE_SECURID 2
+#define PW_AUTHTYPE_CRYPT 3
+#define PW_AUTHTYPE_REJECT 4
+#define PW_AUTHTYPE_PAM 253
+#define PW_AUTHTYPE_ACCEPT 254
-/* PORT TYPES */
-#define PW_NAS_PORT_ASYNC 0
-#define PW_NAS_PORT_SYNC 1
-#define PW_NAS_PORT_ISDN 2
-#define PW_NAS_PORT_ISDN_V120 3
-#define PW_NAS_PORT_ISDN_V110 4
+/* PORT TYPES */
+#define PW_NAS_PORT_ASYNC 0
+#define PW_NAS_PORT_SYNC 1
+#define PW_NAS_PORT_ISDN 2
+#define PW_NAS_PORT_ISDN_V120 3
+#define PW_NAS_PORT_ISDN_V110 4
-/* STATUS TYPES */
+/* STATUS TYPES */
-#define PW_STATUS_START 1
-#define PW_STATUS_STOP 2
-#define PW_STATUS_ALIVE 3
-#define PW_STATUS_ACCOUNTING_ON 7
-#define PW_STATUS_ACCOUNTING_OFF 8
+#define PW_STATUS_START 1
+#define PW_STATUS_STOP 2
+#define PW_STATUS_ALIVE 3
+#define PW_STATUS_ACCOUNTING_ON 7
+#define PW_STATUS_ACCOUNTING_OFF 8
#include <sasl.h>
#endif
-#define APP_NAME_SASL "basic_sasl_auth"
+#define APP_NAME_SASL "basic_sasl_auth"
int
main(int argc, char *argv[])
sasl_done();
return 0;
}
+
#include <cstring>
-#define NMB_UNICAST 1
-#define NMB_BROADCAST 2
+#define NMB_UNICAST 1
+#define NMB_BROADCAST 2
struct SMBDOMAIN {
- const char *name; /* domain name */
- const char *sname; /* match this with user input */
- const char *passthrough; /* pass-through authentication */
- const char *nmbaddr; /* name service address */
- int nmbcast; /* broadcast or unicast */
- char *authshare; /* share name of auth file */
- const char *authfile; /* pathname of auth file */
- struct SMBDOMAIN *next; /* linked list */
+ const char *name; /* domain name */
+ const char *sname; /* match this with user input */
+ const char *passthrough; /* pass-through authentication */
+ const char *nmbaddr; /* name service address */
+ int nmbcast; /* broadcast or unicast */
+ char *authshare; /* share name of auth file */
+ const char *authfile; /* pathname of auth file */
+ struct SMBDOMAIN *next; /* linked list */
};
struct SMBDOMAIN *firstdom = NULL;
SEND_OK("");
else
SEND_ERR("");
- } /* while (1) */
+ } /* while (1) */
return 0;
}
+
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "FATAL: Unknown option: -%c\n", opt);
usage(argv[0]);
}
if ((p = strchr(wstr, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if ((p = strchr(wstr, '\r')) != NULL)
- *p = '\0'; /* strip \r */
+ *p = '\0'; /* strip \r */
/* Clear any current settings */
username[0] = '\0';
password[0] = '\0';
- sscanf(wstr, "%s %s", username, password); /* Extract parameters */
+ sscanf(wstr, "%s %s", username, password); /* Extract parameters */
debug("Got %s from Squid\n", wstr);
}
return 0;
}
+
Valid_Group(char *UserName, char *Group)
{
int result = FALSE;
- WCHAR wszUserName[256]; // Unicode user name
- WCHAR wszGroup[256]; // Unicode Group
+ WCHAR wszUserName[256]; // Unicode user name
+ WCHAR wszGroup[256]; // Unicode Group
LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
}
return result;
}
+
extern const char * errormsg;
/* Debugging stuff */
-#if defined(__GNUC__) /* this is really a gcc-ism */
+#if defined(__GNUC__) /* this is really a gcc-ism */
#include <unistd.h>
static char *__foo;
#define debug(X...) if (debug_enabled) { \
int Valid_User(char *,char *, char *);
#endif
+
char *p;
if ((p = strchr(buf, '\n')) != NULL) {
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
buflen = p - buf; /* length is known already */
} else
buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */
debug("%s build " __DATE__ ", " __TIME__ " shutting down...\n", program_name);
exit(0);
}
+
struct passwd *pwd;
pwd = getpwnam(user);
if (pwd == NULL) {
- return 0; /* User does not exist */
+ return 0; /* User does not exist */
} else {
if (strcmp(pwd->pw_passwd, (char *) crypt(passwd, pwd->pw_passwd))) {
- return 2; /* Wrong password */
+ return 2; /* Wrong password */
} else {
- return 1; /* Authentication Sucessful */
+ return 1; /* Authentication Sucessful */
}
}
}
struct spwd *pwd;
pwd = getspnam(user);
if (pwd == NULL) {
- return passwd_auth(user, passwd); /* Fall back to passwd_auth */
+ return passwd_auth(user, passwd); /* Fall back to passwd_auth */
} else {
if (strcmp(pwd->sp_pwdp, crypt(passwd, pwd->sp_pwdp))) {
- return 2; /* Wrong password */
+ return 2; /* Wrong password */
} else {
- return 1; /* Authentication Sucessful */
+ return 1; /* Authentication Sucessful */
}
}
}
while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) {
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if ((user = strtok(buf, " ")) == NULL) {
SEND_ERR("No Username");
}
return 0;
}
+
* useful and shared between helpers.
*/
-#define HELPER_INPUT_BUFFER 8196
+#define HELPER_INPUT_BUFFER 8196
/* send OK result to Squid with a string parameter. */
-#define SEND_OK(x) fprintf(stdout, "OK %s\n",x)
+#define SEND_OK(x) fprintf(stdout, "OK %s\n",x)
/* send ERR result to Squid with a string parameter. */
-#define SEND_ERR(x) fprintf(stdout, "ERR %s\n",x)
+#define SEND_ERR(x) fprintf(stdout, "ERR %s\n",x)
/* send ERR result to Squid with a string parameter. */
-#define SEND_BH(x) fprintf(stdout, "BH %s\n",x)
+#define SEND_BH(x) fprintf(stdout, "BH %s\n",x)
/* send TT result to Squid with a string parameter. */
-#define SEND_TT(x) fprintf(stdout, "TT %s\n",x)
+#define SEND_TT(x) fprintf(stdout, "TT %s\n",x)
#endif /* __SQUID_HELPERS_DEFINES_H */
+
typedef void HHA1Creator(RequestData *);
#endif /* SQUID_DIGEST_COMMON_H_ */
+
char *p;
requestData->parsed = 0;
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
p = NULL;
requestData->channelId = strtoll(buf, &p, 10);
DoOneRequest(buf);
exit(0);
}
+
fprintf(stderr, "ERROR: Your LDAP library does not have URI support\n");
return 1;
#endif
- /* Fall thru to -h */
+ /* Fall thru to -h */
case 'h':
if (ldapServer) {
int len = strlen(ldapServer) + 1 + strlen(value) + 1;
}
}
+
extern int LDAPArguments(int argc, char **argv);
extern void LDAPHHA1(RequestData * requestData);
+
typedef void HHA1Creator(RequestData *);
#endif /* SQUID_DIGEST_COMMON_H_ */
+
char *p;
requestData->parsed = 0;
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
p = NULL;
requestData->channelId = strtoll(buf, &p, 10);
DoOneRequest(buf);
exit(0);
}
+
*
* Original copyright & license follows:
*
- * Copyright (C) Vince Brimhall 2004-2005
+ * Copyright (C) Vince Brimhall 2004-2005
*
* 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
#include "edir_ldapext.h"
-#define NMASLDAP_GET_LOGIN_CONFIG_REQUEST "2.16.840.1.113719.1.39.42.100.3"
-#define NMASLDAP_GET_LOGIN_CONFIG_RESPONSE "2.16.840.1.113719.1.39.42.100.4"
-#define NMASLDAP_SET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.11"
-#define NMASLDAP_SET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.12"
-#define NMASLDAP_GET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.13"
-#define NMASLDAP_GET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.14"
+#define NMASLDAP_GET_LOGIN_CONFIG_REQUEST "2.16.840.1.113719.1.39.42.100.3"
+#define NMASLDAP_GET_LOGIN_CONFIG_RESPONSE "2.16.840.1.113719.1.39.42.100.4"
+#define NMASLDAP_SET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.11"
+#define NMASLDAP_SET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.12"
+#define NMASLDAP_GET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.13"
+#define NMASLDAP_GET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.14"
-#define NMAS_LDAP_EXT_VERSION 1
+#define NMAS_LDAP_EXT_VERSION 1
-#define SMB_MALLOC_ARRAY(type, nelem) calloc(sizeof(type), nelem)
+#define SMB_MALLOC_ARRAY(type, nelem) calloc(sizeof(type), nelem)
#define DEBUG(level, args)
/**********************************************************************
unsigned int i;
unsigned int elemCnt = methodIDLen / sizeof(unsigned int);
- char *utf8ObjPtr=NULL;
+ char *utf8ObjPtr=NULL;
int utf8ObjSize = 0;
char *utf8TagPtr = NULL;
**********************************************************************/
static int getLoginConfig(
- LDAP *ld,
+ LDAP *ld,
char *objectDN,
unsigned int methodIDLen,
unsigned int *methodID,
**********************************************************************/
static int nmasldap_get_simple_pwd(
- LDAP *ld,
+ LDAP *ld,
char *objectDN,
- size_t pwdLen,
+ size_t pwdLen,
char *pwd )
{
int err = 0;
**********************************************************************/
static int nmasldap_get_password(
- LDAP *ld,
+ LDAP *ld,
char *objectDN,
- size_t *pwdSize, /* in bytes */
+ size_t *pwdSize, /* in bytes */
unsigned char *pwd )
{
int err = 0;
-/*\r
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors\r
- *\r
- * Squid software is distributed under GPLv2+ license and includes\r
- * contributions from numerous individuals and organizations.\r
- * Please see the COPYING and CONTRIBUTORS files for details.\r
- */\r
-\r
-int nds_get_password(LDAP *ld, char *object_dn, size_t * pwd_len, char *pwd);\r
+/*
+ * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+int nds_get_password(LDAP *ld, char *object_dn, size_t * pwd_len, char *pwd);
+
fprintf(stderr, "ERROR: Your LDAP library does not have URI support\n");
return 1;
#endif
- /* Fall thru to -h */
+ /* Fall thru to -h */
case 'h':
if (ldapServer) {
int len = strlen(ldapServer) + 1 + strlen(value) + 1;
}
}
+
#include "digest_common.h"
extern int LDAPArguments(int argc, char **argv);
extern void LDAPHHA1(RequestData * requestData);
+
typedef void HHA1Creator(RequestData *);
#endif /* SQUID_DIGEST_COMMON_H_ */
+
char *p;
requestData->parsed = 0;
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
p = NULL;
requestData->channelId = strtoll(buf, &p, 10);
DoOneRequest(buf);
return 0;
}
+
DigestCalcHA1("md5", requestData->user, requestData->realm, u->passwd, NULL, NULL, HA1, requestData->HHA1);
}
}
+
extern void TextArguments(int argc, char **argv);
extern void TextHHA1(RequestData * requestData);
+
static int
wcstrcmparray(const wchar_t * str, const char **array)
{
- WCHAR wszGroup[GNLEN + 1]; // Unicode Group
+ WCHAR wszGroup[GNLEN + 1]; // Unicode Group
while (*array) {
MultiByteToWideChar(CP_ACP, 0, *array,
{
int result = 0;
char *Domain_Separator;
- WCHAR wszUserName[UNLEN + 1]; /* Unicode user name */
+ WCHAR wszUserName[UNLEN + 1]; /* Unicode user name */
LPLOCALGROUP_USERS_INFO_0 pBuf;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
Valid_Global_Groups(char *UserName, const char **Groups)
{
int result = 0;
- WCHAR wszUser[DNLEN + UNLEN + 2]; /* Unicode user name */
+ WCHAR wszUser[DNLEN + UNLEN + 2]; /* Unicode user name */
char NTDomain[DNLEN + UNLEN + 2];
char *domain_qualify = NULL;
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "%s: FATAL: Unknown option: -%c. Exiting\n", program_name, opt);
usage(argv[0]);
exit(1);
- break; /* not reached */
+ break; /* not reached */
}
}
return;
const char *groups[512];
int n;
- if (argc > 0) { /* should always be true */
+ if (argc > 0) { /* should always be true */
program_name = strrchr(argv[0], '/');
if (program_name == NULL)
program_name = argv[0];
continue;
}
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if ((p = strchr(buf, '\r')) != NULL)
- *p = '\0'; /* strip \r */
+ *p = '\0'; /* strip \r */
debug("Got '%s' from Squid (length: %d).\n", buf, strlen(buf));
}
return 0;
}
+
fprintf(stderr, "FATAL: Your LDAP library does not have URI support\n");
exit(1);
#endif
- /* Fall thru to -h */
+ /* Fall thru to -h */
case 'h':
if (ldapServer) {
int len = strlen(ldapServer) + 1 + strlen(value) + 1;
return 0;
}
+
static int
wcstrcmparray(const wchar_t * str, const char **array)
{
- WCHAR wszGroup[GNLEN + 1]; // Unicode Group
+ WCHAR wszGroup[GNLEN + 1]; // Unicode Group
while (*array) {
MultiByteToWideChar(CP_ACP, 0, *array,
{
int result = 0;
char *Domain_Separator;
- WCHAR wszUserName[UNLEN + 1]; // Unicode user name
+ WCHAR wszUserName[UNLEN + 1]; // Unicode user name
LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
Valid_Global_Groups(char *UserName, const char **Groups)
{
int result = 0;
- WCHAR wszUserName[UNLEN + 1]; // Unicode user name
+ WCHAR wszUserName[UNLEN + 1]; // Unicode user name
- WCHAR wszLocalDomain[DNLEN + 1]; // Unicode Local Domain
+ WCHAR wszLocalDomain[DNLEN + 1]; // Unicode Local Domain
- WCHAR wszUserDomain[DNLEN + 1]; // Unicode User Domain
+ WCHAR wszUserDomain[DNLEN + 1]; // Unicode User Domain
char NTDomain[DNLEN + UNLEN + 2];
char *domain_qualify;
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "%s: FATAL: Unknown option: -%c. Exiting\n", program_name, opt);
usage(argv[0]);
exit(1);
- break; /* not reached */
+ break; /* not reached */
}
}
return;
const char *groups[512];
int n;
- if (argc > 0) { /* should always be true */
+ if (argc > 0) { /* should always be true */
program_name = strrchr(argv[0], '/');
if (program_name == NULL)
program_name = argv[0];
continue;
}
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
if ((p = strchr(buf, '\r')) != NULL)
- *p = '\0'; /* strip \r */
+ *p = '\0'; /* strip \r */
debug("Got '%s' from Squid (length: %d).\n", buf, strlen(buf));
}
return 0;
}
+
#include "rfc1738.h"
#include "util.h"
-#define EDUI_PROGRAM_NAME "ext_edirectory_userip_acl"
-#define EDUI_PROGRAM_VERSION "2.1"
+#define EDUI_PROGRAM_NAME "ext_edirectory_userip_acl"
+#define EDUI_PROGRAM_VERSION "2.1"
/* System includes */
#ifndef _GNU_SOURCE
#endif
#ifdef HELPER_INPUT_BUFFER
-#define EDUI_MAXLEN HELPER_INPUT_BUFFER
+#define EDUI_MAXLEN HELPER_INPUT_BUFFER
#else
-#define EDUI_MAXLEN 4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */
+#define EDUI_MAXLEN 4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */
#endif
/* ldap compile options */
#endif
/* conf_t - status flags */
-#define EDUI_MODE_INIT 0x01
-#define EDUI_MODE_DEBUG 0x02 /* Replace with Squid's debug system */
-#define EDUI_MODE_TLS 0x04
-#define EDUI_MODE_IPV4 0x08
-#define EDUI_MODE_IPV6 0x10
-#define EDUI_MODE_GROUP 0x20 /* Group is REQUIRED */
-#define EDUI_MODE_PERSIST 0x40 /* Persistent LDAP connections */
-#define EDUI_MODE_KILL 0x80
+#define EDUI_MODE_INIT 0x01
+#define EDUI_MODE_DEBUG 0x02 /* Replace with Squid's debug system */
+#define EDUI_MODE_TLS 0x04
+#define EDUI_MODE_IPV4 0x08
+#define EDUI_MODE_IPV6 0x10
+#define EDUI_MODE_GROUP 0x20 /* Group is REQUIRED */
+#define EDUI_MODE_PERSIST 0x40 /* Persistent LDAP connections */
+#define EDUI_MODE_KILL 0x80
/* conf_t - Program configuration struct typedef */
typedef struct {
char attrib[EDUI_MAXLEN];
char dn[EDUI_MAXLEN];
char passwd[EDUI_MAXLEN];
- char search_filter[EDUI_MAXLEN]; /* Base search_filter that gets copied to edui_ldap_t */
+ char search_filter[EDUI_MAXLEN]; /* Base search_filter that gets copied to edui_ldap_t */
int ver;
int scope;
int port;
char host[EDUI_MAXLEN];
char dn[EDUI_MAXLEN];
char passwd[EDUI_MAXLEN];
- char search_filter[EDUI_MAXLEN]; /* search_group gets appended here by GroupLDAP */
- char search_ip[EDUI_MAXLEN]; /* Could be IPv4 or IPv6, set by ConvertIP */
+ char search_filter[EDUI_MAXLEN]; /* search_group gets appended here by GroupLDAP */
+ char search_ip[EDUI_MAXLEN]; /* Could be IPv4 or IPv6, set by ConvertIP */
char userid[EDUI_MAXLEN]; /* Resulting userid */
unsigned int status;
unsigned int port;
- unsigned long type; /* Type of bind */
+ unsigned long type; /* Type of bind */
int ver;
int scope;
- int err; /* LDAP error code */
+ int err; /* LDAP error code */
time_t idle_time;
int num_ent; /* Number of entry's found via search */
int num_val; /* Number of value's found via getval */
l->port = 0;
l->scope = -1;
l->type = 0;
- l->err = -1; /* Set error to LDAP_SUCCESS by default */
+ l->err = -1; /* Set error to LDAP_SUCCESS by default */
l->ver = 0;
l->idle_time = 0;
- l->num_ent = 0; /* Number of entries in l->lm */
- l->num_val = 0; /* Number of entries in l->val */
+ l->num_ent = 0; /* Number of entries in l->lm */
+ l->num_val = 0; /* Number of entries in l->val */
/* Set default settings from conf */
if (edui_conf.basedn[0] != '\0')
OpenLDAP(edui_ldap_t *l, char *h, unsigned int p)
{
if ((l == NULL) || (h == NULL)) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized, or might be in use */
- if (l->status & LDAP_OPEN_S) return LDAP_ERR_OPEN; /* Already open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized, or might be in use */
+ if (l->status & LDAP_OPEN_S) return LDAP_ERR_OPEN; /* Already open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
xstrncpy(l->host, h, sizeof(l->host));
if (p > 0)
l->port = p;
else
- l->port = LDAP_PORT; /* Default is port 389 */
+ l->port = LDAP_PORT; /* Default is port 389 */
#ifdef NETSCAPE_SSL
if (l->port == LDAPS_PORT)
- l->status |= (LDAP_SSL_S | LDAP_TLS_S); /* SSL Port: 636 */
+ l->status |= (LDAP_SSL_S | LDAP_TLS_S); /* SSL Port: 636 */
#endif
#ifdef USE_LDAP_INIT
#endif
if (l->lp == NULL) {
l->err = LDAP_CONNECT_ERROR;
- return LDAP_ERR_CONNECT; /* Unable to connect */
+ return LDAP_ERR_CONNECT; /* Unable to connect */
} else {
/* set status */
// l->status &= ~(LDAP_INIT_S);
int s;
if (l == NULL) return LDAP_ERR_NULL;
if (l->lp == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Connection not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Connection not open */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Connection not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Connection not open */
if (l->lm != NULL) {
ldap_msgfree(l->lm);
if (s == LDAP_SUCCESS) {
l->status = LDAP_INIT_S;
l->idle_time = 0;
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
if (l == NULL) return LDAP_ERR_NULL;
if ((v > 3) || (v < 1)) return LDAP_ERR_PARAM;
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
/* set version */
x = ldap_set_option(l->lp, LDAP_OPT_PROTOCOL_VERSION, &v);
if (x == LDAP_SUCCESS) {
l->ver = v;
- l->err = x; /* Set LDAP error code */
+ l->err = x; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = x; /* Set LDAP error code */
+ l->err = x; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
{
int s;
if (l == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
- if (l->lp == NULL) return LDAP_ERR_POINTER; /* Error */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (l->lp == NULL) return LDAP_ERR_POINTER; /* Error */
/* Copy details - dn and pw CAN be NULL for anonymous and/or TLS */
if (dn != NULL) {
break;
#endif
#ifdef LDAP_AUTH_TLS
- case LDAP_AUTH_TLS: /* Added for chicken switch to TLS-enabled without using SSL */
+ case LDAP_AUTH_TLS: /* Added for chicken switch to TLS-enabled without using SSL */
l->type = t;
break;
#endif
default:
l->type = LDAP_AUTH_NONE;
- break; /* Default to anonymous bind */
+ break; /* Default to anonymous bind */
}
/* Bind */
#endif
s = ldap_bind_s(l->lp, l->dn, l->passwd, l->type);
if (s == LDAP_SUCCESS) {
- l->status |= LDAP_BIND_S; /* Success */
- l->err = s; /* Set LDAP error code */
+ l->status |= LDAP_BIND_S; /* Success */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
void *y, *z;
size_t s;
long x;
- int i, j, t, swi; /* IPv6 "::" cut over toggle */
+ int i, j, t, swi; /* IPv6 "::" cut over toggle */
if (l == NULL) return LDAP_ERR_NULL;
if (ip == NULL) return LDAP_ERR_PARAM;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
y = memchr((void *)ip, ':', EDUI_MAXLEN);
z = memchr((void *)ip, '.', EDUI_MAXLEN);
*(obj) = '\0';
/* StringSplit() will zero out bufa & obj at each call */
memset(l->search_ip, '\0', sizeof(l->search_ip));
- xstrncpy(bufa, ip, sizeof(bufa)); /* To avoid segfaults, use bufa instead of ip */
+ xstrncpy(bufa, ip, sizeof(bufa)); /* To avoid segfaults, use bufa instead of ip */
swi = 0;
if (l->status & LDAP_IPV6_S) {
/* Search for :: in string */
/* bufa starts with a ::, so just copy and clear */
xstrncpy(bufb, bufa, sizeof(bufb));
*(bufa) = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
} else if ((bufa[0] == ':') && (bufa[1] != ':')) {
/* bufa starts with a :, a typo so just fill in a ':', cat and clear */
bufb[0] = ':';
strncat(bufb, bufa, strlen(bufa));
*(bufa) = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
} else {
p = strstr(bufa, "::");
if (p != NULL) {
memcpy(bufb, p, i);
*p = '\0';
bufb[i] = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
}
}
}
errno = 0;
x = strtol(obj, (char **)NULL, 10);
if (((x < 0) || (x > 255)) || ((errno != 0) && (x == 0)) || ((obj[0] != '0') && (x == 0)))
- return LDAP_ERR_OOB; /* Out of bounds -- Invalid address */
+ return LDAP_ERR_OOB; /* Out of bounds -- Invalid address */
memset(hexc, '\0', sizeof(hexc));
int hlen = snprintf(hexc, sizeof(hexc), "%02X", (int)x);
strncat(l->search_ip, hexc, hlen);
} else
- break; /* reached end of octet */
+ break; /* reached end of octet */
} else if (l->status & LDAP_IPV6_S) {
/* Break down IPv6 address */
if (swi > 1)
- t = StringSplit(bufb, ':', obj, sizeof(obj)); /* After "::" */
+ t = StringSplit(bufb, ':', obj, sizeof(obj)); /* After "::" */
else
- t = StringSplit(bufa, ':', obj, sizeof(obj)); /* Before "::" */
+ t = StringSplit(bufa, ':', obj, sizeof(obj)); /* Before "::" */
/* Convert octet by size (t) - and fill 0's */
- switch (t) { /* IPv6 is already in HEX, copy contents */
+ switch (t) { /* IPv6 is already in HEX, copy contents */
case 4:
hexc[0] = (char) toupper((int)obj[0]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[1]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
hexc[0] = (char) toupper((int)obj[2]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[3]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[1] = (char) toupper((int)obj[0]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
hexc[0] = (char) toupper((int)obj[1]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[2]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[0] = (char) toupper((int)obj[0]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[1]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[1] = (char) toupper((int)obj[0]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
if (bufb[i] == ':')
++j;
}
- --j; /* Preceding "::" doesn't count */
- t = 8 - (strlen(l->search_ip) / 4) - j; /* Remainder */
+ --j; /* Preceding "::" doesn't count */
+ t = 8 - (strlen(l->search_ip) / 4) - j; /* Remainder */
if (t > 0) {
for (i = 0; i < t; ++i)
strncat(l->search_ip, "0000", 4);
int swi;
char bufa[EDUI_MAXLEN], bufb[EDUI_MAXLEN], bufc[EDUI_MAXLEN], bufd[EDUI_MAXLEN], bufg[EDUI_MAXLEN];
if (l == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not Bound */
- if (l->search_ip[0] == '\0') return LDAP_ERR_DATA; /* Search IP is required */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not Bound */
+ if (l->search_ip[0] == '\0') return LDAP_ERR_DATA; /* Search IP is required */
/* Zero out if not already */
memset(bufa, '\0', sizeof(bufa));
int s;
char ft[EDUI_MAXLEN];
if (l == NULL) return LDAP_ERR_NULL;
- if ((scope < 0) || (filter == NULL)) return LDAP_ERR_PARAM; /* If attrs is NULL, then all attrs will return */
+ if ((scope < 0) || (filter == NULL)) return LDAP_ERR_PARAM; /* If attrs is NULL, then all attrs will return */
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
- if (l->status & LDAP_SEARCH_S) return LDAP_ERR_SEARCHED; /* Already searching */
- if (l->basedn[0] == '\0') return LDAP_ERR_DATA; /* We require a basedn */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (l->status & LDAP_SEARCH_S) return LDAP_ERR_SEARCHED; /* Already searching */
+ if (l->basedn[0] == '\0') return LDAP_ERR_DATA; /* We require a basedn */
if (l->lm != NULL)
- ldap_msgfree(l->lm); /* Make sure l->lm is empty */
+ ldap_msgfree(l->lm); /* Make sure l->lm is empty */
xstrncpy(ft, filter, sizeof(ft));
break;
}
if (s == LDAP_SUCCESS) {
- l->status |= (LDAP_SEARCH_S); /* Mark as searched */
+ l->status |= (LDAP_SEARCH_S); /* Mark as searched */
l->err = s;
- l->idle_time = 0; /* Connection in use, reset idle timer */
- l->num_ent = ldap_count_entries(l->lp, l->lm); /* Counted */
+ l->idle_time = 0; /* Connection in use, reset idle timer */
+ l->num_ent = ldap_count_entries(l->lp, l->lm); /* Counted */
return LDAP_ERR_SUCCESS;
} else {
l->err = s;
LDAPMessage *ent;
if (l == NULL) return LDAP_ERR_NULL;
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
- if (!(l->status & LDAP_SEARCH_S)) return LDAP_ERR_NOT_SEARCHED; /* Not searched */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (!(l->status & LDAP_SEARCH_S)) return LDAP_ERR_NOT_SEARCHED; /* Not searched */
if (l->num_ent <= 0) {
debug("l->num_ent: %d\n", l->num_ent);
- return LDAP_ERR_DATA; /* No entries found */
+ return LDAP_ERR_DATA; /* No entries found */
}
if (l->val != NULL)
- ldap_value_free_len(l->val); /* Clear data before populating */
+ ldap_value_free_len(l->val); /* Clear data before populating */
l->num_val = 0;
if (l->status & LDAP_VAL_S)
- l->status &= ~(LDAP_VAL_S); /* Clear VAL bit */
+ l->status &= ~(LDAP_VAL_S); /* Clear VAL bit */
if (edui_conf.attrib[0] == '\0')
- xstrncpy(edui_conf.attrib, "cn", sizeof(edui_conf.attrib)); /* Make sure edui_conf.attrib is set */
+ xstrncpy(edui_conf.attrib, "cn", sizeof(edui_conf.attrib)); /* Make sure edui_conf.attrib is set */
/* Sift through entries */
struct berval **ber = NULL;
for (ent = ldap_first_entry(l->lp, l->lm); ent != NULL; ent = ldap_next_entry(l->lp, ent)) {
l->val = ldap_get_values_len(l->lp, ent, "networkAddress");
- ber = ldap_get_values_len(l->lp, ent, edui_conf.attrib); /* edui_conf.attrib is the <userid> mapping */
+ ber = ldap_get_values_len(l->lp, ent, edui_conf.attrib); /* edui_conf.attrib is the <userid> mapping */
if (l->val != NULL) {
- x = ldap_count_values_len(l->val); /* We got x values ... */
+ x = ldap_count_values_len(l->val); /* We got x values ... */
l->num_val = x;
if (x > 0) {
/* Display all values */
memcpy(bufa, l->val[i]->bv_val, j);
z = BinarySplit(bufa, j, '#', bufb, sizeof(bufb));
/* BINARY DEBUGGING *
- local_printfx("value[%" PRIuSIZE "]: BinarySplit(", (size_t) i);
- for (k = 0; k < z; ++k) {
- c = (int) bufb[k];
- if (c < 0)
- c = c + 256;
- local_printfx("%02X", c);
- }
- local_printfx(", ");
- for (k = 0; k < (j - z - 1); ++k) {
- c = (int) bufa[k];
- if (c < 0)
- c = c + 256;
- local_printfx("%02X", c);
- }
- local_printfx("): %" PRIuSIZE "\n", (size_t) z);
+ local_printfx("value[%" PRIuSIZE "]: BinarySplit(", (size_t) i);
+ for (k = 0; k < z; ++k) {
+ c = (int) bufb[k];
+ if (c < 0)
+ c = c + 256;
+ local_printfx("%02X", c);
+ }
+ local_printfx(", ");
+ for (k = 0; k < (j - z - 1); ++k) {
+ c = (int) bufa[k];
+ if (c < 0)
+ c = c + 256;
+ local_printfx("%02X", c);
+ }
+ local_printfx("): %" PRIuSIZE "\n", (size_t) z);
* BINARY DEBUGGING */
z = j - z - 1;
j = atoi(bufb);
/* IPv4 address (eDirectory 8.7 and below) */
/* bufa is the address, just compare it */
if (!(l->status & LDAP_IPV4_S) || (l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv4 */
+ break; /* Not looking for IPv4 */
for (k = 0; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
} else if ((j == 8) || (j == 9)) {
/* IPv4 (UDP/TCP) address (eDirectory 8.8 and higher) */
/* bufa + 2 is the address (skip 2 digit port) */
if (!(l->status & LDAP_IPV4_S) || (l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv4 */
+ break; /* Not looking for IPv4 */
for (k = 2; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
} else if ((j == 10) || (j == 11)) {
/* IPv6 (UDP/TCP) address (eDirectory 8.8 and higher) */
/* bufa + 2 is the address (skip 2 digit port) */
if (!(l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv6 */
+ break; /* Not looking for IPv6 */
for (k = 2; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
}
-// else {
+// else {
/* Others are unsupported */
// }
}
l->num_val = 0;
l->err = LDAP_NO_SUCH_OBJECT;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_NOTFOUND; /* Not found ... Sorry :) */
+ return LDAP_ERR_NOTFOUND; /* Not found ... Sorry :) */
}
/*
return 1;
case 'd':
if (!(edui_conf.mode & EDUI_MODE_DEBUG))
- edui_conf.mode |= EDUI_MODE_DEBUG; /* Don't set mode more than once */
- debug_enabled = 1; /* Official Squid-3 Debug Mode */
+ edui_conf.mode |= EDUI_MODE_DEBUG; /* Don't set mode more than once */
+ debug_enabled = 1; /* Official Squid-3 Debug Mode */
break;
case '4':
if (!(edui_conf.mode & EDUI_MODE_IPV4) || !(edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode |= EDUI_MODE_IPV4; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_IPV4; /* Don't set mode more than once */
break;
case '6':
if (!(edui_conf.mode & EDUI_MODE_IPV4) || !(edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode |= EDUI_MODE_IPV6; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_IPV6; /* Don't set mode more than once */
break;
case 'Z':
if (!(edui_conf.mode & EDUI_MODE_TLS))
- edui_conf.mode |= EDUI_MODE_TLS; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_TLS; /* Don't set mode more than once */
break;
case 'P':
if (!(edui_conf.mode & EDUI_MODE_PERSIST))
- edui_conf.mode |= EDUI_MODE_PERSIST; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_PERSIST; /* Don't set mode more than once */
break;
case 'v':
- ++i; /* Set LDAP version */
+ ++i; /* Set LDAP version */
if (argv[i] != NULL) {
edui_conf.ver = atoi(argv[i]);
if (edui_conf.ver < 1)
}
break;
case 't':
- ++i; /* Set Persistent timeout */
+ ++i; /* Set Persistent timeout */
if (argv[i] != NULL) {
edui_conf.persist_timeout = atoi(argv[i]);
if (edui_conf.persist_timeout < 0)
}
break;
case 'b':
- ++i; /* Set Base DN */
+ ++i; /* Set Base DN */
if (argv[i] != NULL)
xstrncpy(edui_conf.basedn, argv[i], sizeof(edui_conf.basedn));
else {
}
break;
case 'H':
- ++i; /* Set Hostname */
+ ++i; /* Set Hostname */
if (argv[i] != NULL)
xstrncpy(edui_conf.host, argv[i], sizeof(edui_conf.host));
else {
}
break;
case 'p':
- ++i; /* Set port */
+ ++i; /* Set port */
if (argv[i] != NULL)
edui_conf.port = atoi(argv[i]);
else {
}
break;
case 'D':
- ++i; /* Set Bind DN */
+ ++i; /* Set Bind DN */
if (argv[i] != NULL)
xstrncpy(edui_conf.dn, argv[i], sizeof(edui_conf.dn));
else {
}
break;
case 'W':
- ++i; /* Set Bind PWD */
+ ++i; /* Set Bind PWD */
if (argv[i] != NULL)
xstrncpy(edui_conf.passwd, argv[i], sizeof(edui_conf.passwd));
else {
}
break;
case 'F':
- ++i; /* Set Search Filter */
+ ++i; /* Set Search Filter */
if (argv[i] != NULL)
xstrncpy(edui_conf.search_filter, argv[i], sizeof(edui_conf.search_filter));
else {
break;
case 'G':
if (!(edui_conf.mode & EDUI_MODE_GROUP))
- edui_conf.mode |= EDUI_MODE_GROUP; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_GROUP; /* Don't set mode more than once */
break;
case 's':
- ++i; /* Set Scope Level */
+ ++i; /* Set Scope Level */
if (argv[i] != NULL) {
if (!strncmp(argv[i], "base", 4))
edui_conf.scope = 0;
else if (!strncmp(argv[i], "sub", 4))
edui_conf.scope = 2;
else
- edui_conf.scope = 1; /* Default is 'one' */
+ edui_conf.scope = 1; /* Default is 'one' */
} else {
local_printfx("No parameters given for 's'.\n");
DisplayUsage();
}
break;
case 'u':
- ++i; /* Set Search Attribute */
+ ++i; /* Set Search Attribute */
if (argv[i] != NULL) {
xstrncpy(edui_conf.attrib, argv[i], sizeof(edui_conf.attrib));
} else {
return 1;
}
break;
- case '-': /* We got a second '-' ... ignore */
+ case '-': /* We got a second '-' ... ignore */
break;
default:
local_printfx("Invalid parameter - '%c'.\n", argv[i][j]);
}
/* Set predefined required paremeters if none are given, localhost:LDAP_PORT, etc */
- if (edui_conf.host[0] == '\0') /* Default to localhost */
+ if (edui_conf.host[0] == '\0') /* Default to localhost */
xstrncpy(edui_conf.host, "localhost", sizeof(edui_conf.host));
if (edui_conf.port < 0)
- edui_conf.port = LDAP_PORT; /* Default: LDAP_PORT */
+ edui_conf.port = LDAP_PORT; /* Default: LDAP_PORT */
if ((edui_conf.mode & EDUI_MODE_IPV4) && (edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode &= ~(EDUI_MODE_IPV6); /* Default to IPv4 */
+ edui_conf.mode &= ~(EDUI_MODE_IPV6); /* Default to IPv4 */
if (edui_conf.ver < 0)
edui_conf.ver = 2;
if (!(edui_conf.mode & EDUI_MODE_TLS))
- edui_conf.mode |= EDUI_MODE_TLS; /* eDirectory requires TLS mode */
+ edui_conf.mode |= EDUI_MODE_TLS; /* eDirectory requires TLS mode */
if ((edui_conf.mode & EDUI_MODE_TLS) && (edui_conf.ver < 3))
- edui_conf.ver = 3; /* TLS requires version 3 */
+ edui_conf.ver = 3; /* TLS requires version 3 */
if (edui_conf.persist_timeout < 0)
- edui_conf.persist_timeout = 600; /* Default: 600 seconds (10 minutes) */
+ edui_conf.persist_timeout = 600; /* Default: 600 seconds (10 minutes) */
if (edui_conf.scope < 0)
- edui_conf.scope = 1; /* Default: one */
+ edui_conf.scope = 1; /* Default: one */
if (edui_conf.search_filter[0] == '\0')
xstrncpy(edui_conf.search_filter, "(&(objectclass=User)(networkAddress=*))", sizeof(edui_conf.search_filter));
if (edui_conf.attrib[0] == '\0')
if (!(edui_ldap.status & LDAP_INIT_S)) {
InitLDAP(&edui_ldap);
debug("InitLDAP() -> %s\n", ErrLDAP(LDAP_ERR_SUCCESS));
- if (edui_conf.mode & EDUI_MODE_PERSIST) /* Setup persistant mode */
+ if (edui_conf.mode & EDUI_MODE_PERSIST) /* Setup persistant mode */
edui_ldap.status |= LDAP_PERSIST_S;
}
if ((edui_ldap.status & LDAP_IDLE_S) && (edui_elap > 0)) {
local_printfx("ERR message=\"(SearchIPLDAP: %s)\"\n", ErrLDAP(x));
} else {
debug("SearchIPLDAP(-, %s) -> %s\n", edui_ldap.userid, ErrLDAP(x));
- local_printfx("OK user=%s\n", edui_ldap.userid); /* Got userid --> OK user=<userid> */
+ local_printfx("OK user=%s\n", edui_ldap.userid); /* Got userid --> OK user=<userid> */
}
}
/* Clear for next query */
local_printfx("ERR message=\"(SearchIPLDAP: %s)\"\n", ErrLDAP(x));
} else {
debug("SearchIPLDAP(-, %s) -> %s\n", edui_ldap.userid, ErrLDAP(x));
- local_printfx("OK user=%s\n", edui_ldap.userid); /* Got a userid --> OK user=<userid> */
+ local_printfx("OK user=%s\n", edui_ldap.userid); /* Got a userid --> OK user=<userid> */
}
}
}
x = MainSafe(argc, argv);
return x;
}
+
int dict_lookup(struct ip_user_dict *, char *, char *);
/** Size of lines read from the dictionary file */
-#define DICT_BUFFER_SIZE 8196
+#define DICT_BUFFER_SIZE 8196
/** This function parses the dictionary file and loads it
* in memory. All IP addresses are processed with a bitwise AND
*/
struct ip_user_dict *
load_dict(FILE * FH) {
- struct ip_user_dict *current_entry; /* the structure used to
- store data */
- struct ip_user_dict *first_entry = NULL; /* the head of the
- linked list */
+ struct ip_user_dict *current_entry; /* the structure used to
+ store data */
+ struct ip_user_dict *first_entry = NULL; /* the head of the
+ linked list */
char line[DICT_BUFFER_SIZE]; /* the buffer for the lines read
- from the dict file */
- char *tmpbuf; /* for the address before the
- bitwise AND */
+ from the dict file */
+ char *tmpbuf; /* for the address before the
+ bitwise AND */
/* the pointer to the first entry in the linked list */
first_entry = (struct ip_user_dict*)malloc(sizeof(struct ip_user_dict));
}
}
return 0;
-} /* match_user */
+} /* match_user */
int
match_group(char *dict_group, char *username)
{
- struct group *g; /* a struct to hold group entries */
- ++dict_group; /* the @ should be the first char
- so we rip it off by incrementing
- * the pointer by one */
+ struct group *g; /* a struct to hold group entries */
+ ++dict_group; /* the @ should be the first char
+ so we rip it off by incrementing
+ * the pointer by one */
if ((g = getgrnam(dict_group)) == NULL) {
debug("Group does not exist '%s'\n", dict_group);
fclose (FH);
return 0;
}
+
#if HAVE_KRB5
krb5_cleanup();
#endif
- exit(1); /* BIIG buffer */
+ exit(1); /* BIIG buffer */
}
SEND_BH("fgets NULL");
clean_args(&margs);
}
}
#endif
+
#endif
#define PROGRAM "kerberos_ldap_group"
+
cleanup();
return (1);
}
- while (*p) { /* loop over group list */
- if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
+ while (*p) { /* loop over group list */
+ if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
++p;
continue;
}
- if (*p == '@') { /* end of group name - start of domain name */
- if (p == gp) { /* empty group name not allowed */
+ if (*p == '@') { /* end of group name - start of domain name */
+ if (p == gp) { /* empty group name not allowed */
debug((char *) "%s| %s: ERROR: No group defined for domain %s\n", LogTime(), PROGRAM, p);
cleanup();
return (1);
gdsp = init_gd();
gdsp->group = xstrdup(gp);
gdsp->next = gdspn;
- dp = p; /* after @ starts new domain name */
- } else if (*p == ':') { /* end of group name or end of domain name */
- if (p == gp) { /* empty group name not allowed */
+ dp = p; /* after @ starts new domain name */
+ } else if (*p == ':') { /* end of group name or end of domain name */
+ if (p == gp) { /* empty group name not allowed */
debug((char *) "%s| %s: ERROR: No group defined for domain %s\n", LogTime(), PROGRAM, p);
cleanup();
return (1);
}
*p = '\0';
++p;
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
gdsp->domain = xstrdup(dp);
dp = NULL;
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
gdsp = init_gd();
gdsp->group = xstrdup(gp);
gdsp->next = gdspn;
}
gdspn = gdsp;
- gp = p; /* after : starts new group name */
+ gp = p; /* after : starts new group name */
debug((char *) "%s| %s: INFO: Group %s Domain %s\n", LogTime(), PROGRAM, gdsp->group, gdsp->domain ? gdsp->domain : "NULL");
} else
++p;
}
- if (p == gp) { /* empty group name not allowed */
+ if (p == gp) { /* empty group name not allowed */
debug((char *) "%s| %s: ERROR: No group defined for domain %s\n", LogTime(), PROGRAM, p);
cleanup();
return (1);
}
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
gdsp->domain = xstrdup(dp);
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
gdsp = init_gd();
gdsp->group = xstrdup(gp);
- if (gdspn) /* Have already an existing structure */
+ if (gdspn) /* Have already an existing structure */
gdsp->next = gdspn;
}
debug((char *) "%s| %s: INFO: Group %s Domain %s\n", LogTime(), PROGRAM, gdsp->group, gdsp->domain ? gdsp->domain : "NULL");
return (0);
}
#endif
+
debug((char *) "%s| %s: DEBUG: Get default keytab file name\n", LogTime(), PROGRAM);
krb5_kt_default_name(kparam.context, buf, KT_PATH_MAX);
- p = strchr(buf, ':'); /* Find the end if "FILE:" */
+ p = strchr(buf, ':'); /* Find the end if "FILE:" */
if (p)
- ++p; /* step past : */
+ ++p; /* step past : */
keytab_name = xstrdup(p ? p : buf);
debug((char *) "%s| %s: DEBUG: Got default keytab file name %s\n", LogTime(), PROGRAM, keytab_name);
return (retval);
}
#endif
+
return (retval);
}
#endif
+
#endif /* __GNUC__ */
#endif
+
debug((char *) "%s| %s: DEBUG: No ldap servers defined.\n", LogTime(), PROGRAM);
return (0);
}
- while (*p) { /* loop over group list */
- if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
+ while (*p) { /* loop over group list */
+ if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
++p;
continue;
}
- if (*p == '@') { /* end of group name - start of domain name */
- if (p == np) { /* empty group name not allowed */
+ if (*p == '@') { /* end of group name - start of domain name */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No ldap servers defined for domain %s\n", LogTime(), PROGRAM, p);
free_ls(lssp);
return (1);
lssp = init_ls();
lssp->lserver = xstrdup(np);
lssp->next = lsspn;
- dp = p; /* after @ starts new domain name */
- } else if (*p == ':') { /* end of group name or end of domain name */
- if (p == np) { /* empty group name not allowed */
+ dp = p; /* after @ starts new domain name */
+ } else if (*p == ':') { /* end of group name or end of domain name */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No ldap servers defined for domain %s\n", LogTime(), PROGRAM, p);
free_ls(lssp);
return (1);
}
*p = '\0';
++p;
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
lssp->domain = xstrdup(dp);
dp = NULL;
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
lssp = init_ls();
lssp->lserver = xstrdup(np);
lssp->next = lsspn;
}
lsspn = lssp;
- np = p; /* after : starts new group name */
+ np = p; /* after : starts new group name */
debug((char *) "%s| %s: DEBUG: ldap server %s Domain %s\n", LogTime(), PROGRAM, lssp->lserver, lssp->domain?lssp->domain:"NULL");
} else
++p;
}
- if (p == np) { /* empty group name not allowed */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No ldap servers defined for domain %s\n", LogTime(), PROGRAM, p);
free_ls(lssp);
return (1);
}
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
lssp->domain = xstrdup(dp);
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
lssp = init_ls();
lssp->lserver = xstrdup(np);
- if (lsspn) /* Have already an existing structure */
+ if (lsspn) /* Have already an existing structure */
lssp->next = lsspn;
}
debug((char *) "%s| %s: DEBUG: ldap server %s Domain %s\n", LogTime(), PROGRAM, lssp->lserver, lssp->domain?lssp->domain:"NULL");
return (0);
}
#endif
+
debug((char *) "%s| %s: DEBUG: No netbios names defined.\n", LogTime(), PROGRAM);
return (0);
}
- while (*p) { /* loop over group list */
- if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
+ while (*p) { /* loop over group list */
+ if (*p == '\n' || *p == '\r') { /* Ignore CR and LF if exist */
++p;
continue;
}
- if (*p == '@') { /* end of group name - start of domain name */
- if (p == np) { /* empty group name not allowed */
+ if (*p == '@') { /* end of group name - start of domain name */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM, p);
free_nd(ndsp);
return (1);
ndsp = init_nd();
ndsp->netbios = xstrdup(np);
ndsp->next = ndspn;
- dp = p; /* after @ starts new domain name */
- } else if (*p == ':') { /* end of group name or end of domain name */
- if (p == np) { /* empty group name not allowed */
+ dp = p; /* after @ starts new domain name */
+ } else if (*p == ':') { /* end of group name or end of domain name */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM, p);
free_nd(ndsp);
return (1);
}
*p = '\0';
++p;
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
ndsp->domain = xstrdup(dp);
dp = NULL;
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
ndsp = init_nd();
ndsp->netbios = xstrdup(np);
ndsp->next = ndspn;
}
ndspn = ndsp;
- np = p; /* after : starts new group name */
+ np = p; /* after : starts new group name */
if (!ndsp->domain || !strcmp(ndsp->domain, "")) {
debug((char *) "%s| %s: DEBUG: No domain defined for netbios name %s\n", LogTime(), PROGRAM, ndsp->netbios);
free_nd(ndsp);
} else
++p;
}
- if (p == np) { /* empty group name not allowed */
+ if (p == np) { /* empty group name not allowed */
debug((char *) "%s| %s: DEBUG: No netbios name defined for domain %s\n", LogTime(), PROGRAM, p);
free_nd(ndsp);
return (1);
}
- if (dp) { /* end of domain name */
+ if (dp) { /* end of domain name */
ndsp->domain = xstrdup(dp);
- } else { /* end of group name and no domain name */
+ } else { /* end of group name and no domain name */
ndsp = init_nd();
ndsp->netbios = xstrdup(np);
ndsp->next = ndspn;
return NULL;
}
#endif
+
}
}
p = buffer;
- p += 6 * NS_INT16SZ; /* Header(6*16bit) = id + flags + 4*section count */
+ p += 6 * NS_INT16SZ; /* Header(6*16bit) = id + flags + 4*section count */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < header size\n", LogTime(), PROGRAM, len);
goto finalise;
error((char *) "%s| %s: ERROR: Error while expanding query name with dn_expand: %s\n", LogTime(), PROGRAM, strerror(errno));
goto finalise;
}
- p += size; /* Query name */
- p += 2 * NS_INT16SZ; /* Query type + class (2*16bit) */
+ p += size; /* Query name */
+ p += 2 * NS_INT16SZ; /* Query type + class (2*16bit) */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < header + query name,type,class \n", LogTime(), PROGRAM, len);
goto finalise;
error((char *) "%s| %s: ERROR: Error while expanding answer name with dn_expand: %s\n", LogTime(), PROGRAM, strerror(errno));
goto finalise;
}
- p += size; /* Resource Record name */
+ p += size; /* Resource Record name */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < header + query name,type,class + answer name\n", LogTime(), PROGRAM, len);
goto finalise;
}
- NS_GET16(type, p); /* RR type (16bit) */
- p += NS_INT16SZ + NS_INT32SZ; /* RR class + ttl (16bit+32bit) */
+ NS_GET16(type, p); /* RR type (16bit) */
+ p += NS_INT16SZ + NS_INT32SZ; /* RR class + ttl (16bit+32bit) */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < header + query name,type,class + answer name + RR type,class,ttl\n", LogTime(), PROGRAM, len);
goto finalise;
}
- NS_GET16(rdlength, p); /* RR data length (16bit) */
+ NS_GET16(rdlength, p); /* RR data length (16bit) */
- if (type == ns_t_srv) { /* SRV record */
+ if (type == ns_t_srv) { /* SRV record */
int priority, weight, port;
char host[NS_MAXDNAME];
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < header + query name,type,class + answer name + RR type,class,ttl + RR data length\n", LogTime(), PROGRAM, len);
goto finalise;
}
- NS_GET16(priority, p); /* Priority (16bit) */
+ NS_GET16(priority, p); /* Priority (16bit) */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < SRV RR + priority\n", LogTime(), PROGRAM, len);
goto finalise;
}
- NS_GET16(weight, p); /* Weight (16bit) */
+ NS_GET16(weight, p); /* Weight (16bit) */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < SRV RR + priority + weight\n", LogTime(), PROGRAM, len);
goto finalise;
}
- NS_GET16(port, p); /* Port (16bit) */
+ NS_GET16(port, p); /* Port (16bit) */
if (p > buffer + len) {
error((char *) "%s| %s: ERROR: Message to small: %d < SRV RR + priority + weight + port\n", LogTime(), PROGRAM, len);
goto finalise;
return (nhosts);
}
#endif
+
#include <sasl/sasl.h>
#elif HAVE_SASL_DARWIN
typedef struct sasl_interact {
- unsigned long id; /* same as client/user callback ID */
- const char *challenge; /* presented to user (e.g. OTP challenge) */
- const char *prompt; /* presented to user (e.g. "Username: ") */
- const char *defresult; /* default result string */
- const void *result; /* set to point to result */
- unsigned len; /* set to length of result */
+ unsigned long id; /* same as client/user callback ID */
+ const char *challenge; /* presented to user (e.g. OTP challenge) */
+ const char *prompt; /* presented to user (e.g. "Username: ") */
+ const char *defresult; /* default result string */
+ const void *result; /* set to point to result */
+ unsigned len; /* set to length of result */
} sasl_interact_t;
-#define SASL_CB_USER 0x4001 /* client user identity to login as */
-#define SASL_CB_AUTHNAME 0x4002 /* client authentication name */
-#define SASL_CB_PASS 0x4004 /* client passphrase-based secret */
-#define SASL_CB_ECHOPROMPT 0x4005 /* challenge and client enterred result */
-#define SASL_CB_NOECHOPROMPT 0x4006 /* challenge and client enterred result */
-#define SASL_CB_GETREALM 0x4008 /* realm to attempt authentication in */
-#define SASL_CB_LIST_END 0 /* end of list */
+#define SASL_CB_USER 0x4001 /* client user identity to login as */
+#define SASL_CB_AUTHNAME 0x4002 /* client authentication name */
+#define SASL_CB_PASS 0x4004 /* client passphrase-based secret */
+#define SASL_CB_ECHOPROMPT 0x4005 /* challenge and client enterred result */
+#define SASL_CB_NOECHOPROMPT 0x4006 /* challenge and client enterred result */
+#define SASL_CB_GETREALM 0x4008 /* realm to attempt authentication in */
+#define SASL_CB_LIST_END 0 /* end of list */
#endif
#if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
#endif
#endif
+
shutdown_db();
return 0;
}
+
static void readConfig(const char *filename)
{
char line[TQ_BUFFERSIZE]; /* the buffer for the lines read
- from the dict file */
- char *cp; /* a char pointer used to parse
- each line */
- char *username; /* for the username */
+ from the dict file */
+ char *cp; /* a char pointer used to parse
+ each line */
+ char *username; /* for the username */
char *budget;
char *period;
FILE *FH;
shutdown_db();
return 0;
}
+
} else {
fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
}
- // fall through to display help texts.
+ // fall through to display help texts.
default:
usage(argv[0]);
}
return 0;
}
+
#include "defines.h"
/* parse buffer - ie, length of longest expected line */
-#define LOGFILE_BUF_LEN 65536
+#define LOGFILE_BUF_LEN 65536
static void
rotate(const char *path, int rotate_count)
fp = NULL;
exit(0);
}
+
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "ERROR: unknown option: -%c. Exiting\n", opt);
usage();
} else
debug("Got '%s' from Squid\n", buf);
- if (memcmp(buf, "YR ", 3) == 0) { /* refresh-request */
+ if (memcmp(buf, "YR ", 3) == 0) { /* refresh-request */
/* figure out what we got */
decodedLen = base64_decode(decoded, sizeof(decoded), buf + 3);
- if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
+ if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
SEND("NA * Packet format error, couldn't base64-decode");
return 1;
}
if (status == SSP_OK) {
if (Done) {
- lc(cred); /* let's lowercase them for our convenience */
+ lc(cred); /* let's lowercase them for our convenience */
have_serverblob = 0;
Done = FALSE;
if (Negotiate_packet_debug_enabled) {
SEND("BH can't obtain server blob");
return 1;
}
- if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
+ if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
if (!have_serverblob) {
SEND("BH invalid server blob");
return 1;
}
/* figure out what we got */
decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
- if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
+ if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
SEND("NA * Packet format error, couldn't base64-decode");
return 1;
}
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
(LPTSTR) & ErrorMessage,
0,
NULL);
return 1;
}
if (Done) {
- lc(cred); /* let's lowercase them for our convenience */
+ lc(cred); /* let's lowercase them for our convenience */
have_serverblob = 0;
Done = FALSE;
if (Negotiate_packet_debug_enabled) {
return 1;
}
- } else { /* not an auth-request */
+ } else { /* not an auth-request */
SEND("BH illegal request received");
fprintf(stderr, "Illegal request received: '%s'\n", buf);
return 1;
}
exit(0);
}
+
#else
#define HAVE_PAC_SUPPORT 0
#endif
+
struct stat fstat;
char *ktp;
#endif
- if (optarg)
+ if (optarg)
keytab_name = xstrdup(optarg);
- else {
+ else {
fprintf(stderr, "ERROR: keytab file not given\n");
- exit(1);
- }
+ exit(1);
+ }
/*
* Some sanity checks
*/
#if HAVE_SYS_STAT_H
struct stat dstat;
#endif
- if (optarg)
+ if (optarg)
rcache_dir = xstrdup(optarg);
- else {
+ else {
fprintf(stderr, "ERROR: replay cache directory not given\n");
- exit(1);
- }
+ exit(1);
+ }
/*
* Some sanity checks
*/
#endif
break;
case 't':
- if (optarg)
+ if (optarg)
rcache_type = xstrdup(optarg);
- else {
+ else {
fprintf(stderr, "ERROR: replay cache type not given\n");
- exit(1);
- }
+ exit(1);
+ }
break;
case 's':
- if (optarg)
+ if (optarg)
service_principal = xstrdup(optarg);
- else {
+ else {
fprintf(stderr, "ERROR: service principal not given\n");
- exit(1);
- }
+ exit(1);
+ }
break;
default:
fprintf(stderr, "Usage: \n");
strerror(ferror(stdin)));
fprintf(stdout, "BH input error\n");
- exit(1); /* BIIG buffer */
+ exit(1); /* BIIG buffer */
}
fprintf(stdout, "BH input error\n");
exit(0);
}
}
#endif /* HAVE_GSSAPI */
+
}
#endif /* HAVE_GSSAPI */
+
Valid_Group(char *UserName, char *Group)
{
int result = FALSE;
- WCHAR wszUserName[UNLEN+1]; // Unicode user name
- WCHAR wszGroup[GNLEN+1]; // Unicode Group
+ WCHAR wszUserName[UNLEN+1]; // Unicode user name
+ WCHAR wszGroup[GNLEN+1]; // Unicode Group
LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
{
int x;
int rv;
- char credentials[DNLEN+UNLEN+2]; /* we can afford to waste */
+ char credentials[DNLEN+UNLEN+2]; /* we can afford to waste */
if (!NTLM_LocalCall) {
debug("Login attempt had result %d\n", rv);
- if (!rv) { /* failed */
+ if (!rv) { /* failed */
return NTLM_SSPI_ERROR;
}
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "unknown option: -%c. Exiting\n", opt);
usage();
/* NP: for some reason this helper sometimes needs to accept
* from clients that send no negotiate packet. */
if (memcpy(local_nego.hdr.signature, "NTLMSSP", 8) != 0) {
- memset(&local_nego, 0, sizeof(ntlm_negotiate)); /* reset */
+ memset(&local_nego, 0, sizeof(ntlm_negotiate)); /* reset */
memcpy(local_nego.hdr.signature, "NTLMSSP", 8); /* set the signature */
local_nego.hdr.type = le32toh(NTLM_NEGOTIATE); /* this is a challenge */
local_nego.flags = le32toh(NTLM_NEGOTIATE_ALWAYS_SIGN |
hex_dump(reinterpret_cast<unsigned char*>(decoded), decodedLen);
} else
debug("Got '%s' from Squid\n", buf);
- if (memcmp(buf, "YR", 2) == 0) { /* refresh-request */
+ if (memcmp(buf, "YR", 2) == 0) { /* refresh-request */
/* figure out what we got */
if (strlen(buf) > 3)
decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
memcpy(decoded, &local_nego, sizeof(local_nego));
decodedLen = sizeof(local_nego);
}
- if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
+ if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
SEND_ERR("message=\"Packet format error, couldn't base64-decode\"");
return 1;
}
case NTLM_CHALLENGE:
SEND_ERR("message=\"Got a challenge. We refuse to have our authority disputed\"");
return 1;
- /* notreached */
+ /* notreached */
case NTLM_AUTHENTICATE:
SEND_ERR("message=\"Got authentication request instead of negotiate request\"");
return 1;
- /* notreached */
+ /* notreached */
default:
helperfail("message=\"unknown refresh-request packet type\"");
return 1;
}
return 1;
}
- if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
+ if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
if (!have_challenge) {
helperfail("message=\"invalid challenge\"");
return 1;
/* figure out what we got */
decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
- if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
+ if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
SEND_ERR("message=\"Packet format error, couldn't base64-decode\"");
return 1;
}
case NTLM_NEGOTIATE:
SEND_ERR("message=\"Invalid negotiation request received\"");
return 1;
- /* notreached */
+ /* notreached */
case NTLM_CHALLENGE:
SEND_ERR("message=\"Got a challenge. We refuse to have our authority disputed\"");
return 1;
- /* notreached */
+ /* notreached */
case NTLM_AUTHENTICATE: {
/* check against SSPI */
int err = ntlm_check_auth((ntlm_authenticate *) decoded, user, domain, decodedLen);
return 1;
}
return 1;
- } else { /* not an auth-request */
+ } else { /* not an auth-request */
helperfail("message=\"illegal request received\"");
fprintf(stderr, "Illegal request received: '%s'\n", buf);
return 1;
}
exit(0);
}
+
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "unknown option: -%c. Exiting\n", opt);
usage();
debug("%s build " __DATE__ ", " __TIME__ " starting up...\n", my_program_name);
while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) {
- user[0] = '\0'; /*no user code */
- domain[0] = '\0'; /*no domain code */
+ user[0] = '\0'; /*no user code */
+ domain[0] = '\0'; /*no domain code */
if ((p = strchr(buf, '\n')) != NULL)
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */
if (buflen > 3) {
decodedLen = base64_decode(decodedBuf, sizeof(decodedBuf), buf+3);
}
exit(0);
}
+
struct _dc {
char *domain;
char *controller;
- time_t dead; /* 0 if it's alive, otherwise time of death */
+ time_t dead; /* 0 if it's alive, otherwise time of death */
dc *next;
};
static unsigned char challenge[NTLM_NONCE_LEN];
static unsigned char lmencoded_empty_pass[ENCODED_PASS_LEN],
-ntencoded_empty_pass[ENCODED_PASS_LEN];
+ ntencoded_empty_pass[ENCODED_PASS_LEN];
SMB_Handle_Type handle = NULL;
int ntlm_errno;
-static char credentials[MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2]; /* we can afford to waste */
+static char credentials[MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2]; /* we can afford to waste */
static char my_domain[100], my_domain_controller[100];
static char errstr[1001];
#if DEBUG
smberr = SMB_Get_Last_Error();
SMB_Get_Error_Msg(smberr, errstr, 1000);
- if (handle == NULL) { /* couldn't connect */
+ if (handle == NULL) { /* couldn't connect */
debug("Couldn't connect to SMB Server. Error:%s\n", errstr);
return 1;
}
- if (SMB_Negotiate(handle, SMB_Prots) < 0) { /* An error */
+ if (SMB_Negotiate(handle, SMB_Prots) < 0) { /* An error */
debug("Error negotiating protocol with SMB Server\n");
SMB_Discon(handle, 0);
handle = NULL;
return 2;
}
- if (handle->Security == 0) { /* share-level security, unuseable */
+ if (handle->Security == 0) { /* share-level security, unuseable */
debug("SMB Server uses share-level security .. we need user security.\n");
SMB_Discon(handle, 0);
handle = NULL;
char *user;
lstring tmp;
- if (handle == NULL) { /*if null we aren't connected, but it shouldn't happen */
+ if (handle == NULL) { /*if null we aren't connected, but it shouldn't happen */
debug("Weird, we've been disconnected\n");
ntlm_errno = NTLM_ERR_NOT_CONNECTED;
return NULL;
rv = SMB_Logon_Server(handle, user, pass, domain, 1);
debug("Login attempt had result %d\n", rv);
- if (rv != NTLM_ERR_NONE) { /* failed */
+ if (rv != NTLM_ERR_NONE) { /* failed */
ntlm_errno = rv;
return NULL;
}
- *(user - 1) = '\\'; /* hack. Performing, but ugly. */
+ *(user - 1) = '\\'; /* hack. Performing, but ugly. */
debug("credentials: %s\n", credentials);
return credentials;
new_dc->domain = d;
new_dc->controller = c;
new_dc->dead = 0;
- if (controllers == NULL) { /* first controller */
+ if (controllers == NULL) { /* first controller */
controllers = new_dc;
last_dc = new_dc;
} else {
- last_dc->next = new_dc; /* can't be null */
+ last_dc->next = new_dc; /* can't be null */
last_dc = new_dc;
}
}
usage();
exit(1);
}
- last_dc->next = controllers; /* close the queue, now it's circular */
+ last_dc->next = controllers; /* close the queue, now it's circular */
}
/**
/* mark helper as retry-worthy if it's so. */
debug("Reviving DC\n");
current_dc->dead = 0;
- } else { /* skip it */
+ } else { /* skip it */
debug("Skipping it\n");
continue;
}
debug("make_challenge retuned %p\n", ch);
if (ch) {
debug("Got it\n");
- return ch; /* All went OK, returning */
+ return ch; /* All went OK, returning */
}
/* Huston, we've got a problem. Take this DC out of the loop */
debug("Marking DC as DEAD\n");
if (fgets(buf, NTLM_BLOB_BUFFER_SIZE, stdin) == NULL) {
fprintf(stderr, "fgets() failed! dying..... errno=%d (%s)\n", errno,
strerror(errno));
- exit(1); /* BIIG buffer */
+ exit(1); /* BIIG buffer */
}
debug("managing request\n");
- ch2 = (char*)memchr(buf, '\n', NTLM_BLOB_BUFFER_SIZE); /* safer against overrun than strchr */
+ ch2 = (char*)memchr(buf, '\n', NTLM_BLOB_BUFFER_SIZE); /* safer against overrun than strchr */
if (ch2) {
- *ch2 = '\0'; /* terminate the string at newline. */
+ *ch2 = '\0'; /* terminate the string at newline. */
ch = ch2;
}
debug("ntlm authenticator. Got '%s' from Squid\n", buf);
- if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
+ if (memcmp(buf, "KK ", 3) == 0) { /* authenticate-request */
/* figure out what we got */
int decodedLen = base64_decode(decoded, sizeof(decoded), buf+3);
- if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
+ if ((size_t)decodedLen < sizeof(ntlmhdr)) { /* decoding failure, return error */
SEND("NA Packet format error, couldn't base64-decode");
return;
}
case NTLM_NEGOTIATE:
SEND("NA Invalid negotiation request received");
return;
- /* notreached */
+ /* notreached */
case NTLM_CHALLENGE:
SEND("NA Got a challenge. We refuse to have our authority disputed");
return;
- /* notreached */
+ /* notreached */
case NTLM_AUTHENTICATE:
/* check against the DC */
signal(SIGALRM, timeout_during_auth);
}
if (cred == NULL) {
int smblib_err, smb_errorclass, smb_errorcode, nb_error;
- if (ntlm_errno == NTLM_ERR_LOGON) { /* hackish */
+ if (ntlm_errno == NTLM_ERR_LOGON) { /* hackish */
SEND("NA Logon Failure");
return;
}
smblib_err, smb_errorclass, smb_errorcode, nb_error);
/* Should I use smblib_err? Actually it seems I can do as well
* without it.. */
- if (nb_error != 0) { /* netbios-level error */
+ if (nb_error != 0) { /* netbios-level error */
SEND("BH NetBios error!");
fprintf(stderr, "NetBios error code %d (%s)\n", nb_error,
RFCNB_Error_Strings[abs(nb_error)]);
/*this is the most important one for errors */
debug("DOS error\n");
switch (smb_errorcode) {
- /* two categories matter to us: those which could be
- * server errors, and those which are auth errors */
- case SMBD_noaccess: /* 5 */
+ /* two categories matter to us: those which could be
+ * server errors, and those which are auth errors */
+ case SMBD_noaccess: /* 5 */
SEND("NA Access denied");
return;
case SMBD_badformat:
SEND("BH DOS Error");
return;
}
- case SMBC_ERRSRV: /* server errors */
+ case SMBC_ERRSRV: /* server errors */
debug("Server error");
switch (smb_errorcode) {
- /* mostly same as above */
+ /* mostly same as above */
case SMBV_badpw:
SEND("NA Bad password");
return;
SEND("BH Server Error");
return;
}
- case SMBC_ERRHRD: /* hardware errors don't really matter */
+ case SMBC_ERRHRD: /* hardware errors don't really matter */
SEND("BH Domain Controller Hardware error");
return;
case SMBC_ERRCMD:
return;
}
- lc(cred); /* let's lowercase them for our convenience */
+ lc(cred); /* let's lowercase them for our convenience */
SEND2("AF %s", cred);
return;
default:
/* notreached */
return;
}
- if (memcmp(buf, "YR", 2) == 0) { /* refresh-request */
+ if (memcmp(buf, "YR", 2) == 0) { /* refresh-request */
dc_disconnect();
ch = obtain_challenge();
/* Robert says we can afford to wait forever. I'll trust him on this
/* notreached */
return 0;
}
+
exit(0);
case '?':
opt = optopt;
- /* fall thru to default */
+ /* fall thru to default */
default:
fprintf(stderr, "unknown option: -%c. Exiting\n", opt);
usage();
char *p;
if ((p = strchr(buf, '\n')) != NULL) {
- *p = '\0'; /* strip \n */
+ *p = '\0'; /* strip \n */
buflen = p - buf; /* length is known already */
} else
buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */
debug("%s build " __DATE__ ", " __TIME__ " shutting down...\n", my_program_name);
return 0;
}
+
}
#endif /* SQUID_RANGE_H */
+
#endif /* !__SUNPRO_CC && !__clang__*/
#endif /* SQUID_NEW_H */
+
#define MAX_SUBID 0xFF
#endif
-#define MAX_OID_LEN 128 /* max subid's in an oid, per SNMP spec. */
-
-#define ASN_BOOLEAN (0x01)
-#define ASN_INTEGER (0x02)
-#define ASN_BIT_STR (0x03)
-#define ASN_OCTET_STR (0x04)
-#define ASN_NULL (0x05)
-#define ASN_OBJECT_ID (0x06)
-#define ASN_SEQUENCE (0x10)
-#define ASN_SET (0x11)
-
-#define ASN_UNIVERSAL (0x00)
+#define MAX_OID_LEN 128 /* max subid's in an oid, per SNMP spec. */
+
+#define ASN_BOOLEAN (0x01)
+#define ASN_INTEGER (0x02)
+#define ASN_BIT_STR (0x03)
+#define ASN_OCTET_STR (0x04)
+#define ASN_NULL (0x05)
+#define ASN_OBJECT_ID (0x06)
+#define ASN_SEQUENCE (0x10)
+#define ASN_SET (0x11)
+
+#define ASN_UNIVERSAL (0x00)
#define ASN_APPLICATION (0x40)
-#define ASN_CONTEXT (0x80)
-#define ASN_PRIVATE (0xC0)
+#define ASN_CONTEXT (0x80)
+#define ASN_PRIVATE (0xC0)
-#define ASN_PRIMITIVE (0x00)
-#define ASN_CONSTRUCTOR (0x20)
+#define ASN_PRIMITIVE (0x00)
+#define ASN_CONSTRUCTOR (0x20)
-#define ASN_LONG_LEN (0x80)
+#define ASN_LONG_LEN (0x80)
#define ASN_EXTENSION_ID (0x1F)
-#define ASN_BIT8 (0x80)
+#define ASN_BIT8 (0x80)
-#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
-#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
+#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
+#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
#ifdef __cplusplus
extern "C" {
#endif
- u_char *asn_build_header(u_char *, int *, u_char, int);
- u_char *asn_parse_int(u_char *, int *, u_char *, int *, int);
- u_char *asn_parse_unsigned_int(u_char *, int *, u_char *, u_int *, int);
- u_char *asn_build_int(u_char *, int *, u_char, int *, int);
- u_char *asn_build_unsigned_int(u_char *, int *, u_char, u_int *, int);
- u_char *asn_parse_string(u_char *, int *, u_char *, u_char *, int *);
- u_char *asn_build_string(u_char *, int *, u_char, u_char *, int);
- u_char *asn_parse_header(u_char *, int *, u_char *);
- u_char *asn_build_header_with_truth(u_char *, int *, u_char, int, int);
-
- u_char *asn_parse_length(u_char *, u_int *);
- u_char *asn_build_length(u_char *, int *, int, int);
- u_char *asn_parse_objid(u_char *, int *, u_char *, oid *, int *);
- u_char *asn_build_objid(u_char *, int *, u_char, oid *, int);
- u_char *asn_parse_null(u_char *, int *, u_char *);
- u_char *asn_build_null(u_char *, int *, u_char);
+u_char *asn_build_header(u_char *, int *, u_char, int);
+u_char *asn_parse_int(u_char *, int *, u_char *, int *, int);
+u_char *asn_parse_unsigned_int(u_char *, int *, u_char *, u_int *, int);
+u_char *asn_build_int(u_char *, int *, u_char, int *, int);
+u_char *asn_build_unsigned_int(u_char *, int *, u_char, u_int *, int);
+u_char *asn_parse_string(u_char *, int *, u_char *, u_char *, int *);
+u_char *asn_build_string(u_char *, int *, u_char, u_char *, int);
+u_char *asn_parse_header(u_char *, int *, u_char *);
+u_char *asn_build_header_with_truth(u_char *, int *, u_char, int, int);
+
+u_char *asn_parse_length(u_char *, u_int *);
+u_char *asn_build_length(u_char *, int *, int, int);
+u_char *asn_parse_objid(u_char *, int *, u_char *, oid *, int *);
+u_char *asn_build_objid(u_char *, int *, u_char, oid *, int);
+u_char *asn_parse_null(u_char *, int *, u_char *);
+u_char *asn_build_null(u_char *, int *, u_char);
#if 0
- u_char *asn_parse_bitstring(u_char *, int *, u_char *, u_char *, int *);
- u_char *asn_build_bitstring(u_char *, int *, u_char, u_char *, int);
+u_char *asn_parse_bitstring(u_char *, int *, u_char *, u_char *, int *);
+u_char *asn_build_bitstring(u_char *, int *, u_char, u_char *, int);
#endif
- u_char *asn_build_exception(u_char *, int *, u_char);
+u_char *asn_build_exception(u_char *, int *, u_char);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_ASN1_H */
+#endif /* SQUID_SNMP_ASN1_H */
+
extern "C" {
#endif
- // Decoding functions
-
- /// Calculate the decoded length of a given nul-terminated encoded string.
- /// NULL pointer and empty strings are accepted, result is zero.
- /// Any return value <= zero means no decoded result can be produced.
- extern int base64_decode_len(const char *encodedData);
-
- /// Decode a base-64 encoded blob into a provided buffer.
- /// Will not terminate the resulting string.
- /// In-place decoding overlap is supported if result is equal or earlier that the source pointer.
- ///
- /// \return number of bytes filled in result.
- extern int base64_decode(char *result, unsigned int result_max_size, const char *encoded);
-
- // Encoding functions
-
- /// Calculate the buffer size required to hold the encoded form of
- /// a string of length 'decodedLen' including all terminator bytes.
- extern int base64_encode_len(int decodedLen);
-
- /// Base-64 encode a string into a given buffer.
- /// Will not terminate the resulting string.
- /// \return the number of bytes filled in result.
- extern int base64_encode(char *result, int result_max_size, const char *data, int data_size);
-
- /// Base-64 encode a string into a given buffer.
- /// Will terminate the resulting string.
- /// \return the number of bytes filled in result. Including the terminator.
- extern int base64_encode_str(char *result, int result_max_size, const char *data, int data_size);
-
- // Old encoder. Now a wrapper for the new. Takes a binary array of known length.
- // Output is presented in a static buffer which will only remain valid until next call.
- // Ensures a nul-terminated result. Will always return non-NULL.
- extern const char *base64_encode_bin(const char *data, int len);
-
- // Old encoder. Now a wrapper for the new.
- // Output is presented in a static buffer which will only remain valid until next call.
- // Ensures a nul-terminated result. Will always return non-NULL.
- extern const char *old_base64_encode(const char *decoded);
+// Decoding functions
+
+/// Calculate the decoded length of a given nul-terminated encoded string.
+/// NULL pointer and empty strings are accepted, result is zero.
+/// Any return value <= zero means no decoded result can be produced.
+extern int base64_decode_len(const char *encodedData);
+
+/// Decode a base-64 encoded blob into a provided buffer.
+/// Will not terminate the resulting string.
+/// In-place decoding overlap is supported if result is equal or earlier that the source pointer.
+///
+/// \return number of bytes filled in result.
+extern int base64_decode(char *result, unsigned int result_max_size, const char *encoded);
+
+// Encoding functions
+
+/// Calculate the buffer size required to hold the encoded form of
+/// a string of length 'decodedLen' including all terminator bytes.
+extern int base64_encode_len(int decodedLen);
+
+/// Base-64 encode a string into a given buffer.
+/// Will not terminate the resulting string.
+/// \return the number of bytes filled in result.
+extern int base64_encode(char *result, int result_max_size, const char *data, int data_size);
+
+/// Base-64 encode a string into a given buffer.
+/// Will terminate the resulting string.
+/// \return the number of bytes filled in result. Including the terminator.
+extern int base64_encode_str(char *result, int result_max_size, const char *data, int data_size);
+
+// Old encoder. Now a wrapper for the new. Takes a binary array of known length.
+// Output is presented in a static buffer which will only remain valid until next call.
+// Ensures a nul-terminated result. Will always return non-NULL.
+extern const char *base64_encode_bin(const char *data, int len);
+
+// Old encoder. Now a wrapper for the new.
+// Output is presented in a static buffer which will only remain valid until next call.
+// Ensures a nul-terminated result. Will always return non-NULL.
+extern const char *old_base64_encode(const char *decoded);
#ifdef __cplusplus
}
#endif
#endif /* _SQUID_BASE64_H */
+
#endif /* SQUID_SNMP */
#endif /* SQUID_CACHE_SNMP_H */
+
char *latin1_to_utf8(char *out, size_t size, const char *in);
#endif /* _SQUID_CHARSET_H */
+
SQUIDCEXTERN const char *getfullhostname(void);
#endif /* _SQUID_GETFULLHOSTNAME_H */
+
* HASH_SIZE 33493 // prime number < 32768
* HASH_SIZE 65357 // prime number < 65536
*/
-#define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */
+#define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */
#endif /* SQUID_HASH_H */
+
* the top of the heap (as in the smallest object key value). Child nodes
* are larger than their parent.
****************************************************************************/
-#ifndef SQUID_HEAP_H
-#define SQUID_HEAP_H
+#ifndef SQUID_HEAP_H
+#define SQUID_HEAP_H
/*
* Function for generating heap keys. The first argument will typically be
heap_mutex_t lock;
unsigned long size;
unsigned long last;
- heap_key_func *gen_key; /* key generator for heap */
- heap_key age; /* aging factor for heap */
+ heap_key_func *gen_key; /* key generator for heap */
+ heap_key age; /* aging factor for heap */
heap_node **nodes;
} heap;
/*
* Generate a heap key for a given data object. Alternative macro form:
*/
-#ifdef MACRO_DEBUG
+#ifdef MACRO_DEBUG
SQUIDCEXTERN heap_key heap_gen_key(heap * hp, heap_t dat);
#else
-#define heap_gen_key(hp,md) ((hp)->gen_key((md),(hp)->age))
+#define heap_gen_key(hp,md) ((hp)->gen_key((md),(hp)->age))
#endif /* MACRO_DEBUG */
/*
/*
* Is the heap empty? How many nodes (data objects) are in it?
*/
-#ifdef MACRO_DEBUG
+#ifdef MACRO_DEBUG
SQUIDCEXTERN int heap_empty(heap *);
SQUIDCEXTERN int heap_nodes(heap *);
#else /* MACRO_DEBUG */
-#define heap_nodes(heap) ((heap)->last)
-#define heap_empty(heap) ((heap)->last <= 0 ? 1 : 0)
+#define heap_nodes(heap) ((heap)->last)
+#define heap_empty(heap) ((heap)->last <= 0 ? 1 : 0)
#endif /* MACRO_DEBUG */
/*
SQUIDCEXTERN int verify_heap_property(heap *);
#endif /* SQUID_HEAP_H */
+
char *html_quote(const char *);
#endif /* _SQUID_HTML_QUOTE_H */
+
#endif /* HAVE_NETTLE_MD5_H */
#endif /* SQUID_MD5_H */
+
#define memMeterDel(m, sz) { (m).level -= (sz); }
#endif /* _MEM_METER_H_ */
+
#define SQUID_PARSE_H
/***********************************************************
- Copyright 1989 by Carnegie Mellon University
+ Copyright 1989 by Carnegie Mellon University
All Rights Reserved
* A tree in the format of the tree structure of the MIB.
*/
struct snmp_mib_tree {
- struct snmp_mib_tree *child_list; /* list of children of this node */
- struct snmp_mib_tree *next_peer; /* Next node in list of peers */
+ struct snmp_mib_tree *child_list; /* list of children of this node */
+ struct snmp_mib_tree *next_peer; /* Next node in list of peers */
struct snmp_mib_tree *parent;
- char label[64]; /* This node's textual name */
- u_int subid; /* This node's integer subidentifier */
- int type; /* This node's object type */
- struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */
- void (*printer) (char *buf, variable_list *var, void *foo, int quiet); /* Value printing function */
+ char label[64]; /* This node's textual name */
+ u_int subid; /* This node's integer subidentifier */
+ int type; /* This node's object type */
+ struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */
+ void (*printer) (char *buf, variable_list *var, void *foo, int quiet); /* Value printing function */
};
/* non-aggregate types for tree end nodes */
-#define TYPE_OTHER 0
-#define TYPE_OBJID 1
-#define TYPE_OCTETSTR 2
-#define TYPE_INTEGER 3
-#define TYPE_NETADDR 4
-#define TYPE_IPADDR 5
-#define TYPE_COUNTER 6
-#define TYPE_GAUGE 7
-#define TYPE_TIMETICKS 8
-#define TYPE_OPAQUE 9
-#define TYPE_NULL 10
+#define TYPE_OTHER 0
+#define TYPE_OBJID 1
+#define TYPE_OCTETSTR 2
+#define TYPE_INTEGER 3
+#define TYPE_NETADDR 4
+#define TYPE_IPADDR 5
+#define TYPE_COUNTER 6
+#define TYPE_GAUGE 7
+#define TYPE_TIMETICKS 8
+#define TYPE_OPAQUE 9
+#define TYPE_NULL 10
#ifdef __cplusplus
extern "C" {
#endif
- void init_mib(char *);
- int read_objid(char *, oid *, int *);
- void print_objid(oid *, int);
- void sprint_objid(char *, oid *, int);
- void print_variable(oid *, int, struct variable_list *);
- void sprint_variable(char *, oid *, int, struct variable_list *);
- void sprint_value(char *, oid *, int, struct variable_list *);
- void print_value(oid *, int, struct variable_list *);
+void init_mib(char *);
+int read_objid(char *, oid *, int *);
+void print_objid(oid *, int);
+void sprint_objid(char *, oid *, int);
+void print_variable(oid *, int, struct variable_list *);
+void sprint_variable(char *, oid *, int, struct variable_list *);
+void sprint_value(char *, oid *, int, struct variable_list *);
+void print_value(oid *, int, struct variable_list *);
- /*void print_variable_list(struct variable_list *); */
- /*void print_variable_list_value(struct variable_list *); */
- /*void print_type(struct variable_list *); */
- void print_oid_nums(oid *, int);
+/*void print_variable_list(struct variable_list *); */
+/*void print_variable_list_value(struct variable_list *); */
+/*void print_type(struct variable_list *); */
+void print_oid_nums(oid *, int);
- struct snmp_mib_tree *read_mib(char *);
+struct snmp_mib_tree *read_mib(char *);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_PARSE_H */
+#endif /* SQUID_PARSE_H */
+
*/
#ifndef SQUID_RADIX_H
-#define SQUID_RADIX_H
+#define SQUID_RADIX_H
/*
* Copyright (c) 1988, 1989, 1993
struct squid_radix_node {
- struct squid_radix_mask *rn_mklist; /* list of masks contained in subtree */
+ struct squid_radix_mask *rn_mklist; /* list of masks contained in subtree */
- struct squid_radix_node *rn_p; /* parent */
- short rn_b; /* bit offset; -1-index(netmask) */
- char rn_bmask; /* node: mask for bit test */
- unsigned char rn_flags; /* enumerated next */
-#define RNF_NORMAL 1 /* leaf contains normal route */
-#define RNF_ROOT 2 /* leaf is root leaf for tree */
-#define RNF_ACTIVE 4 /* This node is alive (for rtfree) */
+ struct squid_radix_node *rn_p; /* parent */
+ short rn_b; /* bit offset; -1-index(netmask) */
+ char rn_bmask; /* node: mask for bit test */
+ unsigned char rn_flags; /* enumerated next */
+#define RNF_NORMAL 1 /* leaf contains normal route */
+#define RNF_ROOT 2 /* leaf is root leaf for tree */
+#define RNF_ACTIVE 4 /* This node is alive (for rtfree) */
union {
- struct { /* leaf only data: */
- char *rn_Key; /* object of search */
- char *rn_Mask; /* netmask, if present */
+ struct { /* leaf only data: */
+ char *rn_Key; /* object of search */
+ char *rn_Mask; /* netmask, if present */
struct squid_radix_node *rn_Dupedkey;
} rn_leaf;
- struct { /* node only data: */
- int rn_Off; /* where to start compare */
+ struct { /* node only data: */
+ int rn_Off; /* where to start compare */
- struct squid_radix_node *rn_L; /* progeny */
+ struct squid_radix_node *rn_L; /* progeny */
- struct squid_radix_node *rn_R; /* progeny */
+ struct squid_radix_node *rn_R; /* progeny */
} rn_node;
} rn_u;
#ifdef RN_DEBUG
*/
struct squid_radix_mask {
- short rm_b; /* bit offset; -1-index(netmask) */
- char rm_unused; /* cf. rn_bmask */
- unsigned char rm_flags; /* cf. rn_flags */
+ short rm_b; /* bit offset; -1-index(netmask) */
+ char rm_unused; /* cf. rn_bmask */
+ unsigned char rm_flags; /* cf. rn_flags */
- struct squid_radix_mask *rm_mklist; /* more masks to try */
+ struct squid_radix_mask *rm_mklist; /* more masks to try */
union {
- char *rmu_mask; /* the mask */
+ char *rmu_mask; /* the mask */
- struct squid_radix_node *rmu_leaf; /* for normal routes */
+ struct squid_radix_node *rmu_leaf; /* for normal routes */
} rm_rmu;
- int rm_refs; /* # of references to this struct */
+ int rm_refs; /* # of references to this struct */
};
struct squid_radix_node_head {
struct squid_radix_node *rnh_treetop;
- int rnh_addrsize; /* permit, but not require fixed keys */
- int rnh_pktsize; /* permit, but not require fixed keys */
+ int rnh_addrsize; /* permit, but not require fixed keys */
+ int rnh_pktsize; /* permit, but not require fixed keys */
- struct squid_radix_node *(*rnh_addaddr) /* add based on sockaddr */
+ struct squid_radix_node *(*rnh_addaddr) /* add based on sockaddr */
(void *v, void *mask, struct squid_radix_node_head * head, struct squid_radix_node nodes[]);
- struct squid_radix_node *(*rnh_addpkt) /* add based on packet hdr */
+ struct squid_radix_node *(*rnh_addpkt) /* add based on packet hdr */
(void *v, void *mask, struct squid_radix_node_head * head, struct squid_radix_node nodes[]);
- struct squid_radix_node *(*rnh_deladdr) /* remove based on sockaddr */
+ struct squid_radix_node *(*rnh_deladdr) /* remove based on sockaddr */
(void *v, void *mask, struct squid_radix_node_head * head);
- struct squid_radix_node *(*rnh_delpkt) /* remove based on packet hdr */
+ struct squid_radix_node *(*rnh_delpkt) /* remove based on packet hdr */
(void *v, void *mask, struct squid_radix_node_head * head);
- struct squid_radix_node *(*rnh_matchaddr) /* locate based on sockaddr */
+ struct squid_radix_node *(*rnh_matchaddr) /* locate based on sockaddr */
(void *v, struct squid_radix_node_head * head);
- struct squid_radix_node *(*rnh_lookup) /* locate based on sockaddr */
+ struct squid_radix_node *(*rnh_lookup) /* locate based on sockaddr */
(void *v, void *mask, struct squid_radix_node_head * head);
- struct squid_radix_node *(*rnh_matchpkt) /* locate based on packet hdr */
+ struct squid_radix_node *(*rnh_matchpkt) /* locate based on packet hdr */
(void *v, struct squid_radix_node_head * head);
- int (*rnh_walktree) /* traverse tree */
+ int (*rnh_walktree) /* traverse tree */
(struct squid_radix_node_head * head, int (*f) (struct squid_radix_node *, void *), void *w);
- struct squid_radix_node rnh_nodes[3]; /* empty tree for common case */
+ struct squid_radix_node rnh_nodes[3]; /* empty tree for common case */
};
SQUIDCEXTERN void squid_rn_init (void);
SQUIDCEXTERN struct squid_radix_node *squid_rn_lookup(void *, void *, struct squid_radix_node_head *);
#endif /* SQUID_RADIX_H */
+
SQUIDCEXTERN int rfc1035RRPack(char *buf, size_t sz, const rfc1035_rr * RR);
#endif /* SQUID_RFC1035_H */
+
extern "C" {
#endif
- extern const char *mkhttpdlogtime(const time_t *);
- extern const char *mkrfc1123(time_t);
- extern time_t parse_rfc1123(const char *str);
+extern const char *mkhttpdlogtime(const time_t *);
+extern const char *mkrfc1123(time_t);
+extern time_t parse_rfc1123(const char *str);
#ifdef __cplusplus
}
#endif
#endif /* _SQUID_RFC1123_H */
+
extern "C" {
#endif
- /* Encoder rfc1738_do_escape flag values. */
+/* Encoder rfc1738_do_escape flag values. */
#define RFC1738_ESCAPE_CTRLS 1
#define RFC1738_ESCAPE_UNSAFE 2
#define RFC1738_ESCAPE_RESERVED 4
#define RFC1738_ESCAPE_ALL (RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_RESERVED|RFC1738_ESCAPE_CTRLS)
- // exclusions
+// exclusions
#define RFC1738_ESCAPE_NOSPACE 128
#define RFC1738_ESCAPE_NOPERCENT 256
- // Backward compatibility
+// Backward compatibility
#define RFC1738_ESCAPE_UNESCAPED (RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS|RFC1738_ESCAPE_NOPERCENT)
- /**
- * \group rfc1738 RFC 1738 URL-escaping library
- *
- * Public API is formed of a triplet of encode functions mapping to the rfc1738_do_encode() engine.
- *
- * ASCII characters are split into four groups:
- * \item SAFE Characters which are safe to occur in any URL. For example A,B,C
- * \item CTRLS Binary control codes. Dangerous to include in URLs.
- * \item UNSAFE Characters which are completely usafe to occur in any URL. For example; backspace, tab, space, newline.
- * \item RESERVED Characters which are reserved for special meaning and may only occur in certain parts of a URL.
- *
- * Returns a static buffer containing the RFC 1738 compliant, escaped version of the given url.
- *
- * \param flags RFC1738_ESCAPE_CTRLS Encode the blatantly dangerous binary codes.
- * \param flags RFC1738_ESCAPE_UNSAFE Encode printable unsafe characters (excluding CTRLs).
- * \param flags RFC1738_ESCAPE_RESERVED Encode reserved characters.
- * \param flags RFC1738_ESCAPE_ALL Encode all binary CTRL, unsafe and reserved characters.
- * \param flags RFC1738_ESCAPE_NOSPACE Ignore the space whitespace character.
- * \param flags RFC1738_ESCAPE_NOPERCENT Ignore the escaping delimiter '%'.
- */
- extern char *rfc1738_do_escape(const char *url, int flags);
+/**
+ * \group rfc1738 RFC 1738 URL-escaping library
+ *
+ * Public API is formed of a triplet of encode functions mapping to the rfc1738_do_encode() engine.
+ *
+ * ASCII characters are split into four groups:
+ * \item SAFE Characters which are safe to occur in any URL. For example A,B,C
+ * \item CTRLS Binary control codes. Dangerous to include in URLs.
+ * \item UNSAFE Characters which are completely usafe to occur in any URL. For example; backspace, tab, space, newline.
+ * \item RESERVED Characters which are reserved for special meaning and may only occur in certain parts of a URL.
+ *
+ * Returns a static buffer containing the RFC 1738 compliant, escaped version of the given url.
+ *
+ * \param flags RFC1738_ESCAPE_CTRLS Encode the blatantly dangerous binary codes.
+ * \param flags RFC1738_ESCAPE_UNSAFE Encode printable unsafe characters (excluding CTRLs).
+ * \param flags RFC1738_ESCAPE_RESERVED Encode reserved characters.
+ * \param flags RFC1738_ESCAPE_ALL Encode all binary CTRL, unsafe and reserved characters.
+ * \param flags RFC1738_ESCAPE_NOSPACE Ignore the space whitespace character.
+ * \param flags RFC1738_ESCAPE_NOPERCENT Ignore the escaping delimiter '%'.
+ */
+extern char *rfc1738_do_escape(const char *url, int flags);
- /* Old API functions */
+/* Old API functions */
- /* Default RFC 1738 escaping. Escape all UNSAFE characters and binary CTRL codes */
+/* Default RFC 1738 escaping. Escape all UNSAFE characters and binary CTRL codes */
#define rfc1738_escape(x) rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS)
- /* Escape a partial URL. Encoding every binary code, unsafe or reserved character. */
+/* Escape a partial URL. Encoding every binary code, unsafe or reserved character. */
#define rfc1738_escape_part(x) rfc1738_do_escape(x, RFC1738_ESCAPE_ALL)
- /* Escape a URL. Encoding every unsafe characters but skipping reserved and already-encoded bytes.
- * Suitable for safely encoding an absolute URL which may be encoded but is not trusted. */
+/* Escape a URL. Encoding every unsafe characters but skipping reserved and already-encoded bytes.
+ * Suitable for safely encoding an absolute URL which may be encoded but is not trusted. */
#define rfc1738_escape_unescaped(x) rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE|RFC1738_ESCAPE_CTRLS|RFC1738_ESCAPE_NOPERCENT)
- /**
- * Unescape a URL string according to RFC 1738 specification.
- * String is unescaped in-place
- */
- extern void rfc1738_unescape(char *url);
+/**
+ * Unescape a URL string according to RFC 1738 specification.
+ * String is unescaped in-place
+ */
+extern void rfc1738_unescape(char *url);
#ifdef __cplusplus
}
#endif
#endif /* _SQUID_INCLUDE_RFC1738_H */
+
* Squid accepts up to 255 character Hostname and Fully-Qualified Domain Names.
* Squid still NULL-terminates its FQDN and hotsname strings.
*/
-#define RFC2181_MAXHOSTNAMELEN 256
+#define RFC2181_MAXHOSTNAMELEN 256
/** Back-port macro for old squid code still using SQUIDHOSTNAMELEN without RFC reference. */
-#define SQUIDHOSTNAMELEN RFC2181_MAXHOSTNAMELEN
+#define SQUIDHOSTNAMELEN RFC2181_MAXHOSTNAMELEN
#endif /* _SQUID_INCLUDE_RFC1123_H */
+
#endif
#define HASHLEN 16
- typedef char HASH[HASHLEN];
+typedef char HASH[HASHLEN];
#define HASHHEXLEN 32
- typedef char HASHHEX[HASHHEXLEN + 1];
+typedef char HASHHEX[HASHHEXLEN + 1];
- /* calculate H(A1) as per HTTP Digest spec */
- extern void DigestCalcHA1(
- const char *pszAlg,
- const char *pszUserName,
- const char *pszRealm,
- const char *pszPassword,
- const char *pszNonce,
- const char *pszCNonce,
- HASH HA1,
- HASHHEX SessionKey
- );
+/* calculate H(A1) as per HTTP Digest spec */
+extern void DigestCalcHA1(
+ const char *pszAlg,
+ const char *pszUserName,
+ const char *pszRealm,
+ const char *pszPassword,
+ const char *pszNonce,
+ const char *pszCNonce,
+ HASH HA1,
+ HASHHEX SessionKey
+);
- /* calculate request-digest/response-digest as per HTTP Digest spec */
- extern void DigestCalcResponse(
- const HASHHEX HA1, /* H(A1) */
- const char *pszNonce, /* nonce from server */
- const char *pszNonceCount, /* 8 hex digits */
- const char *pszCNonce, /* client nonce */
- const char *pszQop, /* qop-value: "", "auth", "auth-int" */
- const char *pszMethod, /* method from the request */
- const char *pszDigestUri, /* requested URL */
- const HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
- HASHHEX Response /* request-digest or response-digest */
- );
+/* calculate request-digest/response-digest as per HTTP Digest spec */
+extern void DigestCalcResponse(
+ const HASHHEX HA1, /* H(A1) */
+ const char *pszNonce, /* nonce from server */
+ const char *pszNonceCount, /* 8 hex digits */
+ const char *pszCNonce, /* client nonce */
+ const char *pszQop, /* qop-value: "", "auth", "auth-int" */
+ const char *pszMethod, /* method from the request */
+ const char *pszDigestUri, /* requested URL */
+ const HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
+ HASHHEX Response /* request-digest or response-digest */
+);
- extern void CvtHex(const HASH Bin, HASHHEX Hex);
+extern void CvtHex(const HASH Bin, HASHHEX Hex);
- extern void CvtBin(const HASHHEX Hex, HASH Bin);
+extern void CvtBin(const HASHHEX Hex, HASH Bin);
#ifdef __cplusplus
}
#endif
#endif /* SQUID_RFC2617_H */
+
SQUIDCEXTERN int rfc2671RROptPack(char *buf, size_t sz, ssize_t edns_sz);
#endif /* SQUID_RFC3596_H */
+
#define RFC1035_TYPE_AAAA 28
#endif /* SQUID_RFC3596_H */
+
*
**********************************************************************/
-#define SNMP_PORT 161
-#define SNMP_TRAP_PORT 162
-#define SNMP_MAX_LEN 484
+#define SNMP_PORT 161
+#define SNMP_TRAP_PORT 162
+#define SNMP_MAX_LEN 484
#endif /* SQUID_SNMP_INTERNAL_H */
+
*
***************************************************************************/
-#include <asn1.h> /* Need OID Definition */
-#include <snmp_vars.h> /* Need variable_list */
+#include <asn1.h> /* Need OID Definition */
+#include <snmp_vars.h> /* Need variable_list */
#if 0
-#include <mib.h> /* Then the function definitions */
+#include <mib.h> /* Then the function definitions */
#endif
#endif /* SQUID_SNMP_MIB_H */
+
#include "snmp_impl.h"
#endif /* SQUID_SNMP_H */
+
#define SQUID_SNMP_API_H
/***********************************************************
- Copyright 1989 by Carnegie Mellon University
+ Copyright 1989 by Carnegie Mellon University
All Rights Reserved
/*
* Set fields in session and pdu to the following to get a default or unconfigured value.
*/
-#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */
-#define SNMP_DEFAULT_RETRIES 3
-#define SNMP_DEFAULT_TIMEOUT 1
-#define SNMP_DEFAULT_REMPORT 0
-#define SNMP_DEFAULT_PEERNAME NULL
-#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0
-#define SNMP_DEFAULT_TIME 0
+#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */
+#define SNMP_DEFAULT_RETRIES 3
+#define SNMP_DEFAULT_TIMEOUT 1
+#define SNMP_DEFAULT_REMPORT 0
+#define SNMP_DEFAULT_PEERNAME NULL
+#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0
+#define SNMP_DEFAULT_TIME 0
#define SNMP_DEFAULT_MAXREPETITIONS 5
#define SNMP_DEFAULT_MACREPEATERS 0
extern "C" {
#endif
- /* Parse the buffer pointed to by arg3, of length arg4, into pdu arg2.
- *
- * Returns the community of the incoming PDU, or NULL
- */
- u_char *snmp_parse(struct snmp_session *, struct snmp_pdu *, u_char *, int);
-
- /* Encode pdu arg2 into buffer arg3. arg4 contains the size of
- * the buffer.
- */
- int snmp_build(struct snmp_session *, struct snmp_pdu *, u_char *, int *);
-
- /*
- * struct snmp_session *snmp_open(session)
- * struct snmp_session *session;
- *
- * Sets up the session with the snmp_session information provided
- * by the user. Then opens and binds the necessary UDP port.
- * A handle to the created session is returned (this is different than
- * the pointer passed to snmp_open()). On any error, NULL is returned
- * and snmp_errno is set to the appropriate error code.
- */
+/* Parse the buffer pointed to by arg3, of length arg4, into pdu arg2.
+ *
+ * Returns the community of the incoming PDU, or NULL
+ */
+u_char *snmp_parse(struct snmp_session *, struct snmp_pdu *, u_char *, int);
+
+/* Encode pdu arg2 into buffer arg3. arg4 contains the size of
+ * the buffer.
+ */
+int snmp_build(struct snmp_session *, struct snmp_pdu *, u_char *, int *);
+
+/*
+ * struct snmp_session *snmp_open(session)
+ * struct snmp_session *session;
+ *
+ * Sets up the session with the snmp_session information provided
+ * by the user. Then opens and binds the necessary UDP port.
+ * A handle to the created session is returned (this is different than
+ * the pointer passed to snmp_open()). On any error, NULL is returned
+ * and snmp_errno is set to the appropriate error code.
+ */
#if 0
- struct snmp_session *snmp_open(struct snmp_session *);
-
- /*
- * int snmp_close(session)
- * struct snmp_session *session;
- *
- * Close the input session. Frees all data allocated for the session,
- * dequeues any pending requests, and closes any sockets allocated for
- * the session. Returns 0 on error, 1 otherwise.
- */
- int snmp_close(struct snmp_session *);
-
- /*
- * int snmp_send(session, pdu)
- * struct snmp_session *session;
- * struct snmp_pdu *pdu;
- *
- * Sends the input pdu on the session after calling snmp_build to create
- * a serialized packet. If necessary, set some of the pdu data from the
- * session defaults. Add a request corresponding to this pdu to the list
- * of outstanding requests on this session, then send the pdu.
- * Returns the request id of the generated packet if applicable, otherwise 1.
- * On any error, 0 is returned.
- * The pdu is freed by snmp_send() unless a failure occured.
- */
- int snmp_send(struct snmp_session *, struct snmp_pdu *);
-
- /*
- * void snmp_read(fdset)
- * fd_set *fdset;
- *
- * Checks to see if any of the fd's set in the fdset belong to
- * snmp. Each socket with it's fd set has a packet read from it
- * and snmp_parse is called on the packet received. The resulting pdu
- * is passed to the callback routine for that session. If the callback
- * routine returns successfully, the pdu and it's request are deleted.
- */
- void snmp_read(fd_set *);
-
- /*
- * int snmp_select_info(numfds, fdset, timeout, block)
- * int *numfds;
- * fd_set *fdset;
- * struct timeval *timeout;
- * int *block;
- *
- * Returns info about what snmp requires from a select statement.
- * numfds is the number of fds in the list that are significant.
- * All file descriptors opened for SNMP are OR'd into the fdset.
- * If activity occurs on any of these file descriptors, snmp_read
- * should be called with that file descriptor set.
- *
- * The timeout is the latest time that SNMP can wait for a timeout. The
- * select should be done with the minimum time between timeout and any other
- * timeouts necessary. This should be checked upon each invocation of select.
- * If a timeout is received, snmp_timeout should be called to check if the
- * timeout was for SNMP. (snmp_timeout is idempotent)
- *
- * Block is 1 if the select is requested to block indefinitely, rather than time out.
- * If block is input as 1, the timeout value will be treated as undefined, but it must
- * be available for setting in snmp_select_info. On return, if block is true, the value
- * of timeout will be undefined.
- *
- * snmp_select_info returns the number of open sockets. (i.e. The number of sessions open)
- */
- int snmp_select_info(int *, fd_set *, struct timeval *, int *);
-
- /*
- * void snmp_timeout();
- *
- * snmp_timeout should be called whenever the timeout from snmp_select_info expires,
- * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensive
- * proposition). snmp_timeout checks to see if any of the sessions have an
- * outstanding request that has timed out. If it finds one (or more), and that
- * pdu has more retries available, a new packet is formed from the pdu and is
- * resent. If there are no more retries available, the callback for the session
- * is used to alert the user of the timeout.
- */
- void snmp_timeout(void);
-
- /*
- * This routine must be supplied by the application:
- *
- * int callback(operation, session, reqid, pdu, magic)
- * int operation;
- * struct snmp_session *session; The session authenticated under.
- * int reqid; The request id of this pdu (0 for TRAP)
- * struct snmp_pdu *pdu; The pdu information.
- * void *magic A link to the data for this routine.
- *
- * Returns 1 if request was successful, 0 if it should be kept pending.
- * Any data in the pdu must be copied because it will be freed elsewhere.
- * Operations are defined below:
- */
-
- void snmp_api_stats(void *);
+struct snmp_session *snmp_open(struct snmp_session *);
+
+/*
+ * int snmp_close(session)
+ * struct snmp_session *session;
+ *
+ * Close the input session. Frees all data allocated for the session,
+ * dequeues any pending requests, and closes any sockets allocated for
+ * the session. Returns 0 on error, 1 otherwise.
+ */
+int snmp_close(struct snmp_session *);
+
+/*
+ * int snmp_send(session, pdu)
+ * struct snmp_session *session;
+ * struct snmp_pdu *pdu;
+ *
+ * Sends the input pdu on the session after calling snmp_build to create
+ * a serialized packet. If necessary, set some of the pdu data from the
+ * session defaults. Add a request corresponding to this pdu to the list
+ * of outstanding requests on this session, then send the pdu.
+ * Returns the request id of the generated packet if applicable, otherwise 1.
+ * On any error, 0 is returned.
+ * The pdu is freed by snmp_send() unless a failure occured.
+ */
+int snmp_send(struct snmp_session *, struct snmp_pdu *);
+
+/*
+ * void snmp_read(fdset)
+ * fd_set *fdset;
+ *
+ * Checks to see if any of the fd's set in the fdset belong to
+ * snmp. Each socket with it's fd set has a packet read from it
+ * and snmp_parse is called on the packet received. The resulting pdu
+ * is passed to the callback routine for that session. If the callback
+ * routine returns successfully, the pdu and it's request are deleted.
+ */
+void snmp_read(fd_set *);
+
+/*
+ * int snmp_select_info(numfds, fdset, timeout, block)
+ * int *numfds;
+ * fd_set *fdset;
+ * struct timeval *timeout;
+ * int *block;
+ *
+ * Returns info about what snmp requires from a select statement.
+ * numfds is the number of fds in the list that are significant.
+ * All file descriptors opened for SNMP are OR'd into the fdset.
+ * If activity occurs on any of these file descriptors, snmp_read
+ * should be called with that file descriptor set.
+ *
+ * The timeout is the latest time that SNMP can wait for a timeout. The
+ * select should be done with the minimum time between timeout and any other
+ * timeouts necessary. This should be checked upon each invocation of select.
+ * If a timeout is received, snmp_timeout should be called to check if the
+ * timeout was for SNMP. (snmp_timeout is idempotent)
+ *
+ * Block is 1 if the select is requested to block indefinitely, rather than time out.
+ * If block is input as 1, the timeout value will be treated as undefined, but it must
+ * be available for setting in snmp_select_info. On return, if block is true, the value
+ * of timeout will be undefined.
+ *
+ * snmp_select_info returns the number of open sockets. (i.e. The number of sessions open)
+ */
+int snmp_select_info(int *, fd_set *, struct timeval *, int *);
+
+/*
+ * void snmp_timeout();
+ *
+ * snmp_timeout should be called whenever the timeout from snmp_select_info expires,
+ * but it is idempotent, so snmp_timeout can be polled (probably a cpu expensive
+ * proposition). snmp_timeout checks to see if any of the sessions have an
+ * outstanding request that has timed out. If it finds one (or more), and that
+ * pdu has more retries available, a new packet is formed from the pdu and is
+ * resent. If there are no more retries available, the callback for the session
+ * is used to alert the user of the timeout.
+ */
+void snmp_timeout(void);
+
+/*
+ * This routine must be supplied by the application:
+ *
+ * int callback(operation, session, reqid, pdu, magic)
+ * int operation;
+ * struct snmp_session *session; The session authenticated under.
+ * int reqid; The request id of this pdu (0 for TRAP)
+ * struct snmp_pdu *pdu; The pdu information.
+ * void *magic A link to the data for this routine.
+ *
+ * Returns 1 if request was successful, 0 if it should be kept pending.
+ * Any data in the pdu must be copied because it will be freed elsewhere.
+ * Operations are defined below:
+ */
+
+void snmp_api_stats(void *);
#endif
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_API_H */
+#endif /* SQUID_SNMP_API_H */
+
***************************************************************************/
/* Error return values */
-#define SNMPERR_GENERR -1
-#define SNMPERR_BAD_LOCPORT -2 /* local port was already in use */
-#define SNMPERR_BAD_ADDRESS -3
-#define SNMPERR_BAD_SESSION -4
-#define SNMPERR_TOO_LONG -5 /* data too long for provided buffer */
+#define SNMPERR_GENERR -1
+#define SNMPERR_BAD_LOCPORT -2 /* local port was already in use */
+#define SNMPERR_BAD_ADDRESS -3
+#define SNMPERR_BAD_SESSION -4
+#define SNMPERR_TOO_LONG -5 /* data too long for provided buffer */
#define SNMPERR_ASN_ENCODE -6
#define SNMPERR_ASN_DECODE -7
#define SNMPERR_PACKET_ERR -14
#define SNMPERR_NO_RESPONSE -15
-#define SNMPERR_LAST -16 /* Last error message */
+#define SNMPERR_LAST -16 /* Last error message */
#ifdef __cplusplus
extern "C" {
#endif
- /* extern int snmp_errno */
+/* extern int snmp_errno */
- const char *snmp_api_error(int);
- int snmp_api_errno(void);
+const char *snmp_api_error(int);
+int snmp_api_errno(void);
- const char *api_errstring(int); /* Backwards compatibility */
- void snmp_set_api_error(int);
+const char *api_errstring(int); /* Backwards compatibility */
+void snmp_set_api_error(int);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_API_ERROR_H */
+#endif /* SQUID_SNMP_API_ERROR_H */
+
#include "snmp_pdu.h"
/***********************************************************
- Copyright 1997 by Carnegie Mellon University
+ Copyright 1997 by Carnegie Mellon University
All Rights Reserved
*/
struct request_list {
struct request_list *next_request;
- int request_id; /* request id */
- int retries; /* Number of retries */
- u_int timeout; /* length to wait for timeout */
- struct timeval time; /* Time this request was made */
- struct timeval expire; /* time this request is due to expire */
- struct snmp_pdu *pdu; /* The pdu for this request (saved so it can be retransmitted */
+ int request_id; /* request id */
+ int retries; /* Number of retries */
+ u_int timeout; /* length to wait for timeout */
+ struct timeval time; /* Time this request was made */
+ struct timeval expire; /* time this request is due to expire */
+ struct snmp_pdu *pdu; /* The pdu for this request (saved so it can be retransmitted */
};
/*
};
struct snmp_internal_session {
- int sd; /* socket descriptor for this connection */
- struct sockaddr_in addr; /* address of connected peer */
- struct request_list *requests; /* Info about outstanding requests */
+ int sd; /* socket descriptor for this connection */
+ struct sockaddr_in addr; /* address of connected peer */
+ struct request_list *requests; /* Info about outstanding requests */
};
/* Define these here, as they aren't defined normall under
extern "C" {
#endif
- int snmp_get_socket_session(struct snmp_session *session_);
- int snmp_select_info_session(struct snmp_session *session_, struct timeval *timeout);
- int snmp_timeout_session(struct snmp_session *sp_);
+int snmp_get_socket_session(struct snmp_session *session_);
+int snmp_select_info_session(struct snmp_session *session_, struct timeval *timeout);
+int snmp_timeout_session(struct snmp_session *sp_);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_API_UTIL_H */
+#endif /* SQUID_SNMP_API_UTIL_H */
+
#define SQUID_SNMP_CLIENT_H
/***********************************************************
- Copyright 1988, 1989 by Carnegie Mellon University
+ Copyright 1988, 1989 by Carnegie Mellon University
All Rights Reserved
int waiting;
int status;
/* status codes */
-#define STAT_SUCCESS 0
-#define STAT_ERROR 1
+#define STAT_SUCCESS 0
+#define STAT_ERROR 1
#define STAT_TIMEOUT 2
int reqid;
struct snmp_pdu *pdu;
extern "C" {
#endif
- extern struct synch_state snmp_synch_state;
+extern struct synch_state snmp_synch_state;
- /* Synchronize Input with Agent */
- int snmp_synch_input(int, struct snmp_session *, int,
- struct snmp_pdu *, void *);
+/* Synchronize Input with Agent */
+int snmp_synch_input(int, struct snmp_session *, int,
+ struct snmp_pdu *, void *);
- /* Synchronize Response with Agent */
- int snmp_synch_response(struct snmp_session *, struct snmp_pdu *,
- struct snmp_pdu **);
+/* Synchronize Response with Agent */
+int snmp_synch_response(struct snmp_session *, struct snmp_pdu *,
+ struct snmp_pdu **);
- /* Synchronize Setup */
- void snmp_synch_setup(struct snmp_session *);
+/* Synchronize Setup */
+void snmp_synch_setup(struct snmp_session *);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_CLIENT_H */
+#endif /* SQUID_SNMP_CLIENT_H */
+
extern "C" {
#endif
- int snmp_coexist_V2toV1(struct snmp_pdu *);
- int snmp_coexist_V1toV2(struct snmp_pdu *);
+int snmp_coexist_V2toV1(struct snmp_pdu *);
+int snmp_coexist_V1toV2(struct snmp_pdu *);
#ifdef __cplusplus
}
#endif
#endif /* SQUID_SNMP_COEXISTANCE_H */
+
SQUIDCEXTERN void snmplib_debug(int, const char *,...) PRINTF_FORMAT_ARG2;
#endif /* SQUID_SNMP_DEBUG_H */
+
extern "C" {
#endif
- const char *snmp_errstring(int);
+const char *snmp_errstring(int);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_ERROR_H */
+#endif /* SQUID_SNMP_ERROR_H */
+
*
*/
/***********************************************************
- Copyright 1988, 1989 by Carnegie Mellon University
+ Copyright 1988, 1989 by Carnegie Mellon University
All Rights Reserved
#endif
#endif
-#define SID_MAX_LEN 64
+#define SID_MAX_LEN 64
-#define READ 1
-#define WRITE 0
+#define READ 1
+#define WRITE 0
#define SNMP_RESERVE1 0
#define SNMP_RESERVE2 1
#define SNMP_COMMIT 2
#define SNMP_FREE 3
-#define RONLY 0xAAAA /* read access for everyone */
-#define RWRITE 0xAABA /* add write access for community private */
-#define NOACCESS 0x0000 /* no access for anybody */
+#define RONLY 0xAAAA /* read access for everyone */
+#define RWRITE 0xAABA /* add write access for community private */
+#define NOACCESS 0x0000 /* no access for anybody */
struct trapVar {
oid *varName;
};
#endif /* SQUID_SNMP_IMPL_H */
+
#include "snmp_pdu.h"
-#define SNMP_VERSION_1 0 /* RFC 1157 */
-#define SNMP_VERSION_2 1 /* RFC 1901 */
+#define SNMP_VERSION_1 0 /* RFC 1157 */
+#define SNMP_VERSION_2 1 /* RFC 1901 */
#ifdef __cplusplus
extern "C" {
#endif
- u_char *snmp_msg_Encode(u_char *, int *, u_char *, int, int, struct snmp_pdu *);
- u_char *snmp_msg_Decode(u_char *, int *, u_char *, int *, int *, struct snmp_pdu *);
+u_char *snmp_msg_Encode(u_char *, int *, u_char *, int, int, struct snmp_pdu *);
+u_char *snmp_msg_Decode(u_char *, int *, u_char *, int *, int *, struct snmp_pdu *);
#ifdef __cplusplus
}
#endif
-#endif /* SQUID_SNMP_MSG_H */
+#endif /* SQUID_SNMP_MSG_H */
+
extern "C" {
#endif
- /* An SNMP PDU */
- struct snmp_pdu {
- int command; /* Type of this PDU */
- struct sockaddr_in address; /* Address of peer */
-
- int reqid; /* Integer32: Request id */
- int errstat; /* INTEGER: Error status */
- int errindex; /* INTEGER: Error index */
-
- /* SNMPv2 Bulk Request */
- int non_repeaters; /* INTEGER: */
- int max_repetitions; /* INTEGER: */
-
- struct variable_list *variables; /* Variable Bindings */
-
- /* Trap information */
- oid *enterprise; /* System OID */
- int enterprise_length;
- struct sockaddr_in agent_addr; /* address of object generating trap */
- int trap_type; /* generic trap type */
- int specific_type; /* specific type */
- u_int time; /* Uptime */
- };
-
- struct snmp_pdu *snmp_pdu_create(int);
- struct snmp_pdu *snmp_pdu_clone(struct snmp_pdu *);
- struct snmp_pdu *snmp_pdu_fix(struct snmp_pdu *, int);
- struct snmp_pdu *snmp_fix_pdu(struct snmp_pdu *, int);
- void snmp_free_pdu(struct snmp_pdu *);
- void snmp_pdu_free(struct snmp_pdu *);
-
- u_char *snmp_pdu_encode(u_char *, int *, struct snmp_pdu *);
- u_char *snmp_pdu_decode(u_char *, int *, struct snmp_pdu *);
-
- /* Add a NULL Variable to a PDU */
- void snmp_add_null_var(struct snmp_pdu *, oid *, int);
-
- /* RFC 1905: Protocol Operations for SNMPv2
- *
- * RFC 1157: A Simple Network Management Protocol (SNMP)
- *
- * PDU Types
- */
-#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
+/* An SNMP PDU */
+struct snmp_pdu {
+ int command; /* Type of this PDU */
+ struct sockaddr_in address; /* Address of peer */
+
+ int reqid; /* Integer32: Request id */
+ int errstat; /* INTEGER: Error status */
+ int errindex; /* INTEGER: Error index */
+
+ /* SNMPv2 Bulk Request */
+ int non_repeaters; /* INTEGER: */
+ int max_repetitions; /* INTEGER: */
+
+ struct variable_list *variables; /* Variable Bindings */
+
+ /* Trap information */
+ oid *enterprise; /* System OID */
+ int enterprise_length;
+ struct sockaddr_in agent_addr; /* address of object generating trap */
+ int trap_type; /* generic trap type */
+ int specific_type; /* specific type */
+ u_int time; /* Uptime */
+};
+
+struct snmp_pdu *snmp_pdu_create(int);
+struct snmp_pdu *snmp_pdu_clone(struct snmp_pdu *);
+struct snmp_pdu *snmp_pdu_fix(struct snmp_pdu *, int);
+struct snmp_pdu *snmp_fix_pdu(struct snmp_pdu *, int);
+void snmp_free_pdu(struct snmp_pdu *);
+void snmp_pdu_free(struct snmp_pdu *);
+
+u_char *snmp_pdu_encode(u_char *, int *, struct snmp_pdu *);
+u_char *snmp_pdu_decode(u_char *, int *, struct snmp_pdu *);
+
+/* Add a NULL Variable to a PDU */
+void snmp_add_null_var(struct snmp_pdu *, oid *, int);
+
+/* RFC 1905: Protocol Operations for SNMPv2
+ *
+ * RFC 1157: A Simple Network Management Protocol (SNMP)
+ *
+ * PDU Types
+ */
+#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
#define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
#define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
#ifdef UNUSED_CODE
#define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
-#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /*Obsolete */
+#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /*Obsolete */
#endif
#define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
#ifdef UNUSED_CODE
#define SNMP_PDU_V2TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
#define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
#endif
-#define MAX_BINDINGS 2147483647 /* PDU Defaults */
-#define SNMP_DEFAULT_ERRSTAT -1
-#define SNMP_DEFAULT_ERRINDEX -1
-#define SNMP_DEFAULT_ADDRESS 0
-#define SNMP_DEFAULT_REQID 0
-
- /* RFC 1907: Management Information Base for SNMPv2
- *
- * RFC 1157: A Simple Network Management Protocol (SNMP)
- *
- * Trap Types
- */
+#define MAX_BINDINGS 2147483647 /* PDU Defaults */
+#define SNMP_DEFAULT_ERRSTAT -1
+#define SNMP_DEFAULT_ERRINDEX -1
+#define SNMP_DEFAULT_ADDRESS 0
+#define SNMP_DEFAULT_REQID 0
+
+/* RFC 1907: Management Information Base for SNMPv2
+ *
+ * RFC 1157: A Simple Network Management Protocol (SNMP)
+ *
+ * Trap Types
+ */
#if UNUSED_CODE
#define SNMP_TRAP_COLDSTART (0x0)
#define SNMP_TRAP_WARMSTART (0x1)
#endif
#endif /* SQUID_SNMP_PDU_H */
+
**********************************************************************/
struct snmp_session {
- int Version; /* SNMP Version for this session */
+ int Version; /* SNMP Version for this session */
- u_char *community; /* community for outgoing requests. */
- int community_len; /* Length of community name. */
- int retries; /* Number of retries before timeout. */
- int timeout; /* Number of uS until first timeout, then exponential backoff */
- char *peername; /* Domain name or dotted IP address of default peer */
- unsigned short remote_port; /* UDP port number of peer. */
- unsigned short local_port; /* My UDP port number, 0 for default, picked randomly */
+ u_char *community; /* community for outgoing requests. */
+ int community_len; /* Length of community name. */
+ int retries; /* Number of retries before timeout. */
+ int timeout; /* Number of uS until first timeout, then exponential backoff */
+ char *peername; /* Domain name or dotted IP address of default peer */
+ unsigned short remote_port; /* UDP port number of peer. */
+ unsigned short local_port; /* My UDP port number, 0 for default, picked randomly */
};
#define RECEIVED_MESSAGE 1
-#define TIMED_OUT 2
+#define TIMED_OUT 2
#endif /* SQUID_SNMP_SESSION_H */
+
extern "C" {
#endif
- /* call a function at regular intervals (in seconds): */
- extern void snmp_alarm(int ival, void (*handler) (void));
+/* call a function at regular intervals (in seconds): */
+extern void snmp_alarm(int ival, void (*handler) (void));
- /* service for filedescriptors: */
+/* service for filedescriptors: */
- extern void fd_add(int fd, void (*func) (int fd));
- extern void fd_service(void);
+extern void fd_add(int fd, void (*func) (int fd));
+extern void fd_service(void);
- /* ---------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
- /*
- * SNMP Agent extension for Spacer-Controler Management
- *
- * Copyright (c) 1997 FT/CNET/DES/GRL Olivier Montanuy
- */
+/*
+ * SNMP Agent extension for Spacer-Controler Management
+ *
+ * Copyright (c) 1997 FT/CNET/DES/GRL Olivier Montanuy
+ */
- /* Function to safely copy a string, and ensure the last
- * character is always '\0'. */
- void strcpy_safe(char *str, int str_len, char *val);
+/* Function to safely copy a string, and ensure the last
+ * character is always '\0'. */
+void strcpy_safe(char *str, int str_len, char *val);
- /* Function to get IP address of this agent
- * WARNING: this scans all interfaces (slow) */
- u_long Util_local_ip_address(void);
+/* Function to get IP address of this agent
+ * WARNING: this scans all interfaces (slow) */
+u_long Util_local_ip_address(void);
- /* Function to get the current time in seconds */
- long Util_time_now(void);
+/* Function to get the current time in seconds */
+long Util_time_now(void);
- /* Function to determine how long the agent has been running
- * (WARNING: this seems rather slow) */
- long Util_time_running();
+/* Function to determine how long the agent has been running
+ * (WARNING: this seems rather slow) */
+long Util_time_running();
- /* Read data from file */
- int Util_file_read(char *file, int offset, char *data, int dataSz);
+/* Read data from file */
+int Util_file_read(char *file, int offset, char *data, int dataSz);
- /* Write data into file */
- int Util_file_write(char *file, int offset, char *data, int dataSz);
+/* Write data into file */
+int Util_file_write(char *file, int offset, char *data, int dataSz);
- /* ---------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* SQUID_SNMP_UTIL_H */
+
extern "C" {
#endif
- struct variable_list {
- struct variable_list *next_variable; /* NULL for last variable */
- oid *name; /* Object identifier of variable */
- int name_length; /* number of subid's in name */
- u_char type; /* ASN type of variable */
- union { /* value of variable */
- int *integer;
- u_char *string;
- oid *objid;
- } val;
- int val_len;
- };
-
- struct variable_list *snmp_var_new(oid *, int);
- struct variable_list *snmp_var_new_integer(oid *, int, int, unsigned char);
- struct variable_list *snmp_var_clone(struct variable_list *);
- void snmp_var_free(struct variable_list *);
-
- u_char *snmp_var_EncodeVarBind(u_char *, int *, struct variable_list *, int);
- u_char *snmp_var_DecodeVarBind(u_char *, int *, struct variable_list **, int);
-
-#define MAX_NAME_LEN 64 /* number of subid's in a objid */
-
- /* RFC 1902: Structure of Management Information for SNMPv2
- *
- * Defined Types
- */
+struct variable_list {
+ struct variable_list *next_variable; /* NULL for last variable */
+ oid *name; /* Object identifier of variable */
+ int name_length; /* number of subid's in name */
+ u_char type; /* ASN type of variable */
+ union { /* value of variable */
+ int *integer;
+ u_char *string;
+ oid *objid;
+ } val;
+ int val_len;
+};
+
+struct variable_list *snmp_var_new(oid *, int);
+struct variable_list *snmp_var_new_integer(oid *, int, int, unsigned char);
+struct variable_list *snmp_var_clone(struct variable_list *);
+void snmp_var_free(struct variable_list *);
+
+u_char *snmp_var_EncodeVarBind(u_char *, int *, struct variable_list *, int);
+u_char *snmp_var_DecodeVarBind(u_char *, int *, struct variable_list **, int);
+
+#define MAX_NAME_LEN 64 /* number of subid's in a objid */
+
+/* RFC 1902: Structure of Management Information for SNMPv2
+ *
+ * Defined Types
+ */
#define SMI_INTEGER ASN_INTEGER
#define SMI_STRING ASN_OCTET_STR
#define SMI_OBJID ASN_OBJECT_ID
#define SMI_NULLOBJ ASN_NULL
-#define SMI_IPADDRESS (ASN_APPLICATION | 0) /* OCTET STRING, net byte order */
-#define SMI_COUNTER32 (ASN_APPLICATION | 1) /* INTEGER */
-#define SMI_GAUGE32 (ASN_APPLICATION | 2) /* INTEGER */
+#define SMI_IPADDRESS (ASN_APPLICATION | 0) /* OCTET STRING, net byte order */
+#define SMI_COUNTER32 (ASN_APPLICATION | 1) /* INTEGER */
+#define SMI_GAUGE32 (ASN_APPLICATION | 2) /* INTEGER */
#define SMI_UNSIGNED32 SMI_GAUGE32
-#define SMI_TIMETICKS (ASN_APPLICATION | 3) /* INTEGER */
-#define SMI_OPAQUE (ASN_APPLICATION | 4) /* OCTET STRING */
-#define SMI_COUNTER64 (ASN_APPLICATION | 6) /* INTEGER */
-
- /* constants for enums for the MIB nodes
- * cachePeerAddressType (InetAddressType / ASN_INTEGER)
- * cacheClientAddressType (InetAddressType / ASN_INTEGER)
- * Defined Types
- */
+#define SMI_TIMETICKS (ASN_APPLICATION | 3) /* INTEGER */
+#define SMI_OPAQUE (ASN_APPLICATION | 4) /* OCTET STRING */
+#define SMI_COUNTER64 (ASN_APPLICATION | 6) /* INTEGER */
+
+/* constants for enums for the MIB nodes
+ * cachePeerAddressType (InetAddressType / ASN_INTEGER)
+ * cacheClientAddressType (InetAddressType / ASN_INTEGER)
+ * Defined Types
+ */
#ifndef INETADDRESSTYPE_ENUMS
#define INETADDRESSTYPE_ENUMS
#endif /* INETADDRESSTYPE_ENUMS */
- /*
- * RFC 1905: Protocol Operations for SNMPv2
- *
- * Variable binding.
- *
- * VarBind ::=
- * SEQUENCE {
- * name ObjectName
- * CHOICE {
- * value ObjectSyntax
- * unSpecified NULL
- * noSuchObject[0] NULL
- * noSuchInstance[1] NULL
- * endOfMibView[2] NULL
- * }
- * }
- */
+/*
+ * RFC 1905: Protocol Operations for SNMPv2
+ *
+ * Variable binding.
+ *
+ * VarBind ::=
+ * SEQUENCE {
+ * name ObjectName
+ * CHOICE {
+ * value ObjectSyntax
+ * unSpecified NULL
+ * noSuchObject[0] NULL
+ * noSuchInstance[1] NULL
+ * endOfMibView[2] NULL
+ * }
+ * }
+ */
#define SMI_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) /* noSuchObject[0] */
#define SMI_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) /* noSuchInstance[1] */
#define SMI_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2) /* endOfMibView[2] */
- typedef struct variable variable;
- typedef struct variable_list variable_list;
+typedef struct variable variable;
+typedef struct variable_list variable_list;
#ifdef __cplusplus
}
#endif
#endif /* SQUID_SNMP_VARS_H */
+
SplayNode<V> *result = splay(dataToRemove, compare);
- if (splayLastResult == 0) { /* found it */
+ if (splayLastResult == 0) { /* found it */
SplayNode<V> *newTop;
if (result->left == NULL) {
return newTop;
}
- return result; /* It wasn't there */
+ return result; /* It wasn't there */
}
template<class V>
break;
if ((splayLastResult = compare(dataToFind, top->left->data)) < 0) {
- y = top->left; /* rotate right */
+ y = top->left; /* rotate right */
top->left = y->right;
y->right = top;
top = y;
break;
}
- r->left = top; /* link right */
+ r->left = top; /* link right */
r = top;
top = top->left;
} else if (splayLastResult > 0) {
break;
if ((splayLastResult = compare(dataToFind, top->right->data)) > 0) {
- y = top->right; /* rotate left */
+ y = top->right; /* rotate left */
top->right = y->left;
y->left = top;
top = y;
break;
}
- l->right = top; /* link left */
+ l->right = top; /* link left */
l = top;
top = top->right;
} else {
}
}
- l->right = top->left; /* assemble */
+ l->right = top->left; /* assemble */
r->left = top->right;
top->left = N.right;
top->right = N.left;
#endif /* cplusplus */
#endif /* SQUID_SPLAY_H */
+
#ifndef SQUID_CONFIG_H
#define SQUID_CONFIG_H
-#include "autoconf.h" /* For GNU autoconf variables */
+#include "autoconf.h" /* For GNU autoconf variables */
#if !defined(HAVE_SQUID)
/* sub-packages define their own version details */
#ifdef USE_POSIX_REGEX
#ifndef USE_RE_SYNTAX
-#define USE_RE_SYNTAX REG_EXTENDED /* default Syntax */
+#define USE_RE_SYNTAX REG_EXTENDED /* default Syntax */
#endif
#endif
#include "leakcheck.h"
#endif /* SQUID_CONFIG_H */
+
#include <security.h>
#include <sspi.h>
- typedef char * SSP_blobP;
+typedef char * SSP_blobP;
#define WINNT_SECURITY_DLL "security.dll"
#define WIN2K_SECURITY_DLL "secur32.dll"
#define SSP_OK 1
#define SSP_ERROR 2
- HMODULE LoadSecurityDll(int, const char *);
- void UnloadSecurityDll(void);
- BOOL WINAPI SSP_LogonUser(PTSTR, PTSTR, PTSTR);
- BOOL WINAPI SSP_ValidateNTLMCredentials(PVOID, int, char *);
- const char * WINAPI SSP_ValidateNegotiateCredentials(PVOID, int, PBOOL, int *, char *);
- const char * WINAPI SSP_MakeChallenge(PVOID, int);
- const char * WINAPI SSP_MakeNegotiateBlob(PVOID, int, PBOOL, int *, char *);
+HMODULE LoadSecurityDll(int, const char *);
+void UnloadSecurityDll(void);
+BOOL WINAPI SSP_LogonUser(PTSTR, PTSTR, PTSTR);
+BOOL WINAPI SSP_ValidateNTLMCredentials(PVOID, int, char *);
+const char * WINAPI SSP_ValidateNegotiateCredentials(PVOID, int, PBOOL, int *, char *);
+const char * WINAPI SSP_MakeChallenge(PVOID, int);
+const char * WINAPI SSP_MakeNegotiateBlob(PVOID, int, PBOOL, int *, char *);
- extern BOOL Use_Unicode;
- extern BOOL NTLM_LocalCall;
+extern BOOL Use_Unicode;
+extern BOOL NTLM_LocalCall;
#if defined(__cplusplus)
}
#endif /* _SQUID_WINDOWS_ */
#endif /* LIBSSPWIN32_H_ */
+
SQUIDCEXTERN unsigned int RoundTo(const unsigned int num, const unsigned int what);
#endif /* SQUID_UTIL_H */
+
char *uudecode(const char *);
#endif /* _SQUID_UUDECODE_H */
+
#ifndef APP_FULLNAME
#define APP_FULLNAME PACKAGE "/" VERSION
#endif
+
SQUIDCEXTERN int xusleep(unsigned int);
#endif /* _INC_XUSLEEP_H */
+
#include "util.h"
int splayLastResult = 0;
+
/* One quantum of four encoding characters/24 bit */
if (j+4 <= result_size) {
// Speed optimization: plenty of space, avoid some per-byte checks.
- result[j++] = (val >> 16) & 0xff; /* High 8 bits */
- result[j++] = (val >> 8) & 0xff; /* Mid 8 bits */
- result[j++] = val & 0xff; /* Low 8 bits */
+ result[j++] = (val >> 16) & 0xff; /* High 8 bits */
+ result[j++] = (val >> 8) & 0xff; /* Mid 8 bits */
+ result[j++] = val & 0xff; /* Low 8 bits */
} else {
// part-quantum goes a bit slower with per-byte checks
- result[j++] = (val >> 16) & 0xff; /* High 8 bits */
+ result[j++] = (val >> 16) & 0xff; /* High 8 bits */
if (j == result_size)
return j;
- result[j++] = (val >> 8) & 0xff; /* Mid 8 bits */
+ result[j++] = (val >> 8) & 0xff; /* Mid 8 bits */
if (j == result_size)
return j;
- result[j++] = val & 0xff; /* Low 8 bits */
+ result[j++] = val & 0xff; /* Low 8 bits */
}
if (j == result_size)
return j;
}
return (out_cnt >= result_size?result_size:out_cnt);
}
+
return NULL;
return out;
}
+
#include <dirent.h>
#define WIN32_LEAN_AND_MEAN
-#include <windows.h> /* for GetFileAttributes */
+#include <windows.h> /* for GetFileAttributes */
-#define SUFFIX ("*")
-#define SLASH ("\\")
+#define SUFFIX ("*")
+#define SLASH ("\\")
/*
* opendir
}
}
#endif /* _SQUID_WINDOWS_ */
+
xstrncpy(buf, hp->h_name, RFC2181_MAXHOSTNAMELEN);
return buf;
}
+
#include <stdlib.h>
#include <string.h>
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
-char *optarg; /* argument associated with option */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
-#define BADCH (int)'?'
-#define BADARG (int)':'
-#define EMSG (char*)""
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG (char*)""
/*
* getopt --
char *const *nargv;
const char *ostr;
{
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
- if (optreset || !*place) { /* update scanning pointer */
+ if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
- if (place[1] && *++place == '-') { /* found "--" */
+ if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
- } /* option letter okay? */
+ } /* option letter okay? */
if ((optopt = (int) *place++) == (int) ':' ||
!(oli = strchr(ostr, optopt))) {
/*
"%s: illegal option -- %c\n", __FILE__, optopt);
return (BADCH);
}
- if (*++oli != ':') { /* don't need argument */
+ if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
- } else { /* need an argument */
- if (*place) /* no white space */
+ } else { /* need an argument */
+ if (*place) /* no white space */
optarg = place;
- else if (nargc <= ++optind) { /* no arg */
+ else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
"%s: option requires an argument -- %c\n",
__FILE__, optopt);
return (BADCH);
- } else /* white space */
+ } else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
- return (optopt); /* dump back option letter */
+ return (optopt); /* dump back option letter */
}
+
break;
case 7:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 6:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 5:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 4:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 3:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 2:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 1:
HASH4;
}
exit(0);
}
#endif
+
static void _heap_swap_element(heap * hp, heap_node * elm1, heap_node * elm2);
static int _heap_node_exist(heap * hp, int id);
-#ifdef HEAP_DEBUG
+#ifdef HEAP_DEBUG
void _heap_print_tree(heap * hp, heap_node * node);
#endif /* HEAP_DEBUG */
(void) 0;
} else if (hp->last > 0) {
if (lastNode->key < hp->nodes[Parent(lastNode->id)]->key)
- _heap_ify_up(hp, lastNode); /* COOL! */
+ _heap_ify_up(hp, lastNode); /* COOL! */
_heap_ify_down(hp, lastNode);
}
return data;
* heapify operation.
*/
-#ifndef heap_gen_key
+#ifndef heap_gen_key
/*
* Function to generate keys. See macro definition in heap.h.
*/
mutex_lock(hp->lock);
data = hp->nodes[0]->data;
- heap_delete(hp, hp->nodes[0]); /* Delete the root */
+ heap_delete(hp, hp->nodes[0]); /* Delete the root */
mutex_unlock(hp->lock);
return data;
}
-#ifndef heap_nodes
+#ifndef heap_nodes
/*
* Current number of nodes in HP.
*/
}
#endif /* heap_nodes */
-#ifndef heap_empty
+#ifndef heap_empty
/*
* Determine if the heap is empty. Returns 1 if HP has no elements and 0
* otherwise.
parentNode = hp->nodes[Parent(elm->id)];
if (parentNode->key <= elm->key)
break;
- _heap_swap_element(hp, parentNode, elm); /* Demote the parent. */
+ _heap_swap_element(hp, parentNode, elm); /* Demote the parent. */
}
}
hp->nodes[elm2->id] = elm2;
}
-#ifdef NOTDEF
+#ifdef NOTDEF
/*
* Copy KEY and DATA fields of SRC to DEST. ID field is NOT copied.
*/
return correct;
}
-#ifdef MEASURE_HEAP_SKEW
+#ifdef MEASURE_HEAP_SKEW
/****************************************************************************
* Heap skew computation
{
heap_node **nodes;
long id, diff, skew = 0;
-#ifdef HEAP_DEBUG_SKEW
+#ifdef HEAP_DEBUG_SKEW
long skewsq = 0;
#endif /* HEAP_DEBUG_SKEW */
float norm = 0;
diff = id - nodes[id]->id;
skew += abs(diff);
-#ifdef HEAP_DEBUG_SKEW
+#ifdef HEAP_DEBUG_SKEW
skewsq += diff * diff;
-#ifdef HEAP_DEBUG_ALL
+#ifdef HEAP_DEBUG_ALL
printf("%d\tKey = %f, diff = %d\n", id, nodes[id]->key, diff);
#endif /* HEAP_DEBUG */
#endif /* HEAP_DEBUG_SKEW */
}
#endif /* MEASURE_HEAP_SKEW */
+
*dst = '\0';
return (buf);
}
+
return head->add(aString, theLength, privatedata, transform);
}
+
}
#endif /* LIBTRIE_SQUID_H */
+
#endif /* __cplusplus */
#endif /* LIBTRIE_TRIECHARTRANSFORM_H */
+
}
}
#endif /* LIBTRIE_TRIENODE_H */
+
"1234567890123456789012345678901234567890");
return 0;
}
+
#if !HAVE_NETTLE_MD5_H
#if HAVE_STRING_H
-#include <string.h> /* for memcpy() */
+#include <string.h> /* for memcpy() */
#endif
#if HAVE_SYS_TYPES_H
-#include <sys/types.h> /* for stupid systems */
+#include <sys/types.h> /* for stupid systems */
#endif
#ifdef WORDS_BIGENDIAN
t = ctx->bytes[0];
if ((ctx->bytes[0] = t + len) < t)
- ctx->bytes[1]++; /* Carry from low to high */
+ ctx->bytes[1]++; /* Carry from low to high */
- t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
+ t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
if (t > len) {
memcpy((uint8_t *) ctx->in + 64 - t, buf, len);
return;
void
SquidMD5Final(unsigned char digest[16], struct SquidMD5Context *ctx)
{
- int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
+ int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
uint8_t *p = (uint8_t *) ctx->in + count;
/* Set the first char of padding to 0x80. There is always room. */
/* Bytes of padding needed to make 56 bytes (-8..55) */
count = 56 - 1 - count;
- if (count < 0) { /* Padding forces an extra block */
+ if (count < 0) { /* Padding forces an extra block */
memset(p, 0, count + 8);
byteSwap(ctx->in, 16);
SquidMD5Transform(ctx->buf, ctx->in);
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f,w,x,y,z,in,s) \
- (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
+ (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
#endif /* !ASM_MD5 */
#endif /* HAVE_ETTLE_MD5_H */
+
#endif
#include "ntlmauth/ntlmauth.h"
-#include "util.h" /* for base64-related stuff */
+#include "util.h" /* for base64-related stuff */
/* ************************************************************************* */
/* DEBUG functions */
const uint32_t flags)
{
int pl = 0;
- memset(ch, 0, sizeof(ntlm_challenge)); /* reset */
- memcpy(ch->hdr.signature, "NTLMSSP", 8); /* set the signature */
- ch->hdr.type = htole32(NTLM_CHALLENGE); /* this is a challenge */
+ memset(ch, 0, sizeof(ntlm_challenge)); /* reset */
+ memcpy(ch->hdr.signature, "NTLMSSP", 8); /* set the signature */
+ ch->hdr.type = htole32(NTLM_CHALLENGE); /* this is a challenge */
if (domain != NULL) {
// silently truncate the domain if it exceeds 2^16-1 bytes.
// NTLM packets normally expect 2^8 bytes of domain.
ntlm_add_to_payload(&ch->hdr, ch->payload, &pl, &ch->target, domain, dlen);
}
ch->flags = htole32(flags);
- ch->context_low = 0; /* check this out */
+ ch->context_low = 0; /* check this out */
ch->context_high = 0;
memcpy(ch->challenge, challenge_nonce, challenge_nonce_len);
}
* this function will only insert data if the packet contains any. Otherwise
* the buffers will be left untouched.
*
- * \retval NTLM_ERR_NONE username present, maybe also domain.
- * \retval NTLM_ERR_PROTOCOL packet type is not an authentication packet.
- * \retval NTLM_ERR_LOGON no username.
- * \retval NTLM_ERR_BLOB domain field is apparently larger than the packet.
+ * \retval NTLM_ERR_NONE username present, maybe also domain.
+ * \retval NTLM_ERR_PROTOCOL packet type is not an authentication packet.
+ * \retval NTLM_ERR_LOGON no username.
+ * \retval NTLM_ERR_BLOB domain field is apparently larger than the packet.
*/
int
ntlm_unpack_auth(const ntlm_authenticate *auth, char *user, char *domain, const int32_t size)
return NTLM_ERR_NONE;
}
+
extern "C" {
#endif
- /* Used internally. Microsoft seems to think this is right, I believe them.
- * Right. */
-#define NTLM_MAX_FIELD_LENGTH 300 /* max length of an NTLMSSP field */
+/* Used internally. Microsoft seems to think this is right, I believe them.
+ * Right. */
+#define NTLM_MAX_FIELD_LENGTH 300 /* max length of an NTLMSSP field */
- /* max length of the BLOB data. (and helper input/output buffer) */
+/* max length of the BLOB data. (and helper input/output buffer) */
#define NTLM_BLOB_BUFFER_SIZE 10240
- /* Here start the NTLMSSP definitions */
+/* Here start the NTLMSSP definitions */
- /* these are marked as "extra" fields */
+/* these are marked as "extra" fields */
#define NTLM_REQUEST_INIT_RESPONSE 0x100000
#define NTLM_REQUEST_ACCEPT_RESPONSE 0x200000
#define NTLM_REQUEST_NON_NT_SESSION_KEY 0x400000
- /* NTLM error codes */
+/* NTLM error codes */
#define NTLM_ERR_INTERNAL -3
#define NTLM_ERR_BLOB -2
#define NTLM_ERR_BAD_PROTOCOL -1
#define NTLM_ERR_NONE 0 /* aka. SMBLM_ERR_NONE */
- /* codes used by smb_lm helper */
+/* codes used by smb_lm helper */
#define NTLM_ERR_SERVER 1 /* aka. SMBLM_ERR_SERVER */
#define NTLM_ERR_PROTOCOL 2 /* aka. SMBLM_ERR_PROTOCOL */
#define NTLM_ERR_LOGON 3 /* aka. SMBLM_ERR_LOGON */
#define NTLM_ERR_UNTRUSTED_DOMAIN 4
#define NTLM_ERR_NOT_CONNECTED 10
- /* codes used by mswin_ntlmsspi helper */
+/* codes used by mswin_ntlmsspi helper */
#define NTLM_SSPI_ERROR 1
#define NTLM_BAD_NTGROUP 2
#define NTLM_BAD_REQUEST 3
- /* TODO: reduce the above codes down to one set non-overlapping. */
-
- /** String header. String data resides at the end of the request */
- typedef struct _strhdr {
- int16_t len; /**< Length in bytes */
- int16_t maxlen; /**< Allocated space in bytes */
- int32_t offset; /**< Offset from start of request */
- } strhdr;
-
- /** We use this to keep data/length couples. */
- typedef struct _lstring {
- int32_t l; /**< length, -1 if empty */
- char *str; /**< the string. NULL if not initialized */
- } lstring;
-
- /** Debug dump the given flags field to stderr */
- void ntlm_dump_ntlmssp_flags(const uint32_t flags);
-
- /* ************************************************************************* */
- /* Packet and Payload structures and handling functions */
- /* ************************************************************************* */
-
- /* NTLM request types that we know about */
-#define NTLM_ANY 0
-#define NTLM_NEGOTIATE 1
-#define NTLM_CHALLENGE 2
-#define NTLM_AUTHENTICATE 3
-
- /** This is an header common to all packets, it's used to discriminate
- * among the different packet signature types.
- */
- typedef struct _ntlmhdr {
- char signature[8]; /**< "NTLMSSP" */
- int32_t type; /**< One of the NTLM_* types above. */
- } ntlmhdr;
-
- /** Validate the packet type matches one we want. */
- int ntlm_validate_packet(const ntlmhdr *packet, const int32_t type);
-
- /** Retrieve a string from the NTLM packet payload. */
- lstring ntlm_fetch_string(const ntlmhdr *packet,
- const int32_t packet_length,
- const strhdr *str,
- const uint32_t flags);
-
- /** Append a string to the NTLM packet payload. */
- void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
- char *payload,
- int *payload_length,
- strhdr * hdr,
- const char *toadd,
- const uint16_t toadd_length);
-
- /* ************************************************************************* */
- /* Negotiate Packet structures and functions */
- /* ************************************************************************* */
-
- /* negotiate request flags */
+/* TODO: reduce the above codes down to one set non-overlapping. */
+
+/** String header. String data resides at the end of the request */
+typedef struct _strhdr {
+ int16_t len; /**< Length in bytes */
+ int16_t maxlen; /**< Allocated space in bytes */
+ int32_t offset; /**< Offset from start of request */
+} strhdr;
+
+/** We use this to keep data/length couples. */
+typedef struct _lstring {
+ int32_t l; /**< length, -1 if empty */
+ char *str; /**< the string. NULL if not initialized */
+} lstring;
+
+/** Debug dump the given flags field to stderr */
+void ntlm_dump_ntlmssp_flags(const uint32_t flags);
+
+/* ************************************************************************* */
+/* Packet and Payload structures and handling functions */
+/* ************************************************************************* */
+
+/* NTLM request types that we know about */
+#define NTLM_ANY 0
+#define NTLM_NEGOTIATE 1
+#define NTLM_CHALLENGE 2
+#define NTLM_AUTHENTICATE 3
+
+/** This is an header common to all packets, it's used to discriminate
+ * among the different packet signature types.
+ */
+typedef struct _ntlmhdr {
+ char signature[8]; /**< "NTLMSSP" */
+ int32_t type; /**< One of the NTLM_* types above. */
+} ntlmhdr;
+
+/** Validate the packet type matches one we want. */
+int ntlm_validate_packet(const ntlmhdr *packet, const int32_t type);
+
+/** Retrieve a string from the NTLM packet payload. */
+lstring ntlm_fetch_string(const ntlmhdr *packet,
+ const int32_t packet_length,
+ const strhdr *str,
+ const uint32_t flags);
+
+/** Append a string to the NTLM packet payload. */
+void ntlm_add_to_payload(const ntlmhdr *packet_hdr,
+ char *payload,
+ int *payload_length,
+ strhdr * hdr,
+ const char *toadd,
+ const uint16_t toadd_length);
+
+/* ************************************************************************* */
+/* Negotiate Packet structures and functions */
+/* ************************************************************************* */
+
+/* negotiate request flags */
#define NTLM_NEGOTIATE_UNICODE 0x0001
#define NTLM_NEGOTIATE_ASCII 0x0002
#define NTLM_NEGOTIATE_REQUEST_TARGET 0x0004
#define NTLM_NEGOTIATE_THIS_IS_LOCAL_CALL 0x4000
#define NTLM_NEGOTIATE_ALWAYS_SIGN 0x8000
- /** Negotiation request sent by client */
- typedef struct _ntlm_negotiate {
- ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x1) */
- uint32_t flags; /**< Request flags */
- strhdr domain; /**< Domain we wish to authenticate in */
- strhdr workstation; /**< Client workstation name */
- char payload[256]; /**< String data */
- } ntlm_negotiate;
+/** Negotiation request sent by client */
+typedef struct _ntlm_negotiate {
+ ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x1) */
+ uint32_t flags; /**< Request flags */
+ strhdr domain; /**< Domain we wish to authenticate in */
+ strhdr workstation; /**< Client workstation name */
+ char payload[256]; /**< String data */
+} ntlm_negotiate;
- /* ************************************************************************* */
- /* Challenge Packet structures and functions */
- /* ************************************************************************* */
+/* ************************************************************************* */
+/* Challenge Packet structures and functions */
+/* ************************************************************************* */
#define NTLM_NONCE_LEN 8
- /* challenge request flags */
+/* challenge request flags */
#define NTLM_CHALLENGE_TARGET_IS_DOMAIN 0x10000
#define NTLM_CHALLENGE_TARGET_IS_SERVER 0x20000
#define NTLM_CHALLENGE_TARGET_IS_SHARE 0x40000
- /** Challenge request sent by server. */
- typedef struct _ntlm_challenge {
- ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x2) */
- strhdr target; /**< Authentication target (domain/server ...) */
- uint32_t flags; /**< Request flags */
- u_char challenge[NTLM_NONCE_LEN]; /**< Challenge string */
- uint32_t context_low; /**< LS part of the server context handle */
- uint32_t context_high; /**< MS part of the server context handle */
- char payload[256]; /**< String data */
- } ntlm_challenge;
-
- /* Size of the ntlm_challenge structures formatted fields (excluding payload) */
-#define NTLM_CHALLENGE_HEADER_OFFSET (sizeof(ntlm_challenge)-256)
-
- /** Generate a challenge request nonce. */
- void ntlm_make_nonce(char *nonce);
-
- /** Generate a challenge request Blob to be sent to the client.
- * Will silently truncate the domain value at 2^16-1 bytes if larger.
- */
- void ntlm_make_challenge(ntlm_challenge *ch,
- const char *domain,
- const char *domain_controller,
- const char *challenge_nonce,
- const int challenge_nonce_len,
- const uint32_t flags);
-
- /* ************************************************************************* */
- /* Authenticate Packet structures and functions */
- /* ************************************************************************* */
-
- /** Authentication request sent by client in response to challenge */
- typedef struct _ntlm_authenticate {
- ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x3) */
- strhdr lmresponse; /**< LANMAN challenge response */
- strhdr ntresponse; /**< NT challenge response */
- strhdr domain; /**< Domain to authenticate against */
- strhdr user; /**< Username */
- strhdr workstation; /**< Workstation name */
- strhdr sessionkey; /**< Session key for server's use */
- uint32_t flags; /**< Request flags */
- char payload[256 * 6]; /**< String data */
- } ntlm_authenticate;
-
- /** Unpack username and domain out of a packet payload. */
- int ntlm_unpack_auth(const ntlm_authenticate *auth,
- char *user,
- char *domain,
- const int32_t size);
+/** Challenge request sent by server. */
+typedef struct _ntlm_challenge {
+ ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x2) */
+ strhdr target; /**< Authentication target (domain/server ...) */
+ uint32_t flags; /**< Request flags */
+ u_char challenge[NTLM_NONCE_LEN]; /**< Challenge string */
+ uint32_t context_low; /**< LS part of the server context handle */
+ uint32_t context_high; /**< MS part of the server context handle */
+ char payload[256]; /**< String data */
+} ntlm_challenge;
+
+/* Size of the ntlm_challenge structures formatted fields (excluding payload) */
+#define NTLM_CHALLENGE_HEADER_OFFSET (sizeof(ntlm_challenge)-256)
+
+/** Generate a challenge request nonce. */
+void ntlm_make_nonce(char *nonce);
+
+/** Generate a challenge request Blob to be sent to the client.
+ * Will silently truncate the domain value at 2^16-1 bytes if larger.
+ */
+void ntlm_make_challenge(ntlm_challenge *ch,
+ const char *domain,
+ const char *domain_controller,
+ const char *challenge_nonce,
+ const int challenge_nonce_len,
+ const uint32_t flags);
+
+/* ************************************************************************* */
+/* Authenticate Packet structures and functions */
+/* ************************************************************************* */
+
+/** Authentication request sent by client in response to challenge */
+typedef struct _ntlm_authenticate {
+ ntlmhdr hdr; /**< "NTLMSSP" , LSWAP(0x3) */
+ strhdr lmresponse; /**< LANMAN challenge response */
+ strhdr ntresponse; /**< NT challenge response */
+ strhdr domain; /**< Domain to authenticate against */
+ strhdr user; /**< Username */
+ strhdr workstation; /**< Workstation name */
+ strhdr sessionkey; /**< Session key for server's use */
+ uint32_t flags; /**< Request flags */
+ char payload[256 * 6]; /**< String data */
+} ntlm_authenticate;
+
+/** Unpack username and domain out of a packet payload. */
+int ntlm_unpack_auth(const ntlm_authenticate *auth,
+ char *user,
+ char *domain,
+ const int32_t size);
#if __cplusplus
}
#endif
#endif /* SQUID_NTLMAUTH_H */
+
}
#endif /* SQUID_LIBNTLMAUTH_SUPPORT_BITS_CCI */
+
#endif
#endif /* SQUID_LIB_NTLMAUTH_SUPPORT_ENDIAN_H */
+
/* Private stuff */
/* new stuff */
-#define MAXSTACKDEPTH 512
+#define MAXSTACKDEPTH 512
struct _callstack_entry {
- int timer; /* index into timers array */
+ int timer; /* index into timers array */
const char *name;
hrtime_t start, stop, accum;
};
}
#endif /* USE_XPROF_STATS */
+
#define XP_NOBEST (hrtime_t)-1
- typedef struct _xprof_stats_node xprof_stats_node;
+typedef struct _xprof_stats_node xprof_stats_node;
- typedef struct _xprof_stats_data xprof_stats_data;
+typedef struct _xprof_stats_data xprof_stats_data;
- struct _xprof_stats_data {
- hrtime_t start;
- hrtime_t stop;
- hrtime_t delta;
- hrtime_t best;
- hrtime_t worst;
- hrtime_t count;
- hrtime_t accum;
- int64_t summ;
- };
+struct _xprof_stats_data {
+ hrtime_t start;
+ hrtime_t stop;
+ hrtime_t delta;
+ hrtime_t best;
+ hrtime_t worst;
+ hrtime_t count;
+ hrtime_t accum;
+ int64_t summ;
+};
- struct _xprof_stats_node {
- const char *name;
- xprof_stats_data accu;
- xprof_stats_data hist;
- };
+struct _xprof_stats_node {
+ const char *name;
+ xprof_stats_data accu;
+ xprof_stats_data hist;
+};
- typedef xprof_stats_node TimersArray[1];
+typedef xprof_stats_node TimersArray[1];
- /* public Data */
- extern TimersArray *xprof_Timers;
+/* public Data */
+extern TimersArray *xprof_Timers;
- /* Exported functions */
- extern void xprof_start(xprof_type type, const char *timer);
- extern void xprof_stop(xprof_type type, const char *timer);
- extern void xprof_event(void *data);
+/* Exported functions */
+extern void xprof_start(xprof_type type, const char *timer);
+extern void xprof_stop(xprof_type type, const char *timer);
+extern void xprof_event(void *data);
#define PROF_start(probename) xprof_start(XPROF_##probename, #probename)
#define PROF_stop(probename) xprof_stop(XPROF_##probename, #probename)
}
#endif
#endif /* _PROFILING_H_ */
+
{
hrtime_t regs;
-asm volatile ("rdtsc":"=A" (regs));
+ asm volatile ("rdtsc":"=A" (regs));
return regs;
/* We need return value, we rely on CC to optimise out needless subf calls */
/* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
uint32_t lo, hi;
// Based on an example in Wikipedia
/* We cannot use "=A", since this would use %rax on x86_64 */
-asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
+ asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
return (hrtime_t)hi << 32 | lo;
}
{
hrtime_t regs;
-asm volatile ("rpcc %0" : "=r" (regs));
+ asm volatile ("rpcc %0" : "=r" (regs));
return regs;
}
#endif /* USE_XPROF_STATS */
#endif /* _PROFILING_H_ */
+
/* AUTO-GENERATED FILE */
#if USE_XPROF_STATS
typedef enum {
- XPROF_PROF_UNACCOUNTED,
-XPROF_aclCheckFast,
-XPROF_ACL_matches,
-XPROF_calloc,
-XPROF_clientSocketRecipient,
-XPROF_comm_accept,
-XPROF_comm_check_incoming,
-XPROF_comm_close,
-XPROF_comm_connect_addr,
-XPROF_comm_handle_ready_fd,
-XPROF_commHandleWrite,
-XPROF_comm_open,
-XPROF_comm_poll_normal,
-XPROF_comm_poll_prep_pfds,
-XPROF_comm_read_handler,
-XPROF_comm_udp_sendto,
-XPROF_comm_write_handler,
-XPROF_diskHandleRead,
-XPROF_diskHandleWrite,
-XPROF_esiExpressionEval,
-XPROF_esiParsing,
-XPROF_esiProcessing,
-XPROF_eventRun,
-XPROF_file_close,
-XPROF_file_open,
-XPROF_file_read,
-XPROF_file_write,
-XPROF_free,
-XPROF_free_const,
-XPROF_hash_lookup,
-XPROF_headersEnd,
-XPROF_HttpHeaderClean,
-XPROF_HttpHeader_getCc,
-XPROF_HttpHeaderParse,
-XPROF_HttpMsg_httpMsgParseStep,
-XPROF_HttpParserParseReqLine,
-XPROF_httpRequestFree,
-XPROF_HttpServer_parseOneRequest,
-XPROF_httpStart,
-XPROF_HttpStateData_processReplyBody,
-XPROF_HttpStateData_processReplyHeader,
-XPROF_InvokeHandlers,
-XPROF_malloc,
-XPROF_MemBuf_append,
-XPROF_MemBuf_consume,
-XPROF_MemBuf_consumeWhitespace,
-XPROF_MemBuf_grow,
-XPROF_mem_hdr_write,
-XPROF_MemObject_write,
-XPROF_PROF_OVERHEAD,
-XPROF_read,
-XPROF_realloc,
-XPROF_recv,
-XPROF_send,
-XPROF_SignalEngine_checkEvents,
-XPROF_storeClient_kickReads,
-XPROF_storeDirCallback,
-XPROF_StoreEntry_write,
-XPROF_storeGet,
-XPROF_storeGetMemSpace,
-XPROF_storeMaintainSwapSpace,
-XPROF_storeRelease,
-XPROF_StringAllocAndFill,
-XPROF_StringAppend,
-XPROF_StringClean,
-XPROF_StringInitBuf,
-XPROF_StringReset,
-XPROF_write,
-XPROF_xcalloc,
-XPROF_xmalloc,
-XPROF_xrealloc,
- XPROF_LAST } xprof_type;
+ XPROF_PROF_UNACCOUNTED,
+ XPROF_aclCheckFast,
+ XPROF_ACL_matches,
+ XPROF_calloc,
+ XPROF_clientSocketRecipient,
+ XPROF_comm_accept,
+ XPROF_comm_check_incoming,
+ XPROF_comm_close,
+ XPROF_comm_connect_addr,
+ XPROF_comm_handle_ready_fd,
+ XPROF_commHandleWrite,
+ XPROF_comm_open,
+ XPROF_comm_poll_normal,
+ XPROF_comm_poll_prep_pfds,
+ XPROF_comm_read_handler,
+ XPROF_comm_udp_sendto,
+ XPROF_comm_write_handler,
+ XPROF_diskHandleRead,
+ XPROF_diskHandleWrite,
+ XPROF_esiExpressionEval,
+ XPROF_esiParsing,
+ XPROF_esiProcessing,
+ XPROF_eventRun,
+ XPROF_file_close,
+ XPROF_file_open,
+ XPROF_file_read,
+ XPROF_file_write,
+ XPROF_free,
+ XPROF_free_const,
+ XPROF_hash_lookup,
+ XPROF_headersEnd,
+ XPROF_HttpHeaderClean,
+ XPROF_HttpHeader_getCc,
+ XPROF_HttpHeaderParse,
+ XPROF_HttpMsg_httpMsgParseStep,
+ XPROF_HttpParserParseReqLine,
+ XPROF_httpRequestFree,
+ XPROF_HttpServer_parseOneRequest,
+ XPROF_httpStart,
+ XPROF_HttpStateData_processReplyBody,
+ XPROF_HttpStateData_processReplyHeader,
+ XPROF_InvokeHandlers,
+ XPROF_malloc,
+ XPROF_MemBuf_append,
+ XPROF_MemBuf_consume,
+ XPROF_MemBuf_consumeWhitespace,
+ XPROF_MemBuf_grow,
+ XPROF_mem_hdr_write,
+ XPROF_MemObject_write,
+ XPROF_PROF_OVERHEAD,
+ XPROF_read,
+ XPROF_realloc,
+ XPROF_recv,
+ XPROF_send,
+ XPROF_SignalEngine_checkEvents,
+ XPROF_storeClient_kickReads,
+ XPROF_storeDirCallback,
+ XPROF_StoreEntry_write,
+ XPROF_storeGet,
+ XPROF_storeGetMemSpace,
+ XPROF_storeMaintainSwapSpace,
+ XPROF_storeRelease,
+ XPROF_StringAllocAndFill,
+ XPROF_StringAppend,
+ XPROF_StringClean,
+ XPROF_StringInitBuf,
+ XPROF_StringReset,
+ XPROF_write,
+ XPROF_xcalloc,
+ XPROF_xmalloc,
+ XPROF_xrealloc,
+ XPROF_LAST
+} xprof_type;
#endif
#endif
+
#define rn_l rn_u.rn_node.rn_L
#define rn_r rn_u.rn_node.rn_R
#define rm_mask rm_rmu.rmu_mask
-#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */
+#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */
/* Helper macros */
#define squid_Bcmp(a, b, l) (l == 0 ? 0 : memcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))
#define squid_R_Malloc(p, t, n) (p = (t) xmalloc((unsigned int)(n)))
#define squid_Free(p) xfree((char *)p)
#define squid_MKGet(m) {\
- if (squid_rn_mkfreelist) {\
- m = squid_rn_mkfreelist; \
- squid_rn_mkfreelist = (m)->rm_mklist; \
- } else \
- squid_R_Malloc(m, struct squid_radix_mask *, sizeof (*(m)));\
- }
+ if (squid_rn_mkfreelist) {\
+ m = squid_rn_mkfreelist; \
+ squid_rn_mkfreelist = (m)->rm_mklist; \
+ } else \
+ squid_R_Malloc(m, struct squid_radix_mask *, sizeof (*(m)));\
+ }
#define squid_MKFree(m) { (m)->rm_mklist = squid_rn_mkfreelist; squid_rn_mkfreelist = (m);}
t = t->rn_dupedkey;
return t;
on1:
- test = (*cp ^ *cp2) & 0xff; /* find first bit that differs */
+ test = (*cp ^ *cp2) & 0xff; /* find first bit that differs */
for (b = 7; (test >>= 1) > 0;)
b--;
matched_off = cp - v;
x = x->rn_r;
else
x = x->rn_l;
- } while (b > (unsigned) x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */
+ } while (b > (unsigned) x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */
#ifdef RN_DEBUG
if (rn_debug)
fprintf(stderr, "squid_rn_insert: Going In:\n");
else
p->rn_r = t;
x->rn_p = t;
- t->rn_p = p; /* frees x, p as temp vars below */
+ t->rn_p = p; /* frees x, p as temp vars below */
if ((cp[t->rn_off] & t->rn_bmask) == 0) {
t->rn_r = x;
} else {
return (x);
}
-static int /* XXX: arbitrary ordering for non-contiguous masks */
+static int /* XXX: arbitrary ordering for non-contiguous masks */
rn_lexobetter(void *m_arg, void *n_arg)
{
register u_char *mp = m_arg, *np = n_arg, *lim;
if (*mp > *np)
- return 1; /* not really, but need to check longer one first */
+ return 1; /* not really, but need to check longer one first */
if (*mp == *np)
for (lim = mp + *mp; mp < lim;)
if (*mp++ > *np++)
return (0);
if (netmask == 0 ||
(tt->rn_mask &&
- ((b_leaf < tt->rn_b) || /* index(netmask) > node */
+ ((b_leaf < tt->rn_b) || /* index(netmask) > node */
squid_rn_refines(netmask, tt->rn_mask) ||
rn_lexobetter(netmask, tt->rn_mask))))
break;
on2:
/* Add new route to highest possible ancestor's list */
if ((netmask == 0) || (b > t->rn_b))
- return tt; /* can't lift at all */
+ return tt; /* can't lift at all */
b_leaf = tt->rn_b;
do {
x = t;
if (tt->rn_flags & RNF_NORMAL) {
if (m->rm_leaf != tt || m->rm_refs > 0) {
fprintf(stderr, "squid_rn_delete: inconsistent annotation\n");
- return 0; /* dangling ref could cause disaster */
+ return 0; /* dangling ref could cause disaster */
}
} else {
if (m->rm_mask != tt->rn_mask) {
b = -1 - tt->rn_b;
t = saved_tt->rn_p;
if (b > t->rn_b)
- goto on1; /* Wasn't lifted at all */
+ goto on1; /* Wasn't lifted at all */
do {
x = t;
t = t->rn_p;
if (m == 0) {
fprintf(stderr, "squid_rn_delete: couldn't find our annotation\n");
if (tt->rn_flags & RNF_NORMAL)
- return (0); /* Dangling ref to us */
+ return (0); /* Dangling ref to us */
}
on1:
/*
exit(-1);
}
}
+
/* blasted compression */
unsigned short s;
unsigned int ptr;
- if (rdepth > 64) { /* infinite pointer loop */
+ if (rdepth > 64) { /* infinite pointer loop */
RFC1035_UNPACK_DEBUG;
return 1;
}
len = (size_t) c;
if (len == 0)
break;
- if (len > (ns - no - 1)) { /* label won't fit */
+ if (len > (ns - no - 1)) { /* label won't fit */
RFC1035_UNPACK_DEBUG;
return 1;
}
- if ((*off) + len >= sz) { /* message is too short */
+ if ((*off) + len >= sz) { /* message is too short */
RFC1035_UNPACK_DEBUG;
return 1;
}
case RFC1035_TYPE_PTR:
RR->rdata = (char*)xmalloc(RFC1035_MAXHOSTNAMESZ);
rdata_off = *off;
- RR->rdlength = 0; /* Filled in by rfc1035NameUnpack */
+ RR->rdlength = 0; /* Filled in by rfc1035NameUnpack */
if (rfc1035NameUnpack(buf, sz, &rdata_off, &RR->rdlength, RR->rdata, RFC1035_MAXHOSTNAMESZ, 0)) {
RFC1035_UNPACK_DEBUG;
return 1;
i = (unsigned int) msg->ancount;
recs = msg->answer = (rfc1035_rr*)xcalloc(i, sizeof(*recs));
for (j = 0; j < i; j++) {
- if (off >= sz) { /* corrupt packet */
+ if (off >= sz) { /* corrupt packet */
RFC1035_UNPACK_DEBUG;
break;
}
- if (rfc1035RRUnpack(buf, sz, &off, &recs[j])) { /* corrupt RR */
+ if (rfc1035RRUnpack(buf, sz, &off, &recs[j])) { /* corrupt RR */
RFC1035_UNPACK_DEBUG;
break;
}
h.id = qid;
h.qr = 0;
h.rd = 1;
- h.opcode = 0; /* QUERY */
+ h.opcode = 0; /* QUERY */
h.qdcount = (unsigned int) 1;
h.arcount = (edns_sz > 0 ? 1 : 0);
offset += rfc1035HeaderPack(buf + offset, sz - offset, &h);
h.id = qid;
h.qr = 0;
h.rd = 1;
- h.opcode = 0; /* QUERY */
+ h.opcode = 0; /* QUERY */
h.qdcount = (unsigned int) 1;
h.arcount = (edns_sz > 0 ? 1 : 0);
offset += rfc1035HeaderPack(buf + offset, sz - offset, &h);
return 0;
}
#endif
+
#if defined(_timezone) || _SQUID_WINDOWS_
t -= (_timezone + dst);
#else
- t -= (timezone + dst);
+ t -= (timezone + dst);
#endif
}
#endif
}
#endif
+
* any non-US-ASCII character or anything between 0x00 - 0x1F.
*/
static char rfc1738_unsafe_chars[] = {
- (char) 0x3C, /* < */
- (char) 0x3E, /* > */
- (char) 0x22, /* " */
- (char) 0x23, /* # */
-#if 0 /* done in code */
- (char) 0x20, /* space */
- (char) 0x25, /* % */
+ (char) 0x3C, /* < */
+ (char) 0x3E, /* > */
+ (char) 0x22, /* " */
+ (char) 0x23, /* # */
+#if 0 /* done in code */
+ (char) 0x20, /* space */
+ (char) 0x25, /* % */
#endif
- (char) 0x7B, /* { */
- (char) 0x7D, /* } */
- (char) 0x7C, /* | */
- (char) 0x5C, /* \ */
- (char) 0x5E, /* ^ */
- (char) 0x7E, /* ~ */
- (char) 0x5B, /* [ */
- (char) 0x5D, /* ] */
- (char) 0x60, /* ` */
- (char) 0x27 /* ' */
+ (char) 0x7B, /* { */
+ (char) 0x7D, /* } */
+ (char) 0x7C, /* | */
+ (char) 0x5C, /* \ */
+ (char) 0x5E, /* ^ */
+ (char) 0x7E, /* ~ */
+ (char) 0x5B, /* [ */
+ (char) 0x5D, /* ] */
+ (char) 0x60, /* ` */
+ (char) 0x27 /* ' */
};
static char rfc1738_reserved_chars[] = {
- (char) 0x3b, /* ; */
- (char) 0x2f, /* / */
- (char) 0x3f, /* ? */
- (char) 0x3a, /* : */
- (char) 0x40, /* @ */
- (char) 0x3d, /* = */
- (char) 0x26 /* & */
+ (char) 0x3b, /* ; */
+ (char) 0x2f, /* / */
+ (char) 0x3f, /* ? */
+ (char) 0x3a, /* : */
+ (char) 0x40, /* @ */
+ (char) 0x3d, /* = */
+ (char) 0x26 /* & */
};
/*
void
rfc1738_unescape(char *s)
{
- int i, j; /* i is write, j is read */
+ int i, j; /* i is write, j is read */
for (i = j = 0; s[j]; i++, j++) {
s[i] = s[j];
if (s[j] != '%') {
/* normal case, nothing more to do */
- } else if (s[j + 1] == '%') { /* %% case */
- j++; /* Skip % */
+ } else if (s[j + 1] == '%') { /* %% case */
+ j++; /* Skip % */
} else {
/* decode */
int v1, v2, x;
}
s[i] = '\0';
}
+
}
if (strcasecmp(pszAlg, "md5-sess") == 0) {
HASHHEX HA1Hex;
- CvtHex(HA1, HA1Hex); /* RFC2617 errata */
+ CvtHex(HA1, HA1Hex); /* RFC2617 errata */
SquidMD5Init(&Md5Ctx);
SquidMD5Update(&Md5Ctx, HA1Hex, HASHHEXLEN);
SquidMD5Update(&Md5Ctx, ":", 1);
/* calculate request-digest/response-digest as per HTTP Digest spec */
void
DigestCalcResponse(
- const HASHHEX HA1, /* H(A1) */
- const char *pszNonce, /* nonce from server */
- const char *pszNonceCount, /* 8 hex digits */
- const char *pszCNonce, /* client nonce */
- const char *pszQop, /* qop-value: "", "auth", "auth-int" */
- const char *pszMethod, /* method from the request */
- const char *pszDigestUri, /* requested URL */
- const HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
- HASHHEX Response /* request-digest or response-digest */
+ const HASHHEX HA1, /* H(A1) */
+ const char *pszNonce, /* nonce from server */
+ const char *pszNonceCount, /* 8 hex digits */
+ const char *pszCNonce, /* client nonce */
+ const char *pszQop, /* qop-value: "", "auth", "auth-int" */
+ const char *pszMethod, /* method from the request */
+ const char *pszDigestUri, /* requested URL */
+ const HASHHEX HEntity, /* H(entity body) if qop="auth-int" */
+ HASHHEX Response /* request-digest or response-digest */
)
{
SquidMD5_CTX Md5Ctx;
SquidMD5Final((unsigned char *) RespHash, &Md5Ctx);
CvtHex(RespHash, Response);
}
+
return rfc1035RRPack(buf, sz, &opt);
}
+
int
main(int argc, char *argv[])
{
-#define PACKET_BUFSZ 1024
+#define PACKET_BUFSZ 1024
char input[PACKET_BUFSZ];
char buf[PACKET_BUFSZ];
char rbuf[PACKET_BUFSZ];
}
#endif
+
#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
+
extern "C" {
#endif
- /* A data structure we need */
+/* A data structure we need */
- typedef struct RFCNB_Pkt {
+typedef struct RFCNB_Pkt {
- char *data; /* The data in this portion */
- int len;
- struct RFCNB_Pkt *next;
+ char *data; /* The data in this portion */
+ int len;
+ struct RFCNB_Pkt *next;
- } RFCNB_Pkt;
+} RFCNB_Pkt;
#if defined(__cplusplus)
}
#endif
#endif /* _RFCNB_RFCNB_COMMON_H */
+
extern "C" {
#endif
- /* Error responses */
+/* Error responses */
#define RFCNBE_Bad -1 /* Bad response */
#define RFCNBE_OK 0
- /* these should follow the spec ... is there one ? */
+/* these should follow the spec ... is there one ? */
#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */
#define RFCNBE_BadName 2 /* Could not translate a name */
#define RFCNBE_BadParam 15 /* Bad parameters passed ... */
#define RFCNBE_Timeout 16 /* IO Timed out */
- /* Text strings for the error responses */
+/* Text strings for the error responses */
- extern const char *RFCNB_Error_Strings[];
+extern const char *RFCNB_Error_Strings[];
#ifdef __cplusplus
}
#endif
#endif /* _RFCNB_ERROR_H_ */
+
if (sigaction(SIGALRM, &inact, &outact) < 0)
return (-1);
#else /* !HAVE_SIGACTION */
- invec.sv_handler = (void (*)()) rfcnb_alarm;
- invec.sv_mask = 0;
- invec.sv_flags = SV_INTERRUPT;
+ invec.sv_handler = (void (*)()) rfcnb_alarm;
+ invec.sv_mask = 0;
+ invec.sv_flags = SV_INTERRUPT;
- if (sigvec(SIGALRM, &invec, &outvec) < 0)
- return (-1);
+ if (sigvec(SIGALRM, &invec, &outvec) < 0)
+ return (-1);
#endif /* !HAVE_SIGACTION */
}
#endif /* !ORIGINAL_SAMBA_CODE ADAPTED SQUID CODE */
return (read_len + sizeof(RFCNB_Hdr));
}
+
int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len);
#endif
+
#endif
#endif /* _RFCNB_RFCNB_PRIV_H */
+
RFCNB_Free_Pkt(pkt);
return result;
}
+
extern RFCNB_Prot_Print_Routine *Prot_Print_Routine;
#endif /* _RFCNB_RFCNB_UTIL_H */
+
extern "C" {
#endif
- /* Defines we need */
+/* Defines we need */
#define RFCNB_Default_Port 139
- struct RFCNB_Con;
+struct RFCNB_Con;
- /* Definition of routines we define */
+/* Definition of routines we define */
- void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
- int port);
+void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
+ int port);
- int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length);
+int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length);
- int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
+int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
- int RFCNB_Hangup(struct RFCNB_Con *con_Handle);
+int RFCNB_Hangup(struct RFCNB_Con *con_Handle);
- void *RFCNB_Listen(void);
+void *RFCNB_Listen(void);
- void RFCNB_Get_Error(char *buffer, int buf_len);
+void RFCNB_Get_Error(char *buffer, int buf_len);
- int RFCNB_Get_Last_Error(void);
+int RFCNB_Get_Last_Error(void);
- void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
+void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
- int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, int yn);
+int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, int yn);
- struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
+struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
#ifdef __cplusplus
}
#endif
#endif /* _RFCNB_RFCNB_H */
+
{
return (RFCNB_errno);
}
+
#endif
#endif /* _RFCNB_STD_INCLUDES_H */
+
{
struct RFCNB_Pkt *pkt;
int param_len, i, pkt_len, tcon_len, tcon_param_len, open_len,
- open_param_len, header_len;
+ open_param_len, header_len;
struct SMB_File_Def *file_tmp;
SMB_Tree_Handle tree;
char *p, *AndXCom;
fprintf(stderr, "Passwords exhausted.");
}
+
extern void mdfour(unsigned char *out, unsigned char *in, int n);
#endif /* __SMB_LM_SMBVAL_MD4_H */
+
return(strlen(msg_buf));
}
+
{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
{0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
{4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
- {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}},
+ {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}
+ },
{
{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
{3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
{0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
- {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}},
+ {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}
+ },
{
{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
{13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
{13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
- {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}},
+ {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}
+ },
{
{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
{13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
{10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
- {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}},
+ {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}
+ },
{
{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
{14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
{4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
- {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}},
+ {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}
+ },
{
{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
{10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
{9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
- {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}},
+ {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}
+ },
{
{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
{13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
{1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
- {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}},
+ {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}
+ },
{
{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
{1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
{7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
- {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}
+ {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}
+ }
};
static void
key2[0] = key[7];
smbhash(out, buf, key2);
}
+
void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
void cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key);
void cred_hash2(unsigned char *out, unsigned char *in, unsigned char *key);
+
len = 128;
/* Password must be converted to NT unicode */
_my_mbstowcs(wpwd, passwd, len);
- wpwd[len] = 0; /* Ensure string is null terminated */
+ wpwd[len] = 0; /* Ensure string is null terminated */
/* Calculate length in bytes */
len = _my_wcslen(wpwd) * sizeof(int16_t);
}
}
}
+
extern "C" {
#endif
- void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
- void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
- void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16);
+void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16);
#ifdef __cplusplus
}
#endif
#endif /* _SMBLIB_SMBENCRYPT_H */
+
extern "C" {
#endif
- /* To get the error class we want the first 8 bits */
- /* Because we just grab 4bytes from the SMB header, we have to re-order */
- /* here, but it makes the NtStatus part easier in future */
+/* To get the error class we want the first 8 bits */
+/* Because we just grab 4bytes from the SMB header, we have to re-order */
+/* here, but it makes the NtStatus part easier in future */
#define SMBlib_Error_Class(p) (p & 0x000000FF)
- /* To get the error code, we want the bottom 16 bits */
+/* To get the error code, we want the bottom 16 bits */
#define SMBlib_Error_Code(p) (((unsigned int)p & 0xFFFF0000) >>16)
- /* Error CLASS codes and etc ... */
+/* Error CLASS codes and etc ... */
#define SMBC_SUCCESS 0
#define SMBC_ERRDOS 0x01
#define SMBC_ERRHRD 0x03
#define SMBC_ERRCMD 0xFF
- /* Success error codes */
+/* Success error codes */
#define SMBS_BUFFERED 0x54
#define SMBS_LOGGED 0x55
#define SMBS_DISPLAYED 0x56
- /* ERRDOS Error codes */
+/* ERRDOS Error codes */
#define SMBD_badfunc 0x01
#define SMBD_badfile 0x02
#define SMBD_errlock 0x21
#define SMBD_filexists 0x50
- /* Server errors ... */
+/* Server errors ... */
#define SMBV_error 0x01 /* Generic error */
#define SMBV_badpw 0x02
#define SMBV_rmuns 0x57
#define SMBV_nosupport 0xFFFF
- /* Hardware error codes ... */
+/* Hardware error codes ... */
#define SMBH_nowrite 0x13
#define SMBH_badunit 0x14
#define SMBH_general 0x1F
#define SMBH_badshare 0x20
- /* Access mode defines ... */
+/* Access mode defines ... */
#define SMB_AMODE_WTRU 0x4000
#define SMB_AMODE_NOCACHE 0x1000
#define SMB_AMODE_LOCMRAN 0x0200
#define SMB_AMODE_LOCRAL 0x0300
- /* File attribute encoding ... */
+/* File attribute encoding ... */
#define SMB_FA_ORD 0x00
#define SMB_FA_ROF 0x01
#define SMB_FA_DIR 0x10
#define SMB_FA_ARC 0x20
- /* Define the protocol types ... */
+/* Define the protocol types ... */
#define SMB_P_Unknown -1 /* Hmmm, is this smart? */
#define SMB_P_Core 0
#define SMB_P_LanMan2_1 7
#define SMB_P_NT1 8
- /* SMBlib return codes */
- /* We want something that indicates whether or not the return code was a */
- /* remote error, a local error in SMBlib or returned from lower layer ... */
- /* Wonder if this will work ... */
- /* SMBlibE_Remote = 1 indicates remote error */
- /* SMBlibE_ values < 0 indicate local error with more info available */
- /* SMBlibE_ values >1 indicate local from SMBlib code errors? */
+/* SMBlib return codes */
+/* We want something that indicates whether or not the return code was a */
+/* remote error, a local error in SMBlib or returned from lower layer ... */
+/* Wonder if this will work ... */
+/* SMBlibE_Remote = 1 indicates remote error */
+/* SMBlibE_ values < 0 indicate local error with more info available */
+/* SMBlibE_ values >1 indicate local from SMBlib code errors? */
#define SMBlibE_Success 0
#define SMBlibE_Remote 1 /* Remote error, get more info from con */
#define SMBlibE_ProtUnknown 12 /* Protocol unknown */
#define SMBlibE_NoSuchMsg 13 /* Keep this up to date */
- /* the default SMB protocols supported by this library. */
- extern const char *SMB_Prots[];
+/* the default SMB protocols supported by this library. */
+extern const char *SMB_Prots[];
- typedef struct { /* A structure for a Dirent */
+typedef struct { /* A structure for a Dirent */
- unsigned char resume_key[21]; /* Don't touch this */
- unsigned char file_attributes; /* Attributes of file */
- unsigned int date_time; /* date and time of last mod */
- unsigned int size;
- char filename[13]; /* The name of the file */
+ unsigned char resume_key[21]; /* Don't touch this */
+ unsigned char file_attributes; /* Attributes of file */
+ unsigned int date_time; /* date and time of last mod */
+ unsigned int size;
+ char filename[13]; /* The name of the file */
- } SMB_CP_dirent;
+} SMB_CP_dirent;
- typedef struct SMB_Connect_Def * SMB_Handle_Type;
+typedef struct SMB_Connect_Def * SMB_Handle_Type;
- typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
+typedef struct SMB_Tree_Structure * SMB_Tree_Handle;
- /* A Tree_Structure */
+/* A Tree_Structure */
- struct SMB_Tree_Structure {
+struct SMB_Tree_Structure {
- SMB_Tree_Handle next, prev;
- SMB_Handle_Type con;
- char path[129];
- char device_type[20];
- int mbs; /* Local MBS */
- int tid;
+ SMB_Tree_Handle next, prev;
+ SMB_Handle_Type con;
+ char path[129];
+ char device_type[20];
+ int mbs; /* Local MBS */
+ int tid;
- };
+};
- struct SMB_Connect_Def {
- SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */
- int protocol; /* What is the protocol */
- int prot_IDX; /* And what is the index */
- void *Trans_Connect; /* The connection */
+struct SMB_Connect_Def {
+ SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */
+ int protocol; /* What is the protocol */
+ int prot_IDX; /* And what is the index */
+ void *Trans_Connect; /* The connection */
- /* All these strings should be malloc'd */
+ /* All these strings should be malloc'd */
- char service[80], username[80], password[80], desthost[80], sock_options[80];
- char address[80], myname[80];
+ char service[80], username[80], password[80], desthost[80], sock_options[80];
+ char address[80], myname[80];
- SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */
+ SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */
- int gid; /* Group ID, do we need it? */
- int mid; /* Multiplex ID? We might need one per con */
- int pid; /* Process ID */
+ int gid; /* Group ID, do we need it? */
+ int mid; /* Multiplex ID? We might need one per con */
+ int pid; /* Process ID */
- int uid; /* Authenticated user id. */
+ int uid; /* Authenticated user id. */
- /* It is pretty clear that we need to bust some of */
- /* these out into a per TCon record, as there may */
- /* be multiple TCon's per server, etc ... later */
+ /* It is pretty clear that we need to bust some of */
+ /* these out into a per TCon record, as there may */
+ /* be multiple TCon's per server, etc ... later */
- int port; /* port to use in case not default, this is a TCPism! */
+ int port; /* port to use in case not default, this is a TCPism! */
- int max_xmit; /* Max xmit permitted by server */
- int Security; /* 0 = share, 1 = user */
- int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */
- int encrypt_passwords; /* 1 = do , 0 = don't */
- int MaxMPX, MaxVC, MaxRaw;
- unsigned int SessionKey, Capabilities;
- int SvrTZ; /* Server Time Zone */
- int Encrypt_Key_Len;
- char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40];
- char Svr_OS[80], Svr_LMType[80], Svr_PDom[80];
- };
+ int max_xmit; /* Max xmit permitted by server */
+ int Security; /* 0 = share, 1 = user */
+ int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */
+ int encrypt_passwords; /* 1 = do , 0 = don't */
+ int MaxMPX, MaxVC, MaxRaw;
+ unsigned int SessionKey, Capabilities;
+ int SvrTZ; /* Server Time Zone */
+ int Encrypt_Key_Len;
+ char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40];
+ char Svr_OS[80], Svr_LMType[80], Svr_PDom[80];
+};
#ifdef __cplusplus
}
#endif
#endif /* _SMBLIB_SMBLIB_COMMON_H */
+
void SMB_Get_My_Name(char *name, int len);
#endif /* _SMBLIB_PRIV_H_ */
+
extern "C" {
#endif
- /* Just define all the entry points */
+/* Just define all the entry points */
- /* Create a handle to allow us to set/override some parameters ... */
+/* Create a handle to allow us to set/override some parameters ... */
- SMB_Handle_Type SMB_Create_Con_Handle(void);
+SMB_Handle_Type SMB_Create_Con_Handle(void);
- /* Connect to a server, but do not do a tree con etc ... */
+/* Connect to a server, but do not do a tree con etc ... */
- SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
- char *server,
- const char *NTdomain);
+SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle,
+ char *server,
+ const char *NTdomain);
- /* Connect to a server and give us back a handle. If Con == NULL, create */
- /* The handle and populate it with defaults */
+/* Connect to a server and give us back a handle. If Con == NULL, create */
+/* The handle and populate it with defaults */
- SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
- SMB_Tree_Handle *tree,
- char *service,
- char *username,
- char *password);
+SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle,
+ SMB_Tree_Handle *tree,
+ char *service,
+ char *username,
+ char *password);
- int SMB_Init(void);
+int SMB_Init(void);
- int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
- char *UserName,
- char *PassWord,
- const char *NtDomain,
- int PreCrypted);
+int SMB_Logon_Server(SMB_Handle_Type Con_Handle,
+ char *UserName,
+ char *PassWord,
+ const char *NtDomain,
+ int PreCrypted);
- /* Negotiate a protocol */
+/* Negotiate a protocol */
- int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[]);
+int SMB_Negotiate(SMB_Handle_Type Con_Handle, const char *Prots[]);
- /* Connect to a tree ... */
+/* Connect to a tree ... */
- SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
- SMB_Tree_Handle tree,
- const char *path,
- const char *password,
- const char *dev);
+SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con,
+ SMB_Tree_Handle tree,
+ const char *path,
+ const char *password,
+ const char *dev);
- /* Disconnect a tree ... */
+/* Disconnect a tree ... */
- int SMB_TreeDisconect(void *tree_handle);
+int SMB_TreeDisconect(void *tree_handle);
- /* Open a file */
+/* Open a file */
- void *SMB_Open(void *tree_handle,
- void *file_handle,
- char *file_name,
- unsigned short mode,
- unsigned short search);
+void *SMB_Open(void *tree_handle,
+ void *file_handle,
+ char *file_name,
+ unsigned short mode,
+ unsigned short search);
- /* Close a file */
+/* Close a file */
- int SMB_Close(void *file_handle);
+int SMB_Close(void *file_handle);
- /* Disconnect from server. Has flag to specify whether or not we keep the */
- /* handle. */
+/* Disconnect from server. Has flag to specify whether or not we keep the */
+/* handle. */
- int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
+int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
- void *SMB_Create(void *Tree_Handle,
- void *File_Handle,
- char *file_name,
- short search);
+void *SMB_Create(void *Tree_Handle,
+ void *File_Handle,
+ char *file_name,
+ short search);
- int SMB_Delete(void *tree, char *file_name, short search);
+int SMB_Delete(void *tree, char *file_name, short search);
- int SMB_Create_Dir(void *tree, char *dir_name);
+int SMB_Create_Dir(void *tree, char *dir_name);
- int SMB_Delete_Dir(void *tree, char *dir_name);
+int SMB_Delete_Dir(void *tree, char *dir_name);
- int SMB_Check_Dir(void *tree, char *dir_name);
+int SMB_Check_Dir(void *tree, char *dir_name);
- int SMB_Get_Last_Error(void);
+int SMB_Get_Last_Error(void);
- int SMB_Get_Last_SMB_Err(void);
+int SMB_Get_Last_SMB_Err(void);
- void SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
+void SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
- void *SMB_Logon_And_TCon(void *con, void *tree, char *user, char *pass,
- char *service, char *st);
+void *SMB_Logon_And_TCon(void *con, void *tree, char *user, char *pass,
+ char *service, char *st);
#ifdef __cplusplus
}
#endif
#endif /* _SMBLIB_SMBLIB_H */
+
#define FALSE 0
#endif /* _SMBLIB_STD_DEFINES_H */
+
#include "snmp_api_error.h"
u_char *
-asn_build_header(u_char * data, /* IN - ptr to start of object */
- int *datalength, /* IN/OUT - # of valid bytes */
+asn_build_header(u_char * data, /* IN - ptr to start of object */
+ int *datalength, /* IN/OUT - # of valid bytes */
/* left in buffer */
- u_char type, /* IN - ASN type of object */
+ u_char type, /* IN - ASN type of object */
int length)
-{ /* IN - length of object */
+{ /* IN - length of object */
/* Truth is 0 'cause we don't know yet */
return (asn_build_header_with_truth(data, datalength, type, length, 0));
}
/* Is the int negative? */
if (*bufp & 0x80)
- value = -1; /* integer is negative */
+ value = -1; /* integer is negative */
/* Extract the bytes */
while (asn_length--)
/* Is the int negative? */
if (*bufp & 0x80)
- value = -1; /* integer is negative */
+ value = -1; /* integer is negative */
/* Extract the bytes */
while (asn_length--)
{
*datalength -= 4;
if (*datalength < 0) {
- *datalength += 4; /* fix up before punting */
+ *datalength += 4; /* fix up before punting */
snmp_set_api_error(SNMPERR_ASN_ENCODE);
return (NULL);
}
u_char lengthbyte = *data;
if (lengthbyte & ASN_LONG_LEN) {
- lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */
+ lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */
if (lengthbyte == 0) {
snmp_set_api_error(SNMPERR_ASN_DECODE);
}
*data++ = (u_char) (0x01 | ASN_LONG_LEN);
*data++ = (u_char) length;
- } else { /* 0xFF < length <= 0xFFFF */
+ } else { /* 0xFF < length <= 0xFFFF */
if (*datalength < 3) {
snmp_set_api_error(SNMPERR_ASN_ENCODE);
return (NULL);
objid[0] = objid[1] = 0;
length = asn_length;
- (*objidlength)--; /* account for expansion of first byte */
+ (*objidlength)--; /* account for expansion of first byte */
while (length > 0 && (*objidlength)-- > 0) {
subidentifier = 0;
- do { /* shift and add in low order 7 bits */
+ do { /* shift and add in low order 7 bits */
subidentifier = (subidentifier << 7)
+ (*(u_char *) bufp & ~ASN_BIT8);
length--;
while (objidlength-- > 0) {
subid = *op++;
- if (subid < 127) { /* off by one? */
+ if (subid < 127) { /* off by one? */
*bp++ = subid;
} else {
- mask = 0x7F; /* handle subid == 0 case */
+ mask = 0x7F; /* handle subid == 0 case */
bits = 0;
/* testmask *MUST* !!!! be of an unsigned type */
for (testmask = 0x7F, testbits = 0; testmask != 0;
testmask <<= 7, testbits += 7) {
- if (subid & testmask) { /* if any bits set */
+ if (subid & testmask) { /* if any bits set */
mask = testmask;
bits = testbits;
}
{
return (asn_build_header_with_truth(data, datalength, type, 0, 1));
}
+
*/
/***********************************************************
- Copyright 1988, 1989 by Carnegie Mellon University
+ Copyright 1988, 1989 by Carnegie Mellon University
All Rights Reserved
read_objid(input, output, out_len)
char *input;
oid *output;
-int *out_len; /* number of subid's in "output" */
+int *out_len; /* number of subid's in "output" */
{
struct snmp_mib_tree *root = Mib;
oid *op = output;
void
print_objid(objid, objidlen)
oid *objid;
-int objidlen; /* number of subidentifiers */
+int objidlen; /* number of subidentifiers */
{
char buf[256];
struct snmp_mib_tree *subtree = Mib;
- *buf = '.'; /* this is a fully qualified name */
+ *buf = '.'; /* this is a fully qualified name */
get_symbol(objid, objidlen, subtree, buf + 1);
snmplib_debug(7, "%s\n", buf);
sprint_objid(buf, objid, objidlen)
char *buf;
oid *objid;
-int objidlen; /* number of subidentifiers */
+int objidlen; /* number of subidentifiers */
{
struct snmp_mib_tree *subtree = Mib;
- *buf = '.'; /* this is a fully qualified name */
+ *buf = '.'; /* this is a fully qualified name */
get_symbol(objid, objidlen, subtree, buf + 1);
}
}
/* subtree not found */
- while (objidlen--) { /* output rest of name, uninterpreted */
+ while (objidlen--) { /* output rest of name, uninterpreted */
sprintf(buf, "%u.", *objid++);
while (*buf)
buf++;
}
- *(buf - 1) = '\0'; /* remove trailing dot */
+ *(buf - 1) = '\0'; /* remove trailing dot */
return NULL;
found:
for (x = 0; x < len; x++)
printf(".%u", O[x]);
}
+
*/
/***********************************************************
- Copyright 1989 by Carnegie Mellon University
+ Copyright 1989 by Carnegie Mellon University
All Rights Reserved
*/
struct node {
struct node *next;
- char label[64]; /* This node's (unique) textual name */
- u_int subid; /* This node's integer subidentifier */
- char parent[64]; /* The parent's textual name */
- int type; /* The type of object this represents */
- struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */
+ char label[64]; /* This node's (unique) textual name */
+ u_int subid; /* This node's integer subidentifier */
+ char parent[64]; /* The parent's textual name */
+ int type; /* The type of object this represents */
+ struct enum_list *enums; /* (optional) list of enumerated integers (otherwise NULL) */
};
int Line = 1;
/* types of tokens */
-#define CONTINUE -1
+#define CONTINUE -1
#define ENDOFFILE 0
-#define LABEL 1
-#define SUBTREE 2
-#define SYNTAX 3
+#define LABEL 1
+#define SUBTREE 2
+#define SYNTAX 3
#undef OBJID
-#define OBJID 4
+#define OBJID 4
#define OCTETSTR 5
#undef INTEGER
-#define INTEGER 6
-#define NETADDR 7
-#define IPADDR 8
-#define COUNTER 9
-#define GAUGE 10
+#define INTEGER 6
+#define NETADDR 7
+#define IPADDR 8
+#define COUNTER 9
+#define GAUGE 10
#define TIMETICKS 11
-#define SNMP_OPAQUE 12
-#define NUL 13
+#define SNMP_OPAQUE 12
+#define NUL 13
#define SEQUENCE 14
-#define OF 15 /* SEQUENCE OF */
-#define OBJTYPE 16
-#define ACCESS 17
+#define OF 15 /* SEQUENCE OF */
+#define OBJTYPE 16
+#define ACCESS 17
#define READONLY 18
#define READWRITE 19
-#define WRITEONLY 20
+#define WRITEONLY 20
#undef NOACCESS
#define NOACCESS 21
#define SNMP_STATUS 22
#define SNMP_OPTIONAL 24
#define OBSOLETE 25
#define RECOMMENDED 26
-#define PUNCT 27
-#define EQUALS 28
-#define NUMBER 29
+#define PUNCT 27
+#define EQUALS 28
+#define NUMBER 29
#define LEFTBRACKET 30
#define RIGHTBRACKET 31
-#define LEFTPAREN 32
+#define LEFTPAREN 32
#define RIGHTPAREN 33
-#define COMMA 34
+#define COMMA 34
/* For SNMPv2 SMI pseudo-compliance */
#define DESCRIPTION 35
#define INDEX 36
#define QUOTE 37
struct tok {
- const char *name; /* token name */
- int len; /* length not counting nul */
- int token; /* value */
- int hash; /* hash of name */
- struct tok *next; /* pointer to next in hash table */
+ const char *name; /* token name */
+ int len; /* length not counting nul */
+ int token; /* value */
+ int hash; /* hash of name */
+ struct tok *next; /* pointer to next in hash table */
};
struct tok tokens[] = {
{NULL}
};
-#define HASHSIZE 32
-#define BUCKET(x) (x & 0x01F)
+#define HASHSIZE 32
+#define BUCKET(x) (x & 0x01F)
static struct tok *buckets[HASHSIZE];
tp->hash = h;
b = BUCKET(h);
if (buckets[b])
- tp->next = buckets[b]; /* BUG ??? */
+ tp->next = buckets[b]; /* BUG ??? */
buckets[b] = tp;
}
}
oldnp = np;
} else {
if (child_list == NULL) {
- child_list = childp = np; /* first entry in child list */
+ child_list = childp = np; /* first entry in child list */
} else {
childp->next = np;
childp = np;
}
/* take this node out of the node list */
if (oldnp == NULL) {
- *headp = np->next; /* fix root of node list */
+ *headp = np->next; /* fix root of node list */
} else {
- oldnp->next = np->next; /* link around this node */
+ oldnp->next = np->next; /* link around this node */
}
}
}
if (childp)
- childp->next = 0; /* re-terminate list */
+ childp->next = 0; /* re-terminate list */
/*
* Take each element in the child list and place it into the tree.
*/
tp->subid = np->subid;
tp->type = translation_table[np->type];
tp->enums = np->enums;
- np->enums = NULL; /* so we don't free them later */
+ np->enums = NULL; /* so we don't free them later */
if (root->child_list == NULL) {
root->child_list = tp;
} else if (peer) {
}
peer = tp;
/* if (tp->type == TYPE_OTHER) */
- do_subtree(tp, nodes); /* recurse on this child if it isn't an end node */
+ do_subtree(tp, nodes); /* recurse on this child if it isn't an end node */
}
/* free all nodes that were copied into tree */
oldnp = NULL;
* { iso org(3) dod(6) 1 }
* and creates several nodes, one for each parent-child pair.
* Returns NULL on error.
- * register struct subid *SubOid; an array of subids
- * int length; the length of the array
+ * register struct subid *SubOid; an array of subids
+ * int length; the length of the array
*/
static int
getoid(register FILE *fp, register struct subid *SubOid, int length)
type = get_token(fp, token);
if (type != SEQUENCE) {
- print_error("Not a sequence", token, type); /* should we handle this */
+ print_error("Not a sequence", token, type); /* should we handle this */
return ENDOFFILE;
}
while ((type = get_token(fp, token)) != ENDOFFILE) {
tree = build_tree(nodes);
return (tree);
}
+
"Unknown session",
"Too Long",
- "Encoding ASN.1 Information", /* 6 */
- "Decoding ASN.1 Information", /* 7 */
+ "Encoding ASN.1 Information", /* 6 */
+ "Decoding ASN.1 Information", /* 7 */
"PDU Translation error",
"OS Error",
"Invalid Textual OID",
{
return (snmp_api_error(snmp_errnumber));
}
+
return "Unknown Error";
}
}
+
PDUDataStart = bufp;
bufp = snmp_pdu_encode(bufp, BufLenP, PDU);
if (bufp == NULL)
- return (NULL); /* snmp_pdu_encode registered failure */
+ return (NULL); /* snmp_pdu_encode registered failure */
VARHeaderPtr = bufp;
bufp = asn_build_header(bufp, BufLenP,
/* And build the variables */
bufp = snmp_var_EncodeVarBind(bufp, BufLenP, PDU->variables, Version);
if (bufp == NULL)
- return (NULL); /* snmp_var_EncodeVarBind registered failure */
+ return (NULL); /* snmp_var_EncodeVarBind registered failure */
/* Cool. Now insert the appropriate lengths.
*/
tmp = asn_build_header(Buffer,
&FakeArg,
(u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR),
- (bufp - MsgPtr)); /* Length of everything */
+ (bufp - MsgPtr)); /* Length of everything */
if (tmp == NULL)
return (NULL);
tmp = asn_build_header(VARHeaderPtr,
&FakeArg,
(u_char) (ASN_SEQUENCE | ASN_CONSTRUCTOR),
- (bufp - VARDataStart)); /* Length of everything */
+ (bufp - VARDataStart)); /* Length of everything */
if (tmp == NULL)
return (NULL);
return (u_char *) bufp;
}
+
break;
#endif
- /**********************************************************************/
+ /**********************************************************************/
case SNMP_PDU_GETBULK:
return (NULL);
break;
- /**********************************************************************/
+ /**********************************************************************/
default:
if (bufp == NULL)
return (NULL);
break;
- } /* End of encoding */
+ } /* End of encoding */
return (bufp);
}
* Variable Bindings start.
*/
u_char *
-snmp_pdu_decode(u_char * Packet, /* data */
- int *Length, /* &length */
+snmp_pdu_decode(u_char * Packet, /* data */
+ int *Length, /* &length */
struct snmp_pdu * PDU)
-{ /* pdu */
+{ /* pdu */
u_char *bufp;
u_char PDUType;
u_char ASNType;
break;
#endif
- /**********************************************************************/
+ /**********************************************************************/
case SNMP_PDU_GETBULK:
ASN_PARSE_ERROR(NULL);
break;
- /**********************************************************************/
+ /**********************************************************************/
default:
return;
}
+
case SMI_COUNTER32:
case SMI_GAUGE32:
- /* case SMI_UNSIGNED32: */
+ /* case SMI_UNSIGNED32: */
case SMI_TIMETICKS:
bufp = asn_build_unsigned_int(bufp, BufLenP,
Vars->type,
case SMI_COUNTER64:
snmplib_debug(2, "Unable to encode type SMI_COUNTER64!\n");
- /* Fall through */
+ /* Fall through */
default:
snmp_set_api_error(SNMPERR_UNSUPPORTED_TYPE);
case SMI_COUNTER32:
case SMI_GAUGE32:
- /* case SMI_UNSIGNED32: */
+ /* case SMI_UNSIGNED32: */
case SMI_TIMETICKS:
Var->val.integer = (int *) xmalloc(sizeof(u_int));
if (Var->val.integer == NULL) {
case ASN_OCTET_STR:
case SMI_IPADDRESS:
case SMI_OPAQUE:
- Var->val_len = *&ThisVarLen; /* String is this at most */
+ Var->val_len = *&ThisVarLen; /* String is this at most */
Var->val.string = (u_char *) xmalloc((unsigned) Var->val_len);
if (Var->val.string == NULL) {
snmp_set_api_error(SNMPERR_OS_ERR);
snmplib_debug(2, "bad type returned (%x)\n", Var->type);
snmp_set_api_error(SNMPERR_PDU_PARSE);
PARSE_ERROR;
- } /* End of var type switch */
+ } /* End of var type switch */
if (bufp == NULL)
PARSE_ERROR;
return (bufp);
}
+
encoded = base64_encode_bin((char *) pServerBuf, cbOut);
return encoded;
}
+
CPPUNIT_TEST_SUITE_REGISTRATION( testRFC1035 );
// TODO Test each function in the Library independently
-// Just because we can for global functions.
-// It's good for the code too.
+// Just because we can for global functions.
+// It's good for the code too.
void testRFC1035::testHeaderUnpack()
{
CPPUNIT_ASSERT(res < 0);
CPPUNIT_ASSERT(msg == NULL);
}
+
};
#endif /* SQUID_SRC_TEST_IPADDRESS_H */
+
CPPUNIT_ASSERT(memcmp(unescaped_str, "w%%00%rd",9)==0);
xfree(unescaped_str);
}
+
};
#endif /* SQUID_LIB_TEST_RFC1738_H */
+
const char *
xitoa(int num)
{
- static char buf[24]; /* 2^64 = 18446744073709551616 */
+ static char buf[24]; /* 2^64 = 18446744073709551616 */
snprintf(buf, sizeof(buf), "%d", num);
return buf;
}
const char *
xint64toa(int64_t num)
{
- static char buf[24]; /* 2^64 = 18446744073709551616 */
+ static char buf[24]; /* 2^64 = 18446744073709551616 */
snprintf(buf, sizeof(buf), "%" PRId64, num);
return buf;
}
{
return what * ((num + what -1)/what);
}
+
bufplain[nbytesdecoded] = '\0';
return bufplain;
}
+
sl.tv_usec = usec % 1000000;
return select(0, NULL, NULL, NULL, &sl);
}
+
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
+
HTTPMSGUNLOCK(icap.request);
#endif
}
+
typedef RefCount<AccessLogEntry> Pointer;
AccessLogEntry() : url(NULL), tcpClient(), reply(NULL), request(NULL),
- adapted_request(NULL) {}
+ adapted_request(NULL) {}
~AccessLogEntry();
/// Fetch the client IP log string into the given buffer.
public:
HttpDetails() : method(Http::METHOD_NONE), code(0), content_type(NULL),
- timedout(false),
- aborted(false),
- clientRequestSz(),
- clientReplySz() {}
+ timedout(false),
+ aborted(false),
+ clientRequestSz(),
+ clientReplySz() {}
HttpRequestMethod method;
int code;
public:
CacheDetails() : caddr(),
- highOffset(0),
- objectSize(0),
- code (LOG_TAG_NONE),
- rfc931 (NULL),
- extuser(NULL),
+ highOffset(0),
+ objectSize(0),
+ code (LOG_TAG_NONE),
+ rfc931 (NULL),
+ extuser(NULL),
#if USE_OPENSSL
- ssluser(NULL),
+ ssluser(NULL),
#endif
- port(NULL)
+ port(NULL)
{
caddr.setNoAddr();
memset(&start_time, 0, sizeof(start_time));
public:
Headers() : request(NULL),
- adapted_request(NULL),
- reply(NULL) {}
+ adapted_request(NULL),
+ reply(NULL) {}
char *request; //< virgin HTTP request headers
{
public:
IcapLogEntry() : reqMethod(Adaptation::methodNone), bytesSent(0), bytesRead(0),
- bodyBytesRead(-1), request(NULL), reply(NULL),
- outcome(Adaptation::Icap::xoUnknown), resStatus(Http::scNone)
+ bodyBytesRead(-1), request(NULL), reply(NULL),
+ outcome(Adaptation::Icap::xoUnknown), resStatus(Http::scNone)
{
memset(&trTime, 0, sizeof(trTime));
memset(&ioTime, 0, sizeof(ioTime));
const char *accessLogTime(time_t);
#endif /* SQUID_HTTPACCESSLOGENTRY_H */
+
ACL::Prototype ACLAdaptationService::RegistryProtoype(&ACLAdaptationService::RegistryEntry_, "adaptation_service");
ACLStrategised<const char *> ACLAdaptationService::RegistryEntry_(new ACLAdaptationServiceData, ACLAdaptationServiceStrategy::Instance(), "adaptation_service");
#endif
+
#include "squid.h"
#include "AsyncEngine.h"
+
};
#endif /* SQUID_ASYNCENGINE_H */
+
}
#endif /* USE_AUTH */
+
} // namespace Auth
#endif /* SQUID_AUTHREG_H_ */
+
BodyProducerDialer(const BodyProducer::Pointer &aProducer,
Parent::Method aHandler, BodyPipe::Pointer bp):
- Parent(aProducer, aHandler, bp) {}
+ Parent(aProducer, aHandler, bp) {}
virtual bool canDial(AsyncCall &call);
};
BodyConsumerDialer(const BodyConsumer::Pointer &aConsumer,
Parent::Method aHandler, BodyPipe::Pointer bp):
- Parent(aConsumer, aHandler, bp) {}
+ Parent(aConsumer, aHandler, bp) {}
virtual bool canDial(AsyncCall &call);
};
/* BodyPipe */
BodyPipe::BodyPipe(Producer *aProducer): theBodySize(-1),
- theProducer(aProducer), theConsumer(0),
- thePutSize(0), theGetSize(0),
- mustAutoConsume(false), abortedConsumption(false), isCheckedOut(false)
+ theProducer(aProducer), theConsumer(0),
+ thePutSize(0), theGetSize(0),
+ mustAutoConsume(false), abortedConsumption(false), isCheckedOut(false)
{
// TODO: teach MemBuf to start with zero minSize
// TODO: limit maxSize by theBodySize, when known?
AsyncCall::Pointer call= asyncCall(91, 7,
"BodyProducer::noteBodyConsumerAborted",
BodyProducerDialer(theProducer,
- &BodyProducer::noteBodyConsumerAborted, this));
+ &BodyProducer::noteBodyConsumerAborted, this));
ScheduleCallHere(call);
abortedConsumption = true;
AsyncCall::Pointer call= asyncCall(91, 7,
"BodyProducer::noteMoreBodySpaceAvailable",
BodyProducerDialer(theProducer,
- &BodyProducer::noteMoreBodySpaceAvailable, this));
+ &BodyProducer::noteMoreBodySpaceAvailable, this));
ScheduleCallHere(call);
}
}
AsyncCall::Pointer call = asyncCall(91, 7,
"BodyConsumer::noteMoreBodyDataAvailable",
BodyConsumerDialer(theConsumer,
- &BodyConsumer::noteMoreBodyDataAvailable, this));
+ &BodyConsumer::noteMoreBodyDataAvailable, this));
ScheduleCallHere(call);
}
}
AsyncCall::Pointer call = asyncCall(91, 7,
"BodyConsumer::noteBodyProductionEnded",
BodyConsumerDialer(theConsumer,
- &BodyConsumer::noteBodyProductionEnded, this));
+ &BodyConsumer::noteBodyProductionEnded, this));
ScheduleCallHere(call);
} else {
AsyncCall::Pointer call = asyncCall(91, 7,
"BodyConsumer::noteBodyProducerAborted",
BodyConsumerDialer(theConsumer,
- &BodyConsumer::noteBodyProducerAborted, this));
+ &BodyConsumer::noteBodyProducerAborted, this));
ScheduleCallHere(call);
}
}
/* BodyPipeCheckout */
BodyPipeCheckout::BodyPipeCheckout(BodyPipe &aPipe): thePipe(aPipe),
- buf(aPipe.checkOut()), offset(aPipe.consumedSize()),
- checkedOutSize(buf.contentSize()), checkedIn(false)
+ buf(aPipe.checkOut()), offset(aPipe.consumedSize()),
+ checkedOutSize(buf.contentSize()), checkedIn(false)
{
}
}
BodyPipeCheckout::BodyPipeCheckout(const BodyPipeCheckout &c): thePipe(c.thePipe),
- buf(c.buf), offset(c.offset), checkedOutSize(c.checkedOutSize),
- checkedIn(c.checkedIn)
+ buf(c.buf), offset(c.offset), checkedOutSize(c.checkedOutSize),
+ checkedIn(c.checkedIn)
{
assert(false); // prevent copying
}
assert(false); // prevent assignment
return *this;
}
+
};
#endif /* SQUID_BODY_PIPE_H */
+
/* local types */
typedef struct {
- int bit_count; /* total number of bits */
- int bit_on_count; /* #bits turned on */
- int bseq_len_sum; /* sum of all bit seq length */
- int bseq_count; /* number of bit seqs */
+ int bit_count; /* total number of bits */
+ int bit_on_count; /* #bits turned on */
+ int bseq_len_sum; /* sum of all bit seq length */
+ int bseq_count; /* number of bit seqs */
} CacheDigestStats;
/* local functions */
cacheDigestCreate(int capacity, int bpe)
{
CacheDigest *cd = (CacheDigest *)memAllocate(MEM_CACHE_DIGEST);
- assert(SQUID_MD5_DIGEST_LENGTH == 16); /* our hash functions rely on 16 byte keys */
+ assert(SQUID_MD5_DIGEST_LENGTH == 16); /* our hash functions rely on 16 byte keys */
cacheDigestInit(cd, capacity, bpe);
return cd;
}
const int tot_count = true_count + false_count;
assert(label);
- assert(tot_count == hit_count + miss_count); /* paranoid */
+ assert(tot_count == hit_count + miss_count); /* paranoid */
if (!tot_count) {
storeAppendPrintf(sentry, "no guess stats for %s available\n", label);
}
#endif
+
void cacheDigestReport(CacheDigest * cd, const char *label, StoreEntry * e);
#endif /* SQUID_CACHEDIGEST_H_ */
+
};
#endif /* SQUID_CACHEMANAGER_H */
+
};
#endif /* SQUID_CACHEPEER_H_ */
+
};
#endif /* SQUID_CACHEPEERDOMAINLIST_H_ */
+
theIn->consume(crlfEnd);
theStep = theChunkSize ? psChunkBody : psTrailer;
}
+
};
#endif /* SQUID_CHUNKEDCODINGPARSER_H */
+
aclDestroyAccessList(&pools[i].access);
}
}
+
{
public:
ClientDelayPool()
- : access(NULL), rate(0), highwatermark(0) {}
+ : access(NULL), rate(0), highwatermark(0) {}
void dump (StoreEntry * entry, unsigned int poolNumberMinusOne) const;
acl_access *access;
int rate;
{
public:
ClientDelayConfig()
- : initial(50) {}
+ : initial(50) {}
void freePoolCount();
void dumpPoolCount(StoreEntry * entry, const char *name) const;
/* parsing of client_delay_pools - number of pools */
};
#endif // SQUID_CLIENTDELAYCONFIG_H
+
#endif /* USE_DELAY_POOLS */
#endif
+
};
#endif /* SQUID_CLIENTREQUESTCONTEXT_H */
+
};
#endif /* SQUID_COLLAPSED_FORWARDING_H */
+
/* CommCommonCbParams */
CommCommonCbParams::CommCommonCbParams(void *aData):
- data(cbdataReference(aData)), conn(), flag(Comm::OK), xerrno(0), fd(-1)
+ data(cbdataReference(aData)), conn(), flag(Comm::OK), xerrno(0), fd(-1)
{
}
CommCommonCbParams::CommCommonCbParams(const CommCommonCbParams &p):
- data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd)
+ data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd)
{
}
/* CommAcceptCbParams */
CommAcceptCbParams::CommAcceptCbParams(void *aData):
- CommCommonCbParams(aData), xaction()
+ CommCommonCbParams(aData), xaction()
{
}
/* CommConnectCbParams */
CommConnectCbParams::CommConnectCbParams(void *aData):
- CommCommonCbParams(aData)
+ CommCommonCbParams(aData)
{
}
/* CommIoCbParams */
CommIoCbParams::CommIoCbParams(void *aData): CommCommonCbParams(aData),
- buf(NULL), size(0)
+ buf(NULL), size(0)
{
}
/* CommCloseCbParams */
CommCloseCbParams::CommCloseCbParams(void *aData):
- CommCommonCbParams(aData)
+ CommCommonCbParams(aData)
{
}
/* CommTimeoutCbParams */
CommTimeoutCbParams::CommTimeoutCbParams(void *aData):
- CommCommonCbParams(aData)
+ CommCommonCbParams(aData)
{
}
/* FdeCbParams */
FdeCbParams::FdeCbParams(void *aData):
- CommCommonCbParams(aData)
+ CommCommonCbParams(aData)
{
}
CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB *aHandler,
const CommAcceptCbParams &aParams):
- CommDialerParamsT<CommAcceptCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<CommAcceptCbParams>(aParams),
+ handler(aHandler)
{
}
CommAcceptCbPtrFun::CommAcceptCbPtrFun(const CommAcceptCbPtrFun &o):
- CommDialerParamsT<CommAcceptCbParams>(o.params),
- handler(o.handler)
+ CommDialerParamsT<CommAcceptCbParams>(o.params),
+ handler(o.handler)
{
}
CommConnectCbPtrFun::CommConnectCbPtrFun(CNCB *aHandler,
const CommConnectCbParams &aParams):
- CommDialerParamsT<CommConnectCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<CommConnectCbParams>(aParams),
+ handler(aHandler)
{
}
/* CommIoCbPtrFun */
CommIoCbPtrFun::CommIoCbPtrFun(IOCB *aHandler, const CommIoCbParams &aParams):
- CommDialerParamsT<CommIoCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<CommIoCbParams>(aParams),
+ handler(aHandler)
{
}
CommCloseCbPtrFun::CommCloseCbPtrFun(CLCB *aHandler,
const CommCloseCbParams &aParams):
- CommDialerParamsT<CommCloseCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<CommCloseCbParams>(aParams),
+ handler(aHandler)
{
}
CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(CTCB *aHandler,
const CommTimeoutCbParams &aParams):
- CommDialerParamsT<CommTimeoutCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<CommTimeoutCbParams>(aParams),
+ handler(aHandler)
{
}
/* FdeCbPtrFun */
FdeCbPtrFun::FdeCbPtrFun(FDECB *aHandler, const FdeCbParams &aParams) :
- CommDialerParamsT<FdeCbParams>(aParams),
- handler(aHandler)
+ CommDialerParamsT<FdeCbParams>(aParams),
+ handler(aHandler)
{
}
params.print(os);
os << ')';
}
+
typedef void (C::*Method)(const Params &io);
CommCbMemFunT(const CbcPointer<C> &aJob, Method aMeth): JobDialer<C>(aJob),
- CommDialerParamsT<Params_>(aJob->toCbdata()),
- method(aMeth) {}
+ CommDialerParamsT<Params_>(aJob->toCbdata()),
+ method(aMeth) {}
virtual bool canDial(AsyncCall &c) {
return JobDialer<C>::canDial(c) &&
// accept (IOACB) dialer
class CommAcceptCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommAcceptCbParams>
+ public CommDialerParamsT<CommAcceptCbParams>
{
public:
typedef CommAcceptCbParams Params;
// connect (CNCB) dialer
class CommConnectCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommConnectCbParams>
+ public CommDialerParamsT<CommConnectCbParams>
{
public:
typedef CommConnectCbParams Params;
// read/write (IOCB) dialer
class CommIoCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommIoCbParams>
+ public CommDialerParamsT<CommIoCbParams>
{
public:
typedef CommIoCbParams Params;
// close (CLCB) dialer
class CommCloseCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommCloseCbParams>
+ public CommDialerParamsT<CommCloseCbParams>
{
public:
typedef CommCloseCbParams Params;
};
class CommTimeoutCbPtrFun:public CallDialer,
- public CommDialerParamsT<CommTimeoutCbParams>
+ public CommDialerParamsT<CommTimeoutCbParams>
{
public:
typedef CommTimeoutCbParams Params;
/// FD event (FDECB) dialer
class FdeCbPtrFun: public CallDialer,
- public CommDialerParamsT<FdeCbParams>
+ public CommDialerParamsT<FdeCbParams>
{
public:
typedef FdeCbParams Params;
const char *callName, const Dialer &aDialer);
inline CommCbFunPtrCallT(const CommCbFunPtrCallT &o) :
- AsyncCall(o.debugSection, o.debugLevel, o.name),
- dialer(o.dialer) {}
+ AsyncCall(o.debugSection, o.debugLevel, o.name),
+ dialer(o.dialer) {}
~CommCbFunPtrCallT() {}
template <class Dialer>
CommCbFunPtrCallT<Dialer>::CommCbFunPtrCallT(int aDebugSection, int aDebugLevel,
const char *callName, const Dialer &aDialer):
- AsyncCall(aDebugSection, aDebugLevel, callName),
- dialer(aDialer)
+ AsyncCall(aDebugSection, aDebugLevel, callName),
+ dialer(aDialer)
{
}
}
#endif /* SQUID_COMMCALLS_H */
+
};
#endif /* COMMREAD_H */
+
#include "squid.h"
#include "CompletionDispatcher.h"
+
};
#endif /* SQUID_COMPLETIONDISPATCHER_H */
+
#endif /* USE_DELAY_POOLS */
#endif /* COMPOSITEPOOLNODE_H */
+
i != options.end(); ++i)
(*i)->dump(e);
}
+
};
#endif /* SQUID_CONFIGOPTION_H */
+
std::ostringstream message;
CfgFile *f = CfgFiles.top();
message << "Bungled " << f->filePath << " line " << f->lineNo <<
- ": " << f->currentLine << std::endl;
+ ": " << f->currentLine << std::endl;
CfgFiles.pop();
delete f;
while (!CfgFiles.empty()) {
f = CfgFiles.top();
message << " included from " << f->filePath << " line " <<
- f->lineNo << ": " << f->currentLine << std::endl;
+ f->lineNo << ": " << f->currentLine << std::endl;
CfgFiles.pop();
delete f;
}
message << " included from " << cfg_filename << " line " <<
- config_lineno << ": " << config_input_line << std::endl;
+ config_lineno << ": " << config_input_line << std::endl;
std::string msg = message.str();
fatalf("%s", msg.c_str());
} else
while (ConfigParser::RecognizeQuotedPair_ && *nextToken == '\\') {
// NP: do not permit \0 terminator to be escaped.
if (*(nextToken+1) && *(nextToken+1) != '\r' && *(nextToken+1) != '\n') {
- nextToken += 2; // skip the quoted-pair (\-escaped) character
- nextToken += strcspn(nextToken, sep);
+ nextToken += 2; // skip the quoted-pair (\-escaped) character
+ nextToken += strcspn(nextToken, sep);
} else {
debugs(3, DBG_CRITICAL, "FATAL: Unescaped '\' character in regex pattern: " << tokenStart);
self_destruct();
if (wordFile)
fclose(wordFile);
}
+
* The config parser read mechanism can cope, but the other systems
* receiving the data from its buffers on such lines may not.
*/
-#define CONFIG_LINE_LIMIT 2048
+#define CONFIG_LINE_LIMIT 2048
/**
* A configuration file Parser. Instances of this class track
static bool ParseQuotedOrToEol_; ///< The next tokens will be handled as quoted or to_eol token
static bool RecognizeQuotedPair_; ///< The next tokens may contain quoted-pair (\-escaped) characters
static bool PreviewMode_; ///< The next token will not poped from cfg files, will just previewd.
- static bool ParseKvPair_; ///<The next token will be handled as kv-pair token
+ static bool ParseKvPair_; ///<The next token will be handled as kv-pair token
static enum ParsingStates {atParseKey, atParseValue} KvPairState_; ///< Parsing state while parsing kv-pair tokens
};
int parseConfigFile(const char *file_name);
#endif /* SQUID_CONFIGPARSER_H */
+
void CpuAffinityCheck();
#endif // SQUID_CPU_AFFINITY_H
+
}
return cpuAffinitySet;
}
+
};
#endif // SQUID_CPU_AFFINITY_MAP_H
+
{
memcpy(&theCpuSet, &aCpuSet, sizeof(theCpuSet));
}
+
};
#endif // SQUID_CPU_AFFINITY_SET_H
+
#define MAX_DEBUG_SECTIONS 100
/* defined names for Debug Levels */
-#define DBG_CRITICAL 0 /**< critical messages always shown when they occur */
-#define DBG_IMPORTANT 1 /**< important messages always shown when their section is being checked */
+#define DBG_CRITICAL 0 /**< critical messages always shown when they occur */
+#define DBG_IMPORTANT 1 /**< important messages always shown when their section is being checked */
/* levels 2-8 are still being discussed amongst the developers */
-#define DBG_DATA 9 /**< output is a large data dump only necessary for advanced debugging */
+#define DBG_DATA 9 /**< output is a large data dump only necessary for advanced debugging */
#define DBG_PARSE_NOTE(x) (opt_parse_cfg_only?0:(x)) /**< output is always to be displayed on '-k parse' but at level-x normally. */
{
public:
Raw(const char *label, const char *data, const size_t size):
- level(-1), label_(label), data_(data), size_(size) {}
+ level(-1), label_(label), data_(data), size_(size) {}
/// limit data printing to at least the given debugging level
Raw &minLevel(const int aLevel) { level = aLevel; return *this; }
}
#endif /* SQUID_DEBUG_H */
+
}
#endif /* USE_DELAY_POOLS */
+
};
#endif /* SQUID_DELAYBUCKET_H */
+
}
#endif /* USE_DELAY_POOLS */
+
};
#endif /* SQUID_DELAYCONFIG_H */
+
{}
DelayId::DelayId (unsigned short aPool) :
- pool_ (aPool), compositeId (NULL), markedAsNoDelay (false)
+ pool_ (aPool), compositeId (NULL), markedAsNoDelay (false)
{
debugs(77, 3, "DelayId::DelayId: Pool " << aPool << "u");
}
}
#endif /* USE_DELAY_POOLS */
+
#endif /* USE_DELAY_POOLS */
#endif /* SQUID_DELAYID_H */
+
#endif /* USE_DELAY_POOLS */
#endif /* DELAYIDCOMPOSITE_H */
+
}
#endif /* USE_DELAY_POOLS */
+
#endif /* USE_DELAY_POOLS */
#endif /* DELAYPOOL_H */
+
};
#endif /* SQUID_DELAYPOOLS_H */
+
};
#endif /* SQUID_DELAYSPEC_H */
+
#endif /* USE_DELAY_POOLS */
#endif /* DELAYTAGGED_H */
+
}
#endif /* USE_DELAY_POOLS && USE_AUTH */
+
#endif /* USE_DELAY_POOLS && USE_AUTH */
#endif /* DELAYUSER_H */
+
#endif /* USE_DELAY_POOLS */
#endif /* SQUID_DELAYVECTOR_H */
+
// pre-allocates descriptor store and index for Squid_MaxFD descriptors
DescriptorSet::DescriptorSet(): descriptors_(NULL), index_(NULL),
- capacity_(0), size_(0)
+ capacity_(0), size_(0)
{
// we allocate once and never realloc, at least for now
capacity_ = Squid_MaxFD;
// \todo add "name" if the set is used for more than just half-closed FDs
os << size_ << " FDs";
}
+
#endif /* USE_DISKIO_AIO */
#endif /* SQUID_AIODISKFILE_H */
+
#endif /* USE_DISKIO_AIO */
#endif /* SQUID_AIODISKIOMODULE_H */
+
#include "DiskIO/WriteRequest.h"
AIODiskIOStrategy::AIODiskIOStrategy() :
- fd(-1)
+ fd(-1)
{
aq.aq_state = AQ_STATE_NONE;
aq.aq_numpending = 0;
/* found nothing */
return -1;
}
+
#endif /* USE_DISKIO_AIO */
#endif /* SQUID_AIODISKIOSTRATEGY_H */
+
else
dwCreationDisposition = (mode & O_CREAT) ? OPEN_ALWAYS : OPEN_EXISTING;
- if ((hndl = CreateFile(path, /* file name */
- dwDesiredAccess, /* access mode */
- 0, /* share mode */
- NULL, /* SD */
- dwCreationDisposition, /* how to create */
- FILE_FLAG_OVERLAPPED, /* file attributes */
- NULL /* handle to template file */
+ if ((hndl = CreateFile(path, /* file name */
+ dwDesiredAccess, /* access mode */
+ 0, /* share mode */
+ NULL, /* SD */
+ dwCreationDisposition, /* how to create */
+ FILE_FLAG_OVERLAPPED, /* file attributes */
+ NULL /* handle to template file */
)) != INVALID_HANDLE_VALUE) {
++ statCounter.syscalls.disk.opens;
fd = _open_osfhandle((long) hndl, 0);
return aiocbp->aio_sigevent.sigev_signo;
}
#endif /* _SQUID_WINDOWS_ */
+
#if USE_DISKIO_AIO
#ifndef off64_t
-typedef int64_t off64_t;
+typedef int64_t off64_t;
#endif
#if _SQUID_WINDOWS_
#endif /* _SQUID_WINDOWS_ */
#endif /* USE_DISKIO_AIO */
#endif /* __WIN32_AIO_H__ */
+
/* for FREE* */
#include "typedefs.h"
-#define MAX_ASYNCOP 128
+#define MAX_ASYNCOP 128
typedef enum {
- AQ_STATE_NONE, /* Not active/uninitialised */
- AQ_STATE_SETUP /* Initialised */
+ AQ_STATE_NONE, /* Not active/uninitialised */
+ AQ_STATE_SETUP /* Initialised */
} async_queue_state_t;
typedef enum {
struct _async_queue {
async_queue_state_t aq_state;
- async_queue_entry_t aq_queue[MAX_ASYNCOP]; /* queued ops */
- int aq_numpending; /* Num of pending ops */
+ async_queue_entry_t aq_queue[MAX_ASYNCOP]; /* queued ops */
+ int aq_numpending; /* Num of pending ops */
};
#endif /* USE_DISKIO_AIO */
#endif /* __ASYNC_IO_H_ */
+
};
#endif /* SQUID_BLOCKINGDISKIOMODULE_H */
+
}
if (errflag == DISK_EOF)
- errflag = DISK_OK; /* EOF is signalled by len == 0, not errors... */
+ errflag = DISK_OK; /* EOF is signalled by len == 0, not errors... */
ReadRequest::Pointer result = readRequest;
};
#endif /* SQUID_BLOCKINGFILE_H */
+
{
unlinkdUnlink(path);
}
+
};
#endif /* SQUID_BLOCKINGIOSTRATEGY_H */
+
{
return "DiskDaemon";
}
+
};
#endif /* SQUID_DISKDAEMONDISKIOMODULE_H */
+
}
DiskdAction::DiskdAction(const Mgr::CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(79, 5, HERE);
}
hdrMsg.checkType(Ipc::mtCacheMgrResponse);
hdrMsg.getPod(data);
}
+
};
#endif /* SQUID_DISKD_ACTION_H */
+
CBDATA_CLASS_INIT(DiskdFile);
DiskdFile::DiskdFile(char const *aPath, DiskdIOStrategy *anIO) :
- errorOccured(false),
- IO(anIO),
- mode(0),
- inProgressIOs(0)
+ errorOccured(false),
+ IO(anIO),
+ mode(0),
+ inProgressIOs(0)
{
assert(aPath);
debugs(79, 3, "DiskdFile::DiskdFile: " << aPath);
{
return inProgressIOs != 0;
}
+
if (x < 0) {
debugs(79, DBG_IMPORTANT, "storeDiskdSend UNLINK: " << xstrerror());
- ::unlink(buf); /* XXX EWW! */
+ ::unlink(buf); /* XXX EWW! */
// shm.put (shm_offset);
}
}
while (1) {
-#ifdef ALWAYS_ZERO_BUFFERS
+#ifdef ALWAYS_ZERO_BUFFERS
memset(&M, '\0', sizeof(M));
#endif
++diskd_stats.recv_count;
--away;
handle(&M);
- retval = 1; /* Return that we've actually done some work */
+ retval = 1; /* Return that we've actually done some work */
if (M.shm_offset > -1)
shm.put ((off_t) M.shm_offset);
{
storeAppendPrintf(&sentry, "Pending operations: %d\n", away);
}
+
extern diskd_stats_t diskd_stats;
#endif
+
};
#endif /* SQUID_DIOMSG_H__ */
+
};
#endif /* SQUID_DISKFILE_H */
+
result = Find("Blocking");
return result;
}
+
};
#endif /* SQUID_DISKIOMODULE_H */
+
};
#endif /* SQUID_DISKIOSTRATEGY_H */
+
DoneSignalled = false;
}
}
+
};
#endif /* SQUID_SRC_DISKIO_DISKTHREADS_COMMIO_H */
+
int aio_return;
int aio_errno;
enum _squidaio_request_type result_type;
- void *_data; /* Internal housekeeping */
- void *data; /* Available to the caller */
+ void *_data; /* Internal housekeeping */
+ void *data; /* Available to the caller */
};
struct squidaio_ctrl_t {
extern dlink_list used_list;
#endif
+
CBDATA_CLASS_INIT(DiskThreadsDiskFile);
DiskThreadsDiskFile::DiskThreadsDiskFile(char const *aPath, DiskThreadsIOStrategy *anIO):fd(-1), errorOccured (false), IO(anIO),
- inProgressIOs (0)
+ inProgressIOs (0)
{
assert(aPath);
debugs(79, 3, "UFSFile::UFSFile: " << aPath);
#else
if (errflag == DISK_EOF)
- errflag = DISK_OK; /* EOF is signalled by len == 0, not errors... */
+ errflag = DISK_OK; /* EOF is signalled by len == 0, not errors... */
#endif
template <class RT>
cbdata_type IoResult<RT>::CBDATA_IoResult = CBDATA_UNKNOWN;
/** \endcond */
+
IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);}
#endif /* SQUID_DISKTHREADSDISKFILE_H */
+
{
return "DiskThreads";
}
+
};
#endif /* SQUID_DISKTHREADSDISKIOMODULE_H */
+
}
if (ctrlp == NULL)
- continue; /* XXX Should not happen */
+ continue; /* XXX Should not happen */
dlinkDelete(&ctrlp->node, &used_list);
ctrlp->done_handler = NULL;
if (cbdataReferenceValidDone(ctrlp->done_handler_data, &cbdata)) {
- retval = 1; /* Return that we've actually done some work */
+ retval = 1; /* Return that we've actually done some work */
done_callback(ctrlp->fd, cbdata, ctrlp->bufp,
ctrlp->result.aio_return, ctrlp->result.aio_errno);
} else {
DiskThreadsIOStrategy::sync()
{
if (!initialised)
- return; /* nothing to do then */
+ return; /* nothing to do then */
/* Flush all pending operations */
debugs(32, 2, "aioSync: flushing pending I/O operations");
}
DiskThreadsIOStrategy::DiskThreadsIOStrategy() :
- initialised(false),
- squidaio_ctrl_pool(NULL)
+ initialised(false),
+ squidaio_ctrl_pool(NULL)
{}
void
++statCounter.syscalls.disk.unlinks;
aioUnlink(path, NULL, NULL);
}
+
#ifndef __STORE_DISKTHREADEDIOSTRATEGY_H__
#define __STORE_DISKTHREADEDIOSTRATEGY_H__
-#define _AIO_OPEN 0
-#define _AIO_READ 1
-#define _AIO_WRITE 2
-#define _AIO_CLOSE 3
-#define _AIO_UNLINK 4
-#define _AIO_OPENDIR 5
-#define _AIO_STAT 6
+#define _AIO_OPEN 0
+#define _AIO_READ 1
+#define _AIO_WRITE 2
+#define _AIO_CLOSE 3
+#define _AIO_UNLINK 4
+#define _AIO_OPENDIR 5
+#define _AIO_STAT 6
#include "DiskIO/DiskIOStrategy.h"
class DiskThreadsIOStrategy : public DiskIOStrategy
};
#endif
+
#include <sched.h>
#endif
-#define RIDICULOUS_LENGTH 4096
+#define RIDICULOUS_LENGTH 4096
enum _squidaio_thread_status {
_THREAD_STARTING = 0,
squidaio_request_t *volatile head;
squidaio_request_t *volatile *volatile tailp;
unsigned long requests;
- unsigned long blocked; /* main failed to lock the queue */
+ unsigned long blocked; /* main failed to lock the queue */
} squidaio_request_queue_t;
typedef struct squidaio_thread_t squidaio_thread_t;
static int squidaio_initialised = 0;
#define AIO_LARGE_BUFS 16384
-#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
-#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
-#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
-#define AIO_MICRO_BUFS 128
+#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
+#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
+#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
+#define AIO_MICRO_BUFS 128
-static MemAllocator *squidaio_large_bufs = NULL; /* 16K */
-static MemAllocator *squidaio_medium_bufs = NULL; /* 8K */
-static MemAllocator *squidaio_small_bufs = NULL; /* 4K */
-static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
-static MemAllocator *squidaio_micro_bufs = NULL; /* 128K */
+static MemAllocator *squidaio_large_bufs = NULL; /* 16K */
+static MemAllocator *squidaio_medium_bufs = NULL; /* 8K */
+static MemAllocator *squidaio_small_bufs = NULL; /* 4K */
+static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
+static MemAllocator *squidaio_micro_bufs = NULL; /* 128K */
static int request_queue_len = 0;
static MemAllocator *squidaio_request_pool = NULL;
squidaio_do_unlink(request);
break;
-#if AIO_OPENDIR /* Opendir not implemented yet */
+#if AIO_OPENDIR /* Opendir not implemented yet */
case _AIO_OP_OPENDIR:
squidaio_do_opendir(request);
request->err = EINVAL;
break;
}
- } else { /* cancelled */
+ } else { /* cancelled */
request->ret = -1;
request->err = EINTR;
}
pthread_mutex_unlock(&done_queue.mutex);
CommIO::NotifyIOCompleted();
++ threadp->requests;
- } /* while forever */
+ } /* while forever */
return NULL;
-} /* squidaio_thread_loop */
+} /* squidaio_thread_loop */
static void
squidaio_queue_request(squidaio_request_t * request)
squidaio_sync();
debugs(43, DBG_CRITICAL, "squidaio_queue_request: Synced");
}
-} /* squidaio_queue_request */
+} /* squidaio_queue_request */
static void
squidaio_cleanup_request(squidaio_request_t * requestp)
}
squidaio_request_pool->freeOne(requestp);
-} /* squidaio_cleanup_request */
+} /* squidaio_cleanup_request */
int
squidaio_cancel(squidaio_result_t * resultp)
}
return 1;
-} /* squidaio_cancel */
+} /* squidaio_cancel */
int
squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp)
goto AIO_REPOLL;
return resultp;
-} /* squidaio_poll_done */
+} /* squidaio_poll_done */
int
squidaio_operations_pending(void)
threadp = threadp->next;
}
}
+
#include <fcntl.h>
#include <dirent.h>
-#define RIDICULOUS_LENGTH 4096
+#define RIDICULOUS_LENGTH 4096
enum _squidaio_thread_status {
_THREAD_STARTING = 0,
squidaio_request_t *volatile head;
squidaio_request_t *volatile *volatile tailp;
unsigned long requests;
- unsigned long blocked; /* main failed to lock the queue */
+ unsigned long blocked; /* main failed to lock the queue */
} squidaio_request_queue_t;
typedef struct squidaio_thread_t squidaio_thread_t;
static int squidaio_initialised = 0;
#define AIO_LARGE_BUFS 16384
-#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
-#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
-#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
-#define AIO_MICRO_BUFS 128
+#define AIO_MEDIUM_BUFS AIO_LARGE_BUFS >> 1
+#define AIO_SMALL_BUFS AIO_LARGE_BUFS >> 2
+#define AIO_TINY_BUFS AIO_LARGE_BUFS >> 3
+#define AIO_MICRO_BUFS 128
-static MemAllocator *squidaio_large_bufs = NULL; /* 16K */
-static MemAllocator *squidaio_medium_bufs = NULL; /* 8K */
-static MemAllocator *squidaio_small_bufs = NULL; /* 4K */
-static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
-static MemAllocator *squidaio_micro_bufs = NULL; /* 128K */
+static MemAllocator *squidaio_large_bufs = NULL; /* 16K */
+static MemAllocator *squidaio_medium_bufs = NULL; /* 8K */
+static MemAllocator *squidaio_small_bufs = NULL; /* 4K */
+static MemAllocator *squidaio_tiny_bufs = NULL; /* 2K */
+static MemAllocator *squidaio_micro_bufs = NULL; /* 128K */
static int request_queue_len = 0;
static MemAllocator *squidaio_request_pool = NULL;
squidaio_do_unlink(request);
break;
-#if AIO_OPENDIR /* Opendir not implemented yet */
+#if AIO_OPENDIR /* Opendir not implemented yet */
case _AIO_OP_OPENDIR:
squidaio_do_opendir(request);
request->err = EINVAL;
break;
}
- } else { /* cancelled */
+ } else { /* cancelled */
request->ret = -1;
request->err = EINTR;
}
CommIO::NotifyIOCompleted();
Sleep(0);
++ threadp->requests;
- } /* while forever */
+ } /* while forever */
CloseHandle(cond);
return 0;
-} /* squidaio_thread_loop */
+} /* squidaio_thread_loop */
static void
squidaio_queue_request(squidaio_request_t * request)
squidaio_sync();
debugs(43, DBG_CRITICAL, "squidaio_queue_request: Synced");
}
-} /* squidaio_queue_request */
+} /* squidaio_queue_request */
static void
squidaio_cleanup_request(squidaio_request_t * requestp)
}
squidaio_request_pool->freeOne(requestp);
-} /* squidaio_cleanup_request */
+} /* squidaio_cleanup_request */
int
squidaio_cancel(squidaio_result_t * resultp)
}
return 1;
-} /* squidaio_cancel */
+} /* squidaio_cancel */
int
squidaio_open(const char *path, int oflag, mode_t mode, squidaio_result_t * resultp)
goto AIO_REPOLL;
return resultp;
-} /* squidaio_poll_done */
+} /* squidaio_poll_done */
int
squidaio_operations_pending(void)
threadp = threadp->next;
}
}
+
ctrlp->result.data = ctrlp;
squidaio_write(fd, bufp, len, offset, seekmode, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
-} /* aioWrite */
+} /* aioWrite */
void
aioRead(int fd, off_t offset, size_t len, AIOCB * callback, void *callback_data)
squidaio_read(fd, ctrlp->bufp, len, offset, seekmode, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
return;
-} /* aioRead */
+} /* aioRead */
void
squidaio_stat(path, sb, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
return;
-} /* aioStat */
+} /* aioStat */
void
aioUnlink(const char *path, AIOCB * callback, void *callback_data)
ctrlp->result.data = ctrlp;
squidaio_unlink(path, &ctrlp->result);
dlinkAdd(ctrlp, &ctrlp->node, &used_list);
-} /* aioUnlink */
+} /* aioUnlink */
int
aioQueueSize(void)
{
return DiskThreadsIOStrategy::Instance.squidaio_ctrl_pool->inUseCount();
}
+
};
#endif /* SQUID_IOREQUESTOR_H */
+
};
#endif /* SQUID_IPC_IODISKIOMODULE_H */
+
/// IpcIo wrapper for debugs() streams; XXX: find a better class name
struct SipcIo {
SipcIo(int aWorker, const IpcIoMsg &aMsg, int aDisker):
- worker(aWorker), msg(aMsg), disker(aDisker) {}
+ worker(aWorker), msg(aMsg), disker(aDisker) {}
int worker;
const IpcIoMsg &msg;
}
IpcIoFile::IpcIoFile(char const *aDb):
- dbName(aDb), diskId(-1), error_(false), lastRequestId(0),
- olderRequests(&requestMap1), newerRequests(&requestMap2),
- timeoutCheckScheduled(false)
+ dbName(aDb), diskId(-1), error_(false), lastRequestId(0),
+ olderRequests(&requestMap1), newerRequests(&requestMap2),
+ timeoutCheckScheduled(false)
{
}
/* IpcIoMsg */
IpcIoMsg::IpcIoMsg():
- requestId(0),
- offset(0),
- len(0),
- command(IpcIo::cmdNone),
- xerrno(0)
+ requestId(0),
+ offset(0),
+ len(0),
+ command(IpcIo::cmdNone),
+ xerrno(0)
{
start.tv_sec = 0;
start.tv_usec = 0;
/* IpcIoPendingRequest */
IpcIoPendingRequest::IpcIoPendingRequest(const IpcIoFile::Pointer &aFile):
- file(aFile), readRequest(NULL), writeRequest(NULL)
+ file(aFile), readRequest(NULL), writeRequest(NULL)
{
}
{
delete owner;
}
+
};
#endif /* SQUID_IPC_IOFILE_H */
+
{
unlinkdUnlink(path);
}
+
};
#endif /* SQUID_IPC_IOIOSTRATEGY_H */
+
};
#endif /* SQUID_MMAPPEDDISKIOMODULE_H */
+
};
MmappedFile::MmappedFile(char const *aPath): fd(-1),
- minOffset(0), maxOffset(-1), error_(false)
+ minOffset(0), maxOffset(-1), error_(false)
{
assert(aPath);
path_ = xstrdup(aPath);
}
Mmapping::Mmapping(int aFd, size_t aLength, int aProt, int aFlags, off_t anOffset):
- fd(aFd), length(aLength), prot(aProt), flags(aFlags), offset(anOffset),
- delta(-1), buf(NULL)
+ fd(aFd), length(aLength), prot(aProt), flags(aFlags), offset(anOffset),
+ delta(-1), buf(NULL)
{
}
}
// TODO: check MAP_NORESERVE, consider MAP_POPULATE and MAP_FIXED
+
};
#endif /* SQUID_MMAPPEDFILE_H */
+
{
unlinkdUnlink(path);
}
+
};
#endif /* SQUID_MMAPPEDIOSTRATEGY_H */
+
CBDATA_CLASS_INIT(ReadRequest);
ReadRequest::ReadRequest(char *aBuf, off_t anOffset, size_t aLen) : buf (aBuf), offset(anOffset), len(aLen)
{}
+
};
#endif /* SQUID_READREQUEST_H */
+
CBDATA_CLASS_INIT(WriteRequest);
WriteRequest::WriteRequest(char const *aBuf, off_t anOffset, size_t aLen, FREE *aFree) : buf (aBuf), offset(anOffset), len(aLen), free_func(aFree)
{}
+
};
#endif /* SQUID_WRITEREQUEST_H */
+
}
DnsLookupDetails::DnsLookupDetails(const String &e, int w):
- error(e), wait(w)
+ error(e), wait(w)
{
}
os << " lookup_err=" << error;
return os;
}
+
{
return etagStringsMatch(tag1, tag2);
}
+
bool etagIsWeakEqual(const ETag &tag1, const ETag &tag2);
#endif /* _SQUIDETAG_H */
+
EventLoop *EventLoop::Running = NULL;
EventLoop::EventLoop() : errcount(0), last_loop(false), timeService(NULL),
- primaryEngine(NULL),
- loop_delay(EVENT_LOOP_TIMEOUT),
- error(false),
- runOnceResult(false)
+ primaryEngine(NULL),
+ loop_delay(EVENT_LOOP_TIMEOUT),
+ error(false),
+ runOnceResult(false)
{}
void
{
last_loop = true;
}
+
#include <vector>
-#define EVENT_LOOP_TIMEOUT 1000 /* 1s timeout */
+#define EVENT_LOOP_TIMEOUT 1000 /* 1s timeout */
class AsyncEngine;
class TimeEngine;
};
#endif /* SQUID_EVENTLOOP_H */
+
void externalAclShutdown(void);
#endif /* SQUID_EXTERNALACL_H */
+
*/
ExternalACLEntry::ExternalACLEntry() :
- notes()
+ notes()
{
lru.next = lru.prev = NULL;
result = ACCESS_DENIED;
tag = someData.tag;
log = someData.log;
}
+
#include <cmath>
FadingCounter::FadingCounter(): horizon(-1), precision(10), delta(-1),
- lastTime(0), total(0)
+ lastTime(0), total(0)
{
counters.reserve(precision);
while (counters.size() < static_cast<unsigned int>(precision))
return total;
}
+
};
#endif /* SQUID_FADING_COUNTER_H */
+
};
#endif /* FILEMAP_H_ */
+
typedef void (FwdState::*Method)(Ssl::PeerConnectorAnswer &);
FwdStatePeerAnswerDialer(Method method, FwdState *fwd):
- method_(method), fwd_(fwd), answer_() {}
+ method_(method), fwd_(fwd), answer_() {}
/* CallDialer API */
virtual bool canDial(AsyncCall &call) { return fwd_.valid(); }
/**** PUBLIC INTERFACE ********************************************************/
FwdState::FwdState(const Comm::ConnectionPointer &client, StoreEntry * e, HttpRequest * r, const AccessLogEntryPointer &alp):
- al(alp)
+ al(alp)
{
debugs(17, 2, HERE << "Forwarding client request " << client << ", url=" << e->url() );
entry = e;
page_id = ERR_FORWARDING_DENIED;
ErrorState *anErr = new ErrorState(page_id, Http::scForbidden, request);
- errorAppendEntry(entry, anErr); // frees anErr
+ errorAppendEntry(entry, anErr); // frees anErr
return;
}
}
if (shutting_down) {
/* more yuck */
ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, Http::scServiceUnavailable, request);
- errorAppendEntry(entry, anErr); // frees anErr
+ errorAppendEntry(entry, anErr); // frees anErr
return;
}
errorAppendEntry(entry, anErr);
}
- self = NULL; // refcounted
+ self = NULL; // refcounted
}
// If the Server quits before nibbling at the request body, the body sender
whoisStart(this);
break;
- case AnyP::PROTO_WAIS: /* Not implemented */
+ case AnyP::PROTO_WAIS: /* Not implemented */
default:
debugs(17, DBG_IMPORTANT, "WARNING: Cannot retrieve '" << entry->url() << "'.");
conn.nfmark = 0;
#endif
}
+
void getOutgoingAddress(HttpRequest * request, Comm::ConnectionPointer conn);
#endif /* SQUID_FORWARD_H */
+
};
#endif /* SQUID_GENERIC_H */
+
hier_code code;
char host[SQUIDHOSTNAMELEN];
ping_data ping;
- char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
- lookup_t cd_lookup; /* cd prediction: none, miss, hit */
- int n_choices; /* #peers we selected from (cd only) */
- int n_ichoices; /* #peers with known rtt we selected from (cd only) */
+ char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */
+ lookup_t cd_lookup; /* cd prediction: none, miss, hit */
+ int n_choices; /* #peers we selected from (cd only) */
+ int n_ichoices; /* #peers with known rtt we selected from (cd only) */
struct timeval peer_select_start;
};
#endif /* SQUID_HTTPHIERARCHYLOGENTRY_H */
+
* as MemBuf doesn't have a copy-constructor. If such a constructor
* is ever added, add such protection here.
*/
- mb = mb_; /* absorb */
+ mb = mb_; /* absorb */
}
void
if (mb->contentSize())
packerAppend(p, mb->content(), mb->contentSize());
}
+
};
#endif /* HTTPBODY_H_ */
+
typedef AsyncCall::Pointer Callback;
HttpControlMsg(const HttpReply::Pointer &aReply, const Callback &aCallback):
- reply(aReply), cbSuccess(aCallback) {}
+ reply(aReply), cbSuccess(aCallback) {}
public:
HttpReply::Pointer reply; ///< the 1xx message being forwarded
}
#endif /* SQUID_HTTP_CONTROL_MSG_H */
+
HttpHdrCc::parse(const String & str)
{
const char *item;
- const char *p; /* '=' parameter */
+ const char *p; /* '=' parameter */
const char *pos = NULL;
http_hdr_cc_type type;
int ilen;
void
httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int count)
{
- extern const HttpHeaderStat *dump_stat; /* argh! */
+ extern const HttpHeaderStat *dump_stat; /* argh! */
const int id = (int) val;
const int valid_id = id >= 0 && id < CC_ENUM_END;
const char *name = valid_id ? CcAttrs[id].name : "INVALID";
#if !_USE_INLINE_
#include "HttpHdrCc.cci"
#endif
+
value=new_value;
setMask(hdr,setting);
}
+
static const int32_t MIN_FRESH_UNKNOWN=-1; //min_fresh is unset
HttpHdrCc() :
- mask(0), max_age(MAX_AGE_UNKNOWN), s_maxage(S_MAXAGE_UNKNOWN),
- max_stale(MAX_STALE_UNKNOWN), stale_if_error(STALE_IF_ERROR_UNKNOWN),
- min_fresh(MIN_FRESH_UNKNOWN) {}
+ mask(0), max_age(MAX_AGE_UNKNOWN), s_maxage(S_MAXAGE_UNKNOWN),
+ max_stale(MAX_STALE_UNKNOWN), stale_if_error(STALE_IF_ERROR_UNKNOWN),
+ min_fresh(MIN_FRESH_UNKNOWN) {}
/// reset data-members to default state
void clear();
#endif
#endif /* SQUID_HTTPHDRCC_H */
+
cr->spec = spec;
cr->elength = ent_len;
}
+
public:
HttpHdrRangeSpec spec;
- int64_t elength; /**< entity length, not content length */
+ int64_t elength; /**< entity length, not content length */
};
/** \todo CLEANUP: Move httpHdrContRange* functions into the class methods */
void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t);
#endif /* SQUID_HTTPHDRCONTRANGE_H */
+
void
HttpHdrRangeSpec::packInto(Packer * packer) const
{
- if (!known_spec(offset)) /* suffix */
+ if (!known_spec(offset)) /* suffix */
packerPrintf(packer, "-%" PRId64, length);
- else if (!known_spec(length)) /* trailer */
+ else if (!known_spec(length)) /* trailer */
packerPrintf(packer, "%" PRId64 "-", offset);
- else /* range */
+ else /* range */
packerPrintf(packer, "%" PRId64 "-%" PRId64,
offset, offset + length - 1);
}
outputInfo ("have");
HttpRange object(0, clen);
- if (!known_spec(offset)) { /* suffix */
+ if (!known_spec(offset)) { /* suffix */
assert(known_spec(length));
offset = object.intersection(HttpRange (clen - length, clen)).start;
- } else if (!known_spec(length)) { /* trailer */
+ } else if (!known_spec(length)) { /* trailer */
assert(known_spec(offset));
HttpRange newRange = object.intersection(HttpRange (offset, clen));
length = newRange.size();
bool merged (false);
#if MERGING_BREAKS_NOTHING
/* Note: this code works, but some clients may not like its effects */
- int64_t rhs = offset + length; /* no -1 ! */
- const int64_t donor_rhs = donor->offset + donor->length; /* no -1 ! */
+ int64_t rhs = offset + length; /* no -1 ! */
+ const int64_t donor_rhs = donor->offset + donor->length; /* no -1 ! */
assert(known_spec(offset));
assert(known_spec(donor->offset));
assert(length > 0);
/* do we have a left hand side overlap? */
if (donor->offset < offset && offset <= donor_rhs) {
- offset = donor->offset; /* decrease left offset */
+ offset = donor->offset; /* decrease left offset */
merged = 1;
}
/* do we have a right hand side overlap? */
if (donor->offset <= rhs && rhs < donor_rhs) {
- rhs = donor_rhs; /* increase right offset */
+ rhs = donor_rhs; /* increase right offset */
merged = 1;
}
}
HttpHdrRange::HttpHdrRange(HttpHdrRange const &old) :
- specs(),
- clen(HttpHdrRangeSpec::UnknownPosition)
+ specs(),
+ clen(HttpHdrRangeSpec::UnknownPosition)
{
specs.reserve(old.specs.size());
/* merged with current so get rid of the prev one */
delete specs.back();
specs.pop_back();
- continue; /* re-iterate */
+ continue; /* re-iterate */
}
specs.push_back (*i);
- ++i; /* progress */
+ ++i; /* progress */
}
debugs(64, 3, "HttpHdrRange::merge: had " << basis.size() <<
int64_t offset = 0;
for (const_iterator pos (begin()); pos != end(); ++pos) {
- if (!known_spec((*pos)->offset)) /* ignore unknowns */
+ if (!known_spec((*pos)->offset)) /* ignore unknowns */
continue;
/* Ensure typecasts is safe */
offset = (*pos)->offset;
- if (known_spec((*pos)->length)) /* avoid unknowns */
+ if (known_spec((*pos)->length)) /* avoid unknowns */
offset += (*pos)->length;
}
if (!known_spec(current)) {
if ((*pos)->length > size || !known_spec((*pos)->length))
- return 0; /* Unknown. Assume start of file */
+ return 0; /* Unknown. Assume start of file */
current = size - (*pos)->length;
}
debugs(64, 3, "HttpHdrRangeIter::debt: was " << debt_size << " now " << newDebt);
debt_size = newDebt;
}
+
{"no-store-remote", (http_hdr_type)SC_NO_STORE_REMOTE},
{"max-age", (http_hdr_type)SC_MAX_AGE},
{"content", (http_hdr_type)SC_CONTENT},
- {"Other,", (http_hdr_type)SC_OTHER} /* ',' will protect from matches */
+ {"Other,", (http_hdr_type)SC_OTHER} /* ',' will protect from matches */
};
HttpHeaderFieldInfo *ScFieldsInfo = NULL;
{
HttpHdrSc * sc=this;
const char *item;
- const char *p; /* '=' parameter */
+ const char *p; /* '=' parameter */
const char *pos = NULL;
const char *target = NULL; /* ;foo */
const char *temp = NULL; /* temp buffer */
void
httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int count)
{
- extern const HttpHeaderStat *dump_stat; /* argh! */
+ extern const HttpHeaderStat *dump_stat; /* argh! */
const int id = (int) val;
const int valid_id = id >= 0 && id < SC_ENUM_END;
const char *name = valid_id ? ScFieldsInfo[id].name.termedBuf() : "INVALID";
return NULL;
}
+
void httpHdrScSetMaxAge(HttpHdrSc *, char const *, int);
#endif /* SQUID_HTTPHDRSURROGATECONTROL_H */
+
if (isSet(c))
hist->count(c);
}
+
static const int MAX_STALE_UNSET=0; //max-stale is unset
HttpHdrScTarget(const char *target_):
- mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
+ mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
HttpHdrScTarget(const String &target_):
- mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
+ mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
HttpHdrScTarget(const HttpHdrScTarget &t):
- mask(t.mask), max_age(t.max_age), max_stale(t.max_stale),
- content_(t.content_), target(t.target) {}
+ mask(t.mask), max_age(t.max_age), max_stale(t.max_stale),
+ content_(t.content_), target(t.target) {}
bool hasNoStore() const {return isSet(SC_NO_STORE); }
void noStore(bool v) { setMask(SC_NO_STORE,v); }
void httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
#endif /* SQUID_HTTPHDRSURROGATECONTROLTARGET_H */
+
{"Age", HDR_AGE, ftInt},
{"Allow", HDR_ALLOW, ftStr},
{"Alternate-Protocol", HDR_ALTERNATE_PROTOCOL, ftStr},
- {"Authorization", HDR_AUTHORIZATION, ftStr}, /* for now */
+ {"Authorization", HDR_AUTHORIZATION, ftStr}, /* for now */
{"Cache-Control", HDR_CACHE_CONTROL, ftPCc},
{"Connection", HDR_CONNECTION, ftStr},
{"Content-Base", HDR_CONTENT_BASE, ftStr},
{"Content-Language", HDR_CONTENT_LANGUAGE, ftStr},
{"Content-Length", HDR_CONTENT_LENGTH, ftInt64},
{"Content-Location", HDR_CONTENT_LOCATION, ftStr},
- {"Content-MD5", HDR_CONTENT_MD5, ftStr}, /* for now */
+ {"Content-MD5", HDR_CONTENT_MD5, ftStr}, /* for now */
{"Content-Range", HDR_CONTENT_RANGE, ftPContRange},
{"Content-Type", HDR_CONTENT_TYPE, ftStr},
{"Cookie", HDR_COOKIE, ftStr},
{"From", HDR_FROM, ftStr},
{"Host", HDR_HOST, ftStr},
{"HTTP2-Settings", HDR_HTTP2_SETTINGS, ftStr}, /* for now */
- {"If-Match", HDR_IF_MATCH, ftStr}, /* for now */
+ {"If-Match", HDR_IF_MATCH, ftStr}, /* for now */
{"If-Modified-Since", HDR_IF_MODIFIED_SINCE, ftDate_1123},
- {"If-None-Match", HDR_IF_NONE_MATCH, ftStr}, /* for now */
+ {"If-None-Match", HDR_IF_NONE_MATCH, ftStr}, /* for now */
{"If-Range", HDR_IF_RANGE, ftDate_1123_or_ETag},
{"If-Unmodified-Since", HDR_IF_UNMODIFIED_SINCE, ftDate_1123},
{"Keep-Alive", HDR_KEEP_ALIVE, ftStr},
{"Link", HDR_LINK, ftStr},
{"Location", HDR_LOCATION, ftStr},
{"Max-Forwards", HDR_MAX_FORWARDS, ftInt64},
- {"Mime-Version", HDR_MIME_VERSION, ftStr}, /* for now */
+ {"Mime-Version", HDR_MIME_VERSION, ftStr}, /* for now */
{"Negotiate", HDR_NEGOTIATE, ftStr},
{"Origin", HDR_ORIGIN, ftStr},
{"Pragma", HDR_PRAGMA, ftStr},
{"Public", HDR_PUBLIC, ftStr},
{"Range", HDR_RANGE, ftPRange},
{"Referer", HDR_REFERER, ftStr},
- {"Request-Range", HDR_REQUEST_RANGE, ftPRange}, /* usually matches HDR_RANGE */
- {"Retry-After", HDR_RETRY_AFTER, ftStr}, /* for now (ftDate_1123 or ftInt!) */
+ {"Request-Range", HDR_REQUEST_RANGE, ftPRange}, /* usually matches HDR_RANGE */
+ {"Retry-After", HDR_RETRY_AFTER, ftStr}, /* for now (ftDate_1123 or ftInt!) */
{"Server", HDR_SERVER, ftStr},
{"Set-Cookie", HDR_SET_COOKIE, ftStr},
{"Set-Cookie2", HDR_SET_COOKIE2, ftStr},
{"Title", HDR_TITLE, ftStr},
{"Trailer", HDR_TRAILER, ftStr},
{"Transfer-Encoding", HDR_TRANSFER_ENCODING, ftStr},
- {"Translate", HDR_TRANSLATE, ftStr}, /* for now. may need to crop */
+ {"Translate", HDR_TRANSLATE, ftStr}, /* for now. may need to crop */
{"Unless-Modified-Since", HDR_UNLESS_MODIFIED_SINCE, ftStr}, /* for now ignore. may need to crop */
- {"Upgrade", HDR_UPGRADE, ftStr}, /* for now */
+ {"Upgrade", HDR_UPGRADE, ftStr}, /* for now */
{"User-Agent", HDR_USER_AGENT, ftStr},
- {"Vary", HDR_VARY, ftStr}, /* for now */
- {"Via", HDR_VIA, ftStr}, /* for now */
- {"Warning", HDR_WARNING, ftStr}, /* for now */
+ {"Vary", HDR_VARY, ftStr}, /* for now */
+ {"Via", HDR_VIA, ftStr}, /* for now */
+ {"Warning", HDR_WARNING, ftStr}, /* for now */
{"WWW-Authenticate", HDR_WWW_AUTHENTICATE, ftStr},
{"Authentication-Info", HDR_AUTHENTICATION_INFO, ftStr},
{"X-Cache", HDR_X_CACHE, ftStr},
{"FTP-Pre", HDR_FTP_PRE, ftStr},
{"FTP-Status", HDR_FTP_STATUS, ftInt},
{"FTP-Reason", HDR_FTP_REASON, ftStr},
- {"Other:", HDR_OTHER, ftStr} /* ':' will not allow matches */
+ {"Other:", HDR_OTHER, ftStr} /* ':' will not allow matches */
};
static HttpHeaderFieldInfo *Headers = NULL;
* headers with field values defined as #(values) in HTTP/1.1
* Headers that are currently not recognized, are commented out.
*/
-static HttpHeaderMask ListHeadersMask; /* set run-time using ListHeadersArr */
+static HttpHeaderMask ListHeadersMask; /* set run-time using ListHeadersArr */
static http_hdr_type ListHeadersArr[] = {
HDR_ACCEPT,
HDR_ACCEPT_CHARSET,
};
/* request-only headers */
-static HttpHeaderMask RequestHeadersMask; /* set run-time using RequestHeaders */
+static HttpHeaderMask RequestHeadersMask; /* set run-time using RequestHeaders */
static http_hdr_type RequestHeadersArr[] = {
HDR_ACCEPT,
HDR_ACCEPT_CHARSET,
};
/* reply-only headers */
-static HttpHeaderMask ReplyHeadersMask; /* set run-time using ReplyHeaders */
+static HttpHeaderMask ReplyHeadersMask; /* set run-time using ReplyHeaders */
static http_hdr_type ReplyHeadersArr[] = {
HDR_ACCEPT_ENCODING,
HDR_ACCEPT_RANGES,
assert(label);
memset(hs, 0, sizeof(HttpHeaderStat));
hs->label = label;
- hs->hdrUCountDistr.enumInit(32); /* not a real enum */
+ hs->hdrUCountDistr.enumInit(32); /* not a real enum */
hs->fieldTypeDistr.enumInit(HDR_ENUM_END);
hs->ccTypeDistr.enumInit(CC_ENUM_END);
hs->scTypeDistr.enumInit(SC_ENUM_END);
field_end = field_ptr;
- ++field_ptr; /* Move to next line */
+ ++field_ptr; /* Move to next line */
if (field_end > this_line && field_end[-1] == '\r') {
- --field_end; /* Ignore CR LF */
+ --field_end; /* Ignore CR LF */
if (owner == hoRequest && field_end > this_line) {
bool cr_only = true;
getStringPrefix(field_start, field_end-field_start) << "}");
if (Config.onoff.relaxed_header_parser) {
- char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */
+ char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */
while ((p = (char *)memchr(p, '\r', field_end - p)) != NULL) {
*p = ' ';
return reset();
}
- break; /* terminating blank line */
+ break; /* terminating blank line */
}
if ((e = HttpHeaderEntry::parse(field_start, field_end)) == NULL) {
}
PROF_stop(HttpHeaderParse);
- return 1; /* even if no fields where found, it is a valid header */
+ return 1; /* even if no fields where found, it is a valid header */
}
/* packs all the entries using supplied packer */
/* hm.. we thought it was there, but it was not found */
assert(0);
- return NULL; /* not reached */
+ return NULL; /* not reached */
}
/*
result = e;
}
- assert(result); /* must be there! */
+ assert(result); /* must be there! */
return result;
}
int count = 0;
HttpHeaderPos pos = HttpHeaderInitPos;
HttpHeaderEntry *e;
- httpHeaderMaskInit(&mask, 0); /* temporal inconsistency */
+ httpHeaderMaskInit(&mask, 0); /* temporal inconsistency */
debugs(55, 9, "deleting '" << name << "' fields in hdr " << this);
while ((e = getEntry(&pos))) {
HttpHeaderEntry *e;
debugs(55, 8, this << " del-by-id " << id);
assert_eid(id);
- assert(id != HDR_OTHER); /* does not make sense */
+ assert(id != HDR_OTHER); /* does not make sense */
if (!CBIT_TEST(mask, id))
return 0;
HttpHeader::putInt(http_hdr_type id, int number)
{
assert_eid(id);
- assert(Headers[id].type == ftInt); /* must be of an appropriate type */
+ assert(Headers[id].type == ftInt); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xitoa(number)));
}
HttpHeader::putInt64(http_hdr_type id, int64_t number)
{
assert_eid(id);
- assert(Headers[id].type == ftInt64); /* must be of an appropriate type */
+ assert(Headers[id].type == ftInt64); /* must be of an appropriate type */
assert(number >= 0);
addEntry(new HttpHeaderEntry(id, NULL, xint64toa(number)));
}
HttpHeader::putTime(http_hdr_type id, time_t htime)
{
assert_eid(id);
- assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
+ assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
addEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
}
HttpHeader::insertTime(http_hdr_type id, time_t htime)
{
assert_eid(id);
- assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
+ assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
insertEntry(new HttpHeaderEntry(id, NULL, mkrfc1123(htime)));
}
HttpHeader::putStr(http_hdr_type id, const char *str)
{
assert_eid(id);
- assert(Headers[id].type == ftStr); /* must be of an appropriate type */
+ assert(Headers[id].type == ftStr); /* must be of an appropriate type */
assert(str);
addEntry(new HttpHeaderEntry(id, NULL, str));
}
HttpHeader::getInt(http_hdr_type id) const
{
assert_eid(id);
- assert(Headers[id].type == ftInt); /* must be of an appropriate type */
+ assert(Headers[id].type == ftInt); /* must be of an appropriate type */
HttpHeaderEntry *e;
if ((e = findEntry(id)))
HttpHeader::getInt64(http_hdr_type id) const
{
assert_eid(id);
- assert(Headers[id].type == ftInt64); /* must be of an appropriate type */
+ assert(Headers[id].type == ftInt64); /* must be of an appropriate type */
HttpHeaderEntry *e;
if ((e = findEntry(id)))
HttpHeaderEntry *e;
time_t value = -1;
assert_eid(id);
- assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
+ assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
if ((e = findEntry(id))) {
value = parse_rfc1123(e->value.termedBuf());
{
HttpHeaderEntry *e;
assert_eid(id);
- assert(Headers[id].type == ftStr); /* must be of an appropriate type */
+ assert(Headers[id].type == ftStr); /* must be of an appropriate type */
if ((e = findEntry(id))) {
- httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
+ httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
return e->value.termedBuf();
}
{
HttpHeaderEntry *e;
assert_eid(id);
- assert(Headers[id].type == ftStr); /* must be of an appropriate type */
+ assert(Headers[id].type == ftStr); /* must be of an appropriate type */
if ((e = findLastEntry(id))) {
- httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
+ httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
return e->value.termedBuf();
}
assert(auth_scheme);
field = getStr(id);
- if (!field) /* no authorization field */
+ if (!field) /* no authorization field */
return NULL;
l = strlen(auth_scheme);
- if (!l || strncasecmp(field, auth_scheme, l)) /* wrong scheme */
+ if (!l || strncasecmp(field, auth_scheme, l)) /* wrong scheme */
return NULL;
field += l;
- if (!xisspace(*field)) /* wrong scheme */
+ if (!xisspace(*field)) /* wrong scheme */
return NULL;
/* skip white space */
for (; field && xisspace(*field); ++field);
- if (!*field) /* no authorization cookie */
+ if (!*field) /* no authorization cookie */
return NULL;
static char decodedAuthToken[8192];
{
ETag etag = {NULL, -1};
HttpHeaderEntry *e;
- assert(Headers[id].type == ftETag); /* must be of an appropriate type */
+ assert(Headers[id].type == ftETag); /* must be of an appropriate type */
if ((e = findEntry(id)))
etagParseInit(&etag, e->value.termedBuf());
{
TimeOrTag tot;
HttpHeaderEntry *e;
- assert(Headers[id].type == ftDate_1123_or_ETag); /* must be of an appropriate type */
+ assert(Headers[id].type == ftDate_1123_or_ETag); /* must be of an appropriate type */
memset(&tot, 0, sizeof(tot));
if ((e = findEntry(id))) {
}
}
- assert(tot.time < 0 || !tot.tag.str); /* paranoid */
+ assert(tot.time < 0 || !tot.tag.str); /* paranoid */
return tot;
}
/* note: name_start == field_start */
const char *name_end = (const char *)memchr(field_start, ':', field_end - field_start);
int name_len = name_end ? name_end - field_start :0;
- const char *value_start = field_start + name_len + 1; /* skip ':' */
+ const char *value_start = field_start + name_len + 1; /* skip ':' */
/* note: value_end == field_end */
++ HeaderEntryParsedCount;
*/
/* tmp variable used to pass stat info to dumpers */
-extern const HttpHeaderStat *dump_stat; /* argh! */
+extern const HttpHeaderStat *dump_stat; /* argh! */
const HttpHeaderStat *dump_stat = NULL;
void
refreshMask();
}
}
+
/** possible types for http header fields */
typedef enum {
- ftInvalid = HDR_ENUM_END, /**< to catch nasty errors with hdr_id<->fld_type clashes */
+ ftInvalid = HDR_ENUM_END, /**< to catch nasty errors with hdr_id<->fld_type clashes */
ftInt,
ftInt64,
ftStr,
inline bool chunked() const; ///< whether message uses chunked Transfer-Encoding
/* protected, do not use these, use interface functions instead */
- std::vector<HttpHeaderEntry *> entries; /**< parsed fields in raw format */
- HttpHeaderMask mask; /**< bit set <=> entry present */
- http_hdr_owner_type owner; /**< request or reply */
- int len; /**< length when packed, not counting terminating null-byte */
+ std::vector<HttpHeaderEntry *> entries; /**< parsed fields in raw format */
+ HttpHeaderMask mask; /**< bit set <=> entry present */
+ http_hdr_owner_type owner; /**< request or reply */
+ int len; /**< length when packed, not counting terminating null-byte */
protected:
/** \deprecated Public access replaced by removeHopByHopEntries() */
void httpHeaderCleanModule(void);
#endif /* SQUID_HTTPHEADER_H */
+
};
#endif /* SQUID_HTTPHEADERFIELDINFO_H_ */
+
};
#endif /* SQUID_HTTPHEADERFIELDSTAT_H_ */
+
void httpHeaderMaskInit(HttpHeaderMask * mask, int value);
#endif /* SQUID_HTTPHEADERMASK_H */
+
void updateSpec();
int64_t debt() const;
void debt(int64_t);
- int64_t debt_size; /* bytes left to send from the current spec */
- String boundary; /* boundary for multipart responses */
+ int64_t debt_size; /* bytes left to send from the current spec */
+ String boundary; /* boundary for multipart responses */
bool valid;
};
#endif /* SQUID_HTTPHEADERRANGE_H */
+
};
#endif /* HTTPHEADERSTAT_H_ */
+
/* sanity checks */
assert(id >= 0 && id < count);
assert(attrs[i].name);
- assert(info->id == HDR_ACCEPT && info->type == ftInvalid); /* was not set before */
+ assert(info->id == HDR_ACCEPT && info->type == ftInvalid); /* was not set before */
/* copy and init fields */
info->id = id;
info->type = attrs[i].type;
size_t i;
const int * enums = (const int *) http_hdr_type_enums;
assert(mask && enums);
- assert(count < sizeof(*mask) * 8); /* check for overflow */
+ assert(count < sizeof(*mask) * 8); /* check for overflow */
for (i = 0; i < count; ++i) {
- assert(!CBIT_TEST(*mask, enums[i])); /* check for duplicates */
+ assert(!CBIT_TEST(*mask, enums[i])); /* check for duplicates */
CBIT_SET(*mask, enums[i]);
}
}
{
errno = 0;
int64_t res = strtoll(start, NULL, 10);
- if (!res && EINVAL == errno) /* maybe not portable? */
+ if (!res && EINVAL == errno) /* maybe not portable? */
return 0;
*value = res;
return 1;
}
}
}
+
void httpHdrMangleList(HttpHeader *, HttpRequest *, int req_or_rep);
#endif
+
#include "SquidConfig.h"
HttpMsg::HttpMsg(http_hdr_owner_type owner):
- http_ver(Http::ProtocolVersion()),
- header(owner),
- cache_control(NULL),
- hdr_sz(0),
- content_length(0),
- pstate(psReadyToParseStartLine)
+ http_ver(Http::ProtocolVersion()),
+ header(owner),
+ cache_control(NULL),
+ hdr_sz(0),
+ content_length(0),
+ pstate(psReadyToParseStartLine)
{}
HttpMsg::~HttpMsg()
* NOT point to a CR or NL character, then return failure
*/
if (**parse_start != '\r' && **parse_start != '\n')
- return 0; /* failure */
+ return 0; /* failure */
/*
* If we didn't find the end of headers, and parse_start does point
packFirstLineInto(&p, true);
packerClean(&p);
}
+
#define HTTPMSGLOCK(a) (a)->lock()
#endif /* SQUID_HTTPMSG_H */
+
}
HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0),
- expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0),
- protoPrefix("HTTP/"), bodySizeMax(-2)
+ expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0),
+ protoPrefix("HTTP/"), bodySizeMax(-2)
{
init();
}
if (expiresTime >= 0)
hdr->putTime(HDR_EXPIRES, expiresTime);
- if (lmt > 0) /* this used to be lmt != 0 @?@ */
+ if (lmt > 0) /* this used to be lmt != 0 @?@ */
hdr->putTime(HDR_LAST_MODIFIED, lmt);
date = squid_curtime;
else if (method.id() == Http::METHOD_HEAD)
return 0;
else if (sline.status() == Http::scOkay)
- (void) 0; /* common case, continue */
+ (void) 0; /* common case, continue */
else if (sline.status() == Http::scNoContent)
return 0;
else if (sline.status() == Http::scNotModified)
return newValue;
}
+
/** \par public, writable, but use httpReply* interfaces when possible */
Http::StatusLine sline;
- HttpBody body; /**< for small constant memory-resident text bodies only */
+ HttpBody body; /**< for small constant memory-resident text bodies only */
String protoPrefix; /**< e.g., "HTTP/" */
};
#endif /* SQUID_HTTPREPLY_H */
+
#endif
HttpRequest::HttpRequest() :
- HttpMsg(hoRequest)
+ HttpMsg(hoRequest)
{
init();
}
HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) :
- HttpMsg(hoRequest)
+ HttpMsg(hoRequest)
{
static unsigned int id = 1;
debugs(93,7, HERE << "constructed, this=" << this << " id=" << ++id);
dnsWait = -1;
errType = ERR_NONE;
errDetail = ERR_DETAIL_NONE;
- peer_login = NULL; // not allocated/deallocated by this class
- peer_domain = NULL; // not allocated/deallocated by this class
+ peer_login = NULL; // not allocated/deallocated by this class
+ peer_domain = NULL; // not allocated/deallocated by this class
peer_host = NULL;
vary_headers = NULL;
myportname = null_string;
case AnyP::PROTO_CACHE_OBJECT:
return false;
- //case AnyP::PROTO_FTP:
+ //case AnyP::PROTO_FTP:
default:
break;
}
return urlCanonical(this);
}
+
err_type errType;
int errDetail; ///< errType-specific detail about the transaction error
- char *peer_login; /* Configured peer login:password */
+ char *peer_login; /* Configured peer login:password */
char *peer_host; /* Selected peer host*/
- time_t lastmod; /* Used on refreshes */
+ time_t lastmod; /* Used on refreshes */
- const char *vary_headers; /* Used when varying entities are detected. Changes how the store key is calculated */
+ const char *vary_headers; /* Used when varying entities are detected. Changes how the store key is calculated */
- char *peer_domain; /* Configured peer forceddomain */
+ char *peer_domain; /* Configured peer forceddomain */
String myportname; // Internal tag name= value from port this requests arrived in.
NotePairs::Pointer notes; ///< annotations added by the note directive and helpers
- String tag; /* Internal tag for this request */
+ String tag; /* Internal tag for this request */
- String extacl_user; /* User name returned by extacl lookup */
+ String extacl_user; /* User name returned by extacl lookup */
- String extacl_passwd; /* Password returned by extacl lookup */
+ String extacl_passwd; /* Password returned by extacl lookup */
- String extacl_log; /* String to be used for access.log purposes */
+ String extacl_log; /* String to be used for access.log purposes */
- String extacl_message; /* String to be used for error page purposes */
+ String extacl_message; /* String to be used for error page purposes */
#if FOLLOW_X_FORWARDED_FOR
String x_forwarded_for_iterator; /* XXX a list of IP addresses */
};
#endif /* SQUID_HTTPREQUEST_H */
+
};
#endif /* SQUID_HTTPSTATEFLAGS_H_ */
+
uint32_t shostid;
/// \todo I don't believe this header is included in non-c++ code anywhere
-/// the struct should become a public POD class and kill these ifdef.
+/// the struct should become a public POD class and kill these ifdef.
#ifdef __cplusplus
_icp_common_t();
const cache_key *icpGetCacheKey(const char *url, int reqnum);
#endif /* SQUID_ICP_H */
+
};
#endif /* SQUID_IOSTATS_H_ */
+
/* ========================================================================= */
LeakFinderPtr::LeakFinderPtr(void *p , const char *f, const int l) :
- file(f),
- line(l),
- when(squid_curtime)
+ file(f),
+ line(l),
+ when(squid_curtime)
{
// XXX: these bits should be done by hash_link()
key = p;
/* ========================================================================= */
LeakFinder::LeakFinder() :
- count(0),
- last_dump(0)
+ count(0),
+ last_dump(0)
{
debugs(45, 3, "LeakFinder constructed");
table = hash_create(cmp, 1 << 8, hash);
}
#endif /* USE_LEAKFINDER */
+
#endif /* USE_LEAKFINDER */
#endif /* SQUID_LEAKFINDER_H */
+
LoadableModule::LoadableModule(const String &aName): theName(aName), theHandle(0)
{
-# if XSTD_USE_LIBLTDL
+# if XSTD_USE_LIBLTDL
// Initialise preloaded symbol lookup table.
LTDL_SET_PRELOADED_SYMBOLS();
if (lt_dlinit() != 0)
throw TexcHere("internal error: cannot initialize libtool module loader");
-# endif
+# endif
}
LoadableModule::~LoadableModule()
{
if (loaded())
unload();
-# if XSTD_USE_LIBLTDL
+# if XSTD_USE_LIBLTDL
assert(lt_dlexit() == 0); // XXX: replace with a warning
-# endif
+# endif
}
bool LoadableModule::loaded() const
void *LoadableModule::openModule(int mode)
{
-# if XSTD_USE_LIBLTDL
+# if XSTD_USE_LIBLTDL
return lt_dlopen(theName.termedBuf());
-# else
+# else
return dlopen(theName.termedBuf(),
mode == lmNow ? RTLD_NOW : RTLD_LAZY);
-# endif
+# endif
}
bool LoadableModule::closeModule()
{
-# if XSTD_USE_LIBLTDL
+# if XSTD_USE_LIBLTDL
// we cast to avoid including ltdl.h in LoadableModule.h
return lt_dlclose(static_cast<lt_dlhandle>(theHandle)) == 0;
-# else
+# else
return dlclose(theHandle) == 0;
-# endif
+# endif
}
const char *LoadableModule::errorMsg()
{
-# if XSTD_USE_LIBLTDL
+# if XSTD_USE_LIBLTDL
return lt_dlerror();
-# else
+# else
return dlerror();
-# endif
+# endif
}
+
LoadModule(i->key);
debugs(1, DBG_IMPORTANT, "Squid plugin modules loaded: " << count);
}
+
void LoadableModulesConfigure(const wordlist *names);
#endif /* SQUID_LOADABLE_MODULES_H */
+
#include "MasterXaction.h"
InstanceIdDefinitions(MasterXaction, "MXID_");
+
};
#endif /* SQUID_SRC_MASTERXACTION_H */
+
MemBlobStats::dump(std::ostream &os) const
{
os <<
- "MemBlob created: " << alloc <<
- "\nMemBlob alive: " << live <<
- "\nMemBlob append calls: " << append <<
- "\nMemBlob currently allocated size: " << liveBytes <<
- "\nlive MemBlob mean current allocation size: " <<
- (static_cast<double>(liveBytes)/(live?live:1)) << std::endl;
+ "MemBlob created: " << alloc <<
+ "\nMemBlob alive: " << live <<
+ "\nMemBlob append calls: " << append <<
+ "\nMemBlob currently allocated size: " << liveBytes <<
+ "\nlive MemBlob mean current allocation size: " <<
+ (static_cast<double>(liveBytes)/(live?live:1)) << std::endl;
return os;
}
/* MemBlob */
MemBlob::MemBlob(const MemBlob::size_type reserveSize) :
- mem(NULL), capacity(0), size(0) // will be set by memAlloc
+ mem(NULL), capacity(0), size(0) // will be set by memAlloc
{
debugs(MEMBLOB_DEBUGSECTION,9, HERE << "constructed, this="
<< static_cast<void*>(this) << " id=" << id
}
MemBlob::MemBlob(const char *buffer, const MemBlob::size_type bufSize) :
- mem(NULL), capacity(0), size(0) // will be set by memAlloc
+ mem(NULL), capacity(0), size(0) // will be set by memAlloc
{
debugs(MEMBLOB_DEBUGSECTION,9, HERE << "constructed, this="
<< static_cast<void*>(this) << " id=" << id
MemBlob::dump(std::ostream &os) const
{
os << "id @" << (void *)this
- << "mem:" << static_cast<void*>(mem)
- << ",capacity:" << capacity
- << ",size:" << size
- << ",refs:" << LockCount() << "; ";
+ << "mem:" << static_cast<void*>(mem)
+ << ",capacity:" << capacity
+ << ",size:" << size
+ << ",refs:" << LockCount() << "; ";
return os;
}
+
};
#endif /* SQUID_MEMBLOB_H_ */
+
// nothing to do
} else {
assert(buf);
- assert(!stolen); /* not frozen */
+ assert(!stolen); /* not frozen */
memFreeBuf(capacity, buf);
buf = NULL;
if (isNull()) {
init();
} else {
- assert(!stolen); /* not frozen */
+ assert(!stolen); /* not frozen */
/* reset */
memset(buf, 0, capacity);
size = 0;
MemBuf::isNull()
{
if (!buf && !max_capacity && !capacity && !size)
- return 1; /* is null (not initialized) */
+ return 1; /* is null (not initialized) */
- assert(buf && max_capacity && capacity); /* paranoid */
+ assert(buf && max_capacity && capacity); /* paranoid */
return 0;
}
int sz = 0;
assert(fmt);
assert(buf);
- assert(!stolen); /* not frozen */
+ assert(!stolen); /* not frozen */
/* assert in Grow should quit first, but we do not want to have a scary infinite loop */
while (capacity <= max_capacity) {
{
FREE *ff;
assert(buf);
- assert(!stolen); /* not frozen */
+ assert(!stolen); /* not frozen */
ff = memFreeBufFunc((size_t) capacity);
- stolen = 1; /* freeze */
+ stolen = 1; /* freeze */
return ff;
}
new_cap = 64 * 1024;
while (new_cap < (size_t) min_cap)
- new_cap += 64 * 1024; /* increase in reasonable steps */
+ new_cap += 64 * 1024; /* increase in reasonable steps */
} else {
new_cap = (size_t) min_cap;
}
if (new_cap > (size_t) max_capacity)
new_cap = (size_t) max_capacity;
- assert(new_cap <= (size_t) max_capacity); /* no overflow */
+ assert(new_cap <= (size_t) max_capacity); /* no overflow */
- assert(new_cap > (size_t) capacity); /* progress */
+ assert(new_cap > (size_t) capacity); /* progress */
buf_cap = (size_t) capacity;
assert(mb);
mb->Printf("memBufReport is not yet implemented @?@\n");
}
+
/**
* Whether the buffer contains any data.
- \retval true if data exists in the buffer
- \retval false if data exists in the buffer
+ \retval true if data exists in the buffer
+ \retval false if data exists in the buffer
*/
bool hasContent() const { return size > 0; }
/**
* Whether the buffer contains any data space available.
- \retval true if data can be added to the buffer
- \retval false if the buffer is full
+ \retval true if data can be added to the buffer
+ \retval false if the buffer is full
*/
bool hasSpace() const { return size+1 < capacity; }
*/
mb_size_t capacity;
- unsigned stolen:1; /* the buffer has been stolen for use by someone else */
+ unsigned stolen:1; /* the buffer has been stolen for use by someone else */
#if 0
- unsigned valid:1; /* to be used for debugging only! */
+ unsigned valid:1; /* to be used for debugging only! */
#endif
};
void packerToMemInit(Packer * p, MemBuf * mb);
#endif /* SQUID_MEMBUF_H */
+
new_mem_lo = on_disk - 1;
if (new_mem_lo == -1)
- new_mem_lo = 0; /* the above might become -1 */
+ new_mem_lo = 0; /* the above might become -1 */
data_hdr.freeDataUpto(new_mem_lo);
{
return endOffset() - swapout.queue_offset;
}
+
extern RemovalPolicy *mem_policy;
#endif /* SQUID_MEMOBJECT_H */
+
sfileno index;
const Ipc::StoreMapAnchor *const slot = map->openForReading(
- reinterpret_cast<cache_key*>(collapsed.key), index);
+ reinterpret_cast<cache_key*>(collapsed.key), index);
if (!slot)
return false;
delete mapOwner;
delete spaceOwner;
}
+
// would hurt because we can support synchronous get/put, unlike the disks.
#endif /* SQUID_MEMSTORE_H */
+
};
#endif /* SQUID_SRC_MESSAGESIZES_H */
+
};
#endif /* SQUID_NEIGHBORTYPEDOMAINLIST_H_ */
+
request.notes = new NotePairs;
request.notes->replaceOrAdd(&helperNotes);
}
+
*/
bool empty() const {return entries.empty();}
- std::vector<NotePairs::Entry *> entries; ///< The key/value pair entries
+ std::vector<NotePairs::Entry *> entries; ///< The key/value pair entries
private:
NotePairs &operator = (NotePairs const &); // Not implemented
*/
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const ¬es);
#endif
+
}
#endif /* USE_DELAY_POOLS */
+
};
#endif
#endif /* NULLDELAYID_H */
+
};
#endif /* _SQUID_SRC_OUTOFBOUNDSEXCEPTION_H */
+
p->packer_vprintf(p->real_handler, fmt, args);
va_end(args);
}
+
/* protected, use interface functions instead */
append_f append;
vprintf_f packer_vprintf;
- void *real_handler; /* first parameter to real append and vprintf */
+ void *real_handler; /* first parameter to real append and vprintf */
};
void packerClean(Packer * p);
void packerPrintf(Packer * p, const char *fmt,...) PRINTF_FORMAT_ARG2;
#endif /* SQUID_PACKER_H */
+
bool GetHostWithPort(char *token, Ip::Address *ipa);
#endif /* SQUID_PARSING_H */
+
class Version
{
public:
- short int current; /* current version */
- short int required; /* minimal version that can safely handle current version */
+ short int current; /* current version */
+ short int required; /* minimal version that can safely handle current version */
};
/* digest control block; used for transmission and storage */
struct {
/* all times are absolute unless augmented with _delay */
- time_t initialized; /* creation */
- time_t needed; /* first lookup/use by a peer */
- time_t next_check; /* next scheduled check/refresh event */
- time_t retry_delay; /* delay before re-checking _invalid_ digest */
- time_t requested; /* requested a fresh copy of a digest */
- time_t req_delay; /* last request response time */
- time_t received; /* received the current copy of a digest */
- time_t disabled; /* disabled for good */
+ time_t initialized; /* creation */
+ time_t needed; /* first lookup/use by a peer */
+ time_t next_check; /* next scheduled check/refresh event */
+ time_t retry_delay; /* delay before re-checking _invalid_ digest */
+ time_t requested; /* requested a fresh copy of a digest */
+ time_t req_delay; /* last request response time */
+ time_t received; /* received the current copy of a digest */
+ time_t disabled; /* disabled for good */
} times;
struct {
#endif /* USE_CACHE_DIGESTS */
#endif /* SQUID_PEERDIGEST_H */
+
#if USE_OPENSSL
/// Gives Ssl::PeerConnector access to Answer in the PeerPoolMgr callback dialer.
class MyAnswerDialer: public UnaryMemFunT<PeerPoolMgr, Ssl::PeerConnectorAnswer, Ssl::PeerConnectorAnswer&>,
- public Ssl::PeerConnector::CbDialer
+ public Ssl::PeerConnector::CbDialer
{
public:
MyAnswerDialer(const JobPointer &aJob, Method aMethod):
- UnaryMemFunT<PeerPoolMgr, Ssl::PeerConnectorAnswer, Ssl::PeerConnectorAnswer&>(aJob, aMethod, Ssl::PeerConnectorAnswer()) {}
+ UnaryMemFunT<PeerPoolMgr, Ssl::PeerConnectorAnswer, Ssl::PeerConnectorAnswer&>(aJob, aMethod, Ssl::PeerConnectorAnswer()) {}
/* Ssl::PeerConnector::CbDialer API */
virtual Ssl::PeerConnectorAnswer &answer() { return arg1; }
#endif
PeerPoolMgr::PeerPoolMgr(CachePeer *aPeer): AsyncJob("PeerPoolMgr"),
- peer(cbdataReference(aPeer)),
- request(),
- opener(),
- securer(),
- closer(),
- addrUsed(0)
+ peer(cbdataReference(aPeer)),
+ request(),
+ opener(),
+ securer(),
+ closer(),
+ addrUsed(0)
{
}
}
}
}
+
};
#endif /* SQUID_PEERPOOLMGR_H */
+
};
#endif /* SQUID_PEERSELECTSTATE_H */
+
int n_sent;
int n_recv;
int n_replies_expected;
- int timeout; /* msec */
+ int timeout; /* msec */
int timedout;
int w_rtt;
int p_rtt;
};
#endif /* SQUID_PINGDATA_H */
+
for (i = 0; i < XPROF_LAST; ++i) {
hist[i]->name = head[i]->name;
hist[i]->accu.summ += head[i]->accu.summ;
- hist[i]->accu.count += head[i]->accu.count; /* accumulate multisec */
+ hist[i]->accu.count += head[i]->accu.count; /* accumulate multisec */
if (!hist[i]->accu.best)
hist[i]->accu.best = head[i]->accu.best;
}
#endif /* USE_XPROF_STATS */
+
};
#endif /* SQUID_REFRESHPATTERN_H_ */
+
};
#endif /* SQUID_REGEXLIST_H_ */
+
CBDATA_CLASS_INIT(RemovalPolicy);
CBDATA_CLASS_INIT(RemovalPolicyWalker);
CBDATA_CLASS_INIT(RemovalPurgeWalker);
+
typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
#endif /* SQUID_REMOVALPOLICY_H */
+
// are flags that are different, they should be cleared in the clone.
return *this;
}
+
};
#endif /* SQUID_REQUESTFLAGS_H_ */
+
const SBuf::size_type SBuf::maxSize;
SBufStats::SBufStats()
- : alloc(0), allocCopy(0), allocFromString(0), allocFromCString(0),
- assignFast(0), clear(0), append(0), toStream(0), setChar(0),
- getChar(0), compareSlow(0), compareFast(0), copyOut(0),
- rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), scanf(0),
- caseChange(0), cowFast(0), cowSlow(0), live(0)
+ : alloc(0), allocCopy(0), allocFromString(0), allocFromCString(0),
+ assignFast(0), clear(0), append(0), toStream(0), setChar(0),
+ getChar(0), compareSlow(0), compareFast(0), copyOut(0),
+ rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), scanf(0),
+ caseChange(0), cowFast(0), cowSlow(0), live(0)
{}
SBufStats&
}
SBuf::SBuf()
- : store_(GetStorePrototype()), off_(0), len_(0)
+ : store_(GetStorePrototype()), off_(0), len_(0)
{
debugs(24, 8, id << " created");
++stats.alloc;
}
SBuf::SBuf(const SBuf &S)
- : store_(S.store_), off_(S.off_), len_(S.len_)
+ : store_(S.store_), off_(S.off_), len_(S.len_)
{
debugs(24, 8, id << " created from id " << S.id);
++stats.alloc;
}
SBuf::SBuf(const String &S)
- : store_(GetStorePrototype()), off_(0), len_(0)
+ : store_(GetStorePrototype()), off_(0), len_(0)
{
debugs(24, 8, id << " created from string");
assign(S.rawBuf(), S.size());
}
SBuf::SBuf(const std::string &s)
- : store_(GetStorePrototype()), off_(0), len_(0)
+ : store_(GetStorePrototype()), off_(0), len_(0)
{
debugs(24, 8, id << " created from std::string");
lowAppend(s.data(),s.length());
}
SBuf::SBuf(const char *S, size_type n)
- : store_(GetStorePrototype()), off_(0), len_(0)
+ : store_(GetStorePrototype()), off_(0), len_(0)
{
append(S,n);
++stats.alloc;
SBuf::dump(std::ostream &os) const
{
os << id
- << ": ";
+ << ": ";
store_->dump(os);
os << ", offset:" << off_
- << ", len:" << len_
- << ") : '";
+ << ", len:" << len_
+ << ") : '";
print(os);
os << '\'' << std::endl;
return os;
# if 0
// alternate implementation, based on Raw() API.
os << Raw("SBuf", buf(), length()) <<
- ". id: " << id <<
- ", offset:" << off_ <<
- ", len:" << len_ <<
- ", store: ";
+ ". id: " << id <<
+ ", offset:" << off_ <<
+ ", len:" << len_ <<
+ ", store: ";
store_->dump(os);
os << std::endl;
return os;
{
MemBlobStats ststats = MemBlob::GetStats();
os <<
- "SBuf stats:\nnumber of allocations: " << alloc <<
- "\ncopy-allocations: " << allocCopy <<
- "\ncopy-allocations from SquidString: " << allocFromString <<
- "\ncopy-allocations from C String: " << allocFromCString <<
- "\nlive references: " << live <<
- "\nno-copy assignments: " << assignFast <<
- "\nclearing operations: " << clear <<
- "\nappend operations: " << append <<
- "\ndump-to-ostream: " << toStream <<
- "\nset-char: " << setChar <<
- "\nget-char: " << getChar <<
- "\ncomparisons with data-scan: " << compareSlow <<
- "\ncomparisons not requiring data-scan: " << compareFast <<
- "\ncopy-out ops: " << copyOut <<
- "\nraw access to memory: " << rawAccess <<
- "\nNULL terminate C string: " << nulTerminate <<
- "\nchop operations: " << chop <<
- "\ntrim operations: " << trim <<
- "\nfind: " << find <<
- "\nscanf: " << scanf <<
- "\ncase-change ops: " << caseChange <<
- "\nCOW not actually requiring a copy: " << cowFast <<
- "\nCOW: " << cowSlow <<
- "\naverage store share factor: " <<
- (ststats.live != 0 ? static_cast<float>(live)/ststats.live : 0) <<
- std::endl;
+ "SBuf stats:\nnumber of allocations: " << alloc <<
+ "\ncopy-allocations: " << allocCopy <<
+ "\ncopy-allocations from SquidString: " << allocFromString <<
+ "\ncopy-allocations from C String: " << allocFromCString <<
+ "\nlive references: " << live <<
+ "\nno-copy assignments: " << assignFast <<
+ "\nclearing operations: " << clear <<
+ "\nappend operations: " << append <<
+ "\ndump-to-ostream: " << toStream <<
+ "\nset-char: " << setChar <<
+ "\nget-char: " << getChar <<
+ "\ncomparisons with data-scan: " << compareSlow <<
+ "\ncomparisons not requiring data-scan: " << compareFast <<
+ "\ncopy-out ops: " << copyOut <<
+ "\nraw access to memory: " << rawAccess <<
+ "\nNULL terminate C string: " << nulTerminate <<
+ "\nchop operations: " << chop <<
+ "\ntrim operations: " << trim <<
+ "\nfind: " << find <<
+ "\nscanf: " << scanf <<
+ "\ncase-change ops: " << caseChange <<
+ "\nCOW not actually requiring a copy: " << cowFast <<
+ "\nCOW: " << cowSlow <<
+ "\naverage store share factor: " <<
+ (ststats.live != 0 ? static_cast<float>(live)/ststats.live : 0) <<
+ std::endl;
return os;
}
}
reAlloc(newsize);
}
+
}
#endif /* SQUID_SBUF_H */
+
{
public:
explicit SBufEqual(const SBuf &reference, SBufCaseSensitive sensitivity = caseSensitive) :
- reference_(reference), sensitivity_(sensitivity) {}
+ reference_(reference), sensitivity_(sensitivity) {}
bool operator() (const SBuf & checking) { return checking.compare(reference_,sensitivity_) == 0; }
private:
SBuf reference_;
{
public:
explicit SBufStartsWith(const SBuf &prefix, SBufCaseSensitive sensitivity = caseSensitive) :
- prefix_(prefix), sensitivity_(sensitivity) {}
+ prefix_(prefix), sensitivity_(sensitivity) {}
bool operator() (const SBuf & checking) { return checking.startsWith(prefix_,sensitivity_); }
private:
SBuf prefix_;
{
public:
explicit SBufAddLength(const SBuf &separator) :
- separatorLen_(separator.length()) {}
+ separatorLen_(separator.length()) {}
SBuf::size_type operator()(const SBuf::size_type sz, const SBuf & item) {
return sz + item.length() + separatorLen_;
}
}
#endif /* SQUID_SBUFALGOS_H_ */
+
{
return &memblobDestructTimeStats;
}
+
const StatHist * collectMemBlobDestructTimeStats();
#endif /* SQUID_SBUFDETAILEDSTATS_H */
+
OutOfBoundsException::OutOfBoundsException(const SBuf &throwingBuf,
SBuf::size_type &pos,
const char *aFileName, int aLineNo)
- : TextException(NULL, aFileName, aLineNo),
- theThrowingBuf(throwingBuf),
- accessedPosition(pos)
+ : TextException(NULL, aFileName, aLineNo),
+ theThrowingBuf(throwingBuf),
+ accessedPosition(pos)
{
SBuf explanatoryText("OutOfBoundsException");
if (aLineNo != -1)
{ }
InvalidParamException::InvalidParamException(const char *aFilename, int aLineNo)
- : TextException("Invalid parameter", aFilename, aLineNo)
+ : TextException("Invalid parameter", aFilename, aLineNo)
{ }
SBufTooBigException::SBufTooBigException(const char *aFilename, int aLineNo)
- : TextException("Trying to create an oversize SBuf", aFilename, aLineNo)
+ : TextException("Trying to create an oversize SBuf", aFilename, aLineNo)
{ }
+
};
#endif /* SQUID_SBUFEXCEPTIONS_H */
+
{
return std::find_if(sl.begin(), sl.end(), SBufEqual(S,case_sensitive)) != sl.end();
}
+
bool IsMember(const SBufList &, const SBuf &, const SBufCaseSensitive isCaseSensitive = caseSensitive);
#endif /* SQUID_SBUFLIST_H */
+
#include "StoreEntryStream.h"
SBufStatsAction::SBufStatsAction(const Mgr::CommandPointer &cmd_):
- Action(cmd_)
+ Action(cmd_)
{ } //default constructor is OK for data member
SBufStatsAction::Pointer
{
StoreEntryStream ses(entry);
ses << "\n\n\nThese statistics are experimental; their format and contents "
- "should not be relied upon, they are bound to change as "
- "the SBuf feature is evolved\n";
+ "should not be relied upon, they are bound to change as "
+ "the SBuf feature is evolved\n";
sbdata.dump(ses);
mbdata.dump(ses);
ses << "\n";
static const bool Registered = (Mgr::RegisterAction("sbuf",
"String-Buffer statistics", &SBufStatsAction::Create, 0 , 1),
true);
+
};
#endif /* SQUID_SBUFSTATSACTION_H */
+
};
#endif /* SQUID_SBUFSTREAM_H */
+
#endif /* SQUID_SNMP */
#endif /* SQUID_SNMPREQUEST_H_ */
+
extern SquidConfig2 Config2;
#endif /* SQUID_SQUIDCONFIG_H_ */
+
void idnsPTRLookup(const Ip::Address &, IDNSCB *, void *);
#endif /* SQUID_DNS_H */
+
void **hIpc);
#endif /* SQUID_SQUIDIPC_H_ */
+
void *linklistShift(link_list **);
#endif /* SQUID_SQUIDLIST_H_ */
+
return (cur * (n - 1) + newI) / n;
}
+
} // namespace Math
#endif /* _SQUID_SRC_SQUIDMATH_H */
+
}
#endif /* __SUNPRO_CC */
+
/**
* Retrieve a single character in the string.
- \param pos Position of character to retrieve.
+ \param pos Position of character to retrieve.
*/
_SQUID_INLINE_ char operator [](unsigned int pos) const;
char *strwordtok(char *buf, char **t);
#endif /* SQUID_STRING_H */
+
} // namespace Time
#endif /* SQUID_TIME_H */
+
#include "StatCounters.h"
StatCounters statCounter;
+
extern StatCounters statCounter;
#endif /* STATCOUNTERS_H_ */
+
}
StatHist::StatHist(const StatHist &src) :
- capacity_(src.capacity_), min_(src.min_), max_(src.max_),
- scale_(src.scale_), val_in(src.val_in), val_out(src.val_out)
+ capacity_(src.capacity_), min_(src.min_), max_(src.max_),
+ scale_(src.scale_), val_in(src.val_in), val_out(src.val_out)
{
if (src.bins!=NULL) {
bins = static_cast<bins_type *>(xcalloc(src.capacity_, sizeof(bins_type)));
StatHist::findBin(double v)
{
- v -= min_; /* offset */
+ v -= min_; /* offset */
- if (v <= 0.0) /* too small */
+ if (v <= 0.0) /* too small */
return 0;
unsigned int bin;
return 0;
bin = static_cast <unsigned int>(tmp_bin);
- if (bin >= capacity_) /* too big */
+ if (bin >= capacity_) /* too big */
bin = capacity_ - 1;
return bin;
if (count)
storeAppendPrintf(sentry, "%9d\t%9d\n", (int) val, count);
}
+
inline
StatHist::StatHist() :
- bins(NULL), capacity_(0), min_(0), max_(0),
- scale_(1.0), val_in(NULL), val_out(NULL)
+ bins(NULL), capacity_(0), min_(0), max_(0),
+ scale_(1.0), val_in(NULL), val_out(NULL)
{}
inline void
}
#endif /* STATHIST_H_ */
+
void expireNow();
void releaseRequest();
void negativeCache();
- void cacheNegatively(); /** \todo argh, why both? */
+ void cacheNegatively(); /** \todo argh, why both? */
void invokeHandlers();
void purgeMem();
void cacheInMemory(); ///< start or continue storing in memory cache
static MemAllocator *pool;
- unsigned short lock_count; /* Assume < 65536! */
+ unsigned short lock_count; /* Assume < 65536! */
#if USE_ADAPTATION
/// producer callback registered with deferProducer
virtual StoreSearch *search(String const url, HttpRequest *) = 0;
/* pulled up from SwapDir for migration.... probably do not belong here */
- virtual void reference(StoreEntry &) = 0; /* Reference this object */
+ virtual void reference(StoreEntry &) = 0; /* Reference this object */
/// Undo reference(), returning false iff idle e should be destroyed
virtual bool dereference(StoreEntry &e, bool wantsLocalMemory) = 0;
void storeGetMemSpace(int size);
#endif /* SQUID_STORE_H */
+
#include "StoreIOBuffer.h"
#include "StoreIOState.h"
-typedef void STCB(void *, StoreIOBuffer); /* store callback */
+typedef void STCB(void *, StoreIOBuffer); /* store callback */
class StoreEntry;
void *owner;
#endif
- StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
+ StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */
StoreIOState::Pointer swapin_sio;
struct {
int storeClientIsThisAClient(store_client * sc, void *someClient);
#endif /* SQUID_STORECLIENT_H */
+
};
#endif /* SQUID_STORE_ENTRY_STREAM_H */
+
void
StoreFileSystem::registerWithCacheManager(void)
{}
+
/* ****** DOCUMENTATION ***** */
/**
- \defgroup FileSystems Storage Filesystems
+ \defgroup FileSystems Storage Filesystems
*
\section Introduction Introduction
\par
typedef StoreFileSystem storefs_entry_t;
#endif /* SQUID_STOREFILESYSTEM_H */
+
};
class StoreHashIndexEntry : public StoreEntry
- {};
+{};
class StoreSearchHashIndex : public StoreSearch
{
};
#endif /* SQUID_STOREHASHINDEX_H */
+
StoreIOBuffer():length(0), offset (0), data (NULL) {flags.error = 0;}
StoreIOBuffer(size_t aLength, int64_t anOffset, char *someData) :
- length (aLength), offset (anOffset), data (someData) {
+ length (aLength), offset (anOffset), data (someData) {
flags.error = 0;
}
/* Create a StoreIOBuffer from a MemBuf and offset */
/* NOTE that MemBuf still "owns" the pointers, StoreIOBuffer is just borrowing them */
StoreIOBuffer(MemBuf *aMemBuf, int64_t anOffset) :
- length(aMemBuf->contentSize()),
- offset (anOffset),
- data(aMemBuf->content()) {
+ length(aMemBuf->contentSize()),
+ offset (anOffset),
+ data(aMemBuf->content()) {
flags.error = 0;
}
StoreIOBuffer(MemBuf *aMemBuf, int64_t anOffset, size_t anLength) :
- length(anLength),
- offset (anOffset),
- data(aMemBuf->content()) {
+ length(anLength),
+ offset (anOffset),
+ data(aMemBuf->content()) {
flags.error = 0;
}
}
#endif /* SQUID_STOREIOBUFFER_H */
+
StoreIOState::operator delete (void *address) {assert (0);}
StoreIOState::StoreIOState() :
- swap_dirn(-1), swap_filen(-1), e(NULL), mode(O_BINARY),
- offset_(0), file_callback(NULL), callback(NULL), callback_data(NULL)
+ swap_dirn(-1), swap_filen(-1), e(NULL), mode(O_BINARY),
+ offset_(0), file_callback(NULL), callback(NULL), callback_data(NULL)
{
read.callback = NULL;
read.callback_data = NULL;
if (callback_data)
cbdataReferenceDone(callback_data);
}
+
sdirno swap_dirn;
sfileno swap_filen;
- StoreEntry *e; /* Need this so the FS layers can play god */
+ StoreEntry *e; /* Need this so the FS layers can play god */
mode_t mode;
off_t offset_; ///< number of bytes written or read for this entry so far
- STFNCB *file_callback; /* called on delayed sfileno assignments */
+ STFNCB *file_callback; /* called on delayed sfileno assignments */
STIOCB *callback;
void *callback_data;
} read;
struct {
- bool closing; /* debugging aid */
+ bool closing; /* debugging aid */
} flags;
};
void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
#endif /* SQUID_STOREIOSTATE_H */
+
{
assert (*tail == NULL);
*tail = aNode;
- return &aNode->next; /* return new tail pointer */
+ return &aNode->next; /* return new tail pointer */
}
bool
return true;
}
+
STORE_META_OBJSIZE,
- STORE_META_STOREURL, /* the store url, if different to the normal URL */
- STORE_META_VARY_ID, /* Unique ID linking variants */
+ STORE_META_STOREURL, /* the store url, if different to the normal URL */
+ STORE_META_VARY_ID, /* Unique ID linking variants */
STORE_META_END
};
void storeSwapTLVFree(tlv * n);
#endif /* SQUID_TYPELENGTHVALUE_H */
+
};
#endif /* SQUID_STOREMETAMD5_H */
+
};
#endif /* SQUID_STOREMETAOBJSIZE_H */
+
{
return len == STORE_HDR_METASIZE_OLD;
}
+
};
#endif /* SQUID_STOREMETASTD_H */
+
{
return len == STORE_HDR_METASIZE;
}
+
};
#endif /* SQUID_STOREMETASTDLFS_H */
+
};
#endif /* SQUID_STOREMETAURL_H */
+
}
StoreMetaUnpacker::StoreMetaUnpacker(char const *aBuffer, ssize_t aLen, int *anInt) :
- buf(aBuffer),
- buflen(aLen),
- hdr_len(anInt),
- position(1 + sizeof(int)),
- type('\0'),
- length(0),
- tail(NULL)
+ buf(aBuffer),
+ buflen(aLen),
+ hdr_len(anInt),
+ position(1 + sizeof(int)),
+ type('\0'),
+ length(0),
+ tail(NULL)
{
assert(aBuffer != NULL);
}
return TLV;
}
+
StoreMeta ** storeSwapTLVAdd(int type, const void *ptr, size_t len, StoreMeta ** tail);
#endif /* SQUID_TYPELENGTHVALUEUNPACKER_H */
+
};
#endif /* SQUID_STOREMETAVARY_H */
+
typedef RefCount<StoreSearch> StoreSearchPointer;
#endif /* SQUID_STORESEARCH_H */
+
};
#endif /* SQUID_STORE_STATS_H */
+
}
StoreSwapLogHeader::StoreSwapLogHeader(): op(SWAP_LOG_VERSION), version(2),
- record_size(sizeof(StoreSwapLogData))
+ record_size(sizeof(StoreSwapLogData))
{
checksum.set(version, record_size, 0);
}
assert(static_cast<size_t>(record_size) > sizeof(*this));
return static_cast<size_t>(record_size) - sizeof(*this);
}
+
};
#endif /* SQUID_STORESWAPLOGDATA_H */
+
int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos);
#endif /* SQUID_STRLIST_H_ */
+
#if !_USE_INLINE_
#include "String.cci"
#endif
+
{
return a.cmp(b) < 0;
}
+
#include "tools.h"
SwapDir::SwapDir(char const *aType): theType(aType),
- max_size(0), min_objsize(0), max_objsize (-1),
- path(NULL), index(-1), disker(-1),
- repl(NULL), removals(0), scanned(0),
- cleanLog(NULL)
+ max_size(0), min_objsize(0), max_objsize (-1),
+ path(NULL), index(-1), disker(-1),
+ repl(NULL), removals(0), scanned(0),
+ cleanLog(NULL)
{
fs.blksize = 1024;
}
value = strchr(name, '=');
if (value) {
- *value = '\0'; /* cut on = */
+ *value = '\0'; /* cut on = */
++value;
}
{
fatal("not implemented");
}
+
virtual void getStats(StoreInfoStats &stats) const;
virtual void stat(StoreEntry &) const;
- virtual void sync(); /* Sync the store prior to shutdown */
+ virtual void sync(); /* Sync the store prior to shutdown */
virtual StoreSearch *search(String const url, HttpRequest *);
- virtual void reference(StoreEntry &); /* Reference this object */
+ virtual void reference(StoreEntry &); /* Reference this object */
- virtual bool dereference(StoreEntry &, bool); /* Unreference this object */
+ virtual bool dereference(StoreEntry &, bool); /* Unreference this object */
/* the number of store dirs being rebuilt. */
static int store_dirs_rebuilding;
public:
char *path;
- int index; /* This entry's index into the swapDirs array */
+ int index; /* This entry's index into the swapDirs array */
int disker; ///< disker kid id dedicated to this SwapDir or -1
RemovalPolicy *repl;
int removals;
bool selected;
bool read_only;
} flags;
- virtual void init() = 0; /* Initialise the fs */
- virtual void create(); /* Create a new fs */
- virtual void dump(StoreEntry &)const; /* Dump fs config snippet */
- virtual bool doubleCheck(StoreEntry &); /* Double check the obj integrity */
- virtual void statfs(StoreEntry &) const; /* Dump fs statistics */
- virtual void maintain(); /* Replacement maintainence */
+ virtual void init() = 0; /* Initialise the fs */
+ virtual void create(); /* Create a new fs */
+ virtual void dump(StoreEntry &)const; /* Dump fs config snippet */
+ virtual bool doubleCheck(StoreEntry &); /* Double check the obj integrity */
+ virtual void statfs(StoreEntry &) const; /* Dump fs statistics */
+ virtual void maintain(); /* Replacement maintainence */
/// check whether we can store the entry; if we can, report current load
virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const = 0;
/* These two are notifications */
- virtual void reference(StoreEntry &); /* Reference this object */
- virtual bool dereference(StoreEntry &, bool); /* Unreference this object */
- virtual int callback(); /* Handle pending callbacks */
- virtual void sync(); /* Sync the store prior to shutdown */
+ virtual void reference(StoreEntry &); /* Reference this object */
+ virtual bool dereference(StoreEntry &, bool); /* Unreference this object */
+ virtual int callback(); /* Handle pending callbacks */
+ virtual void sync(); /* Sync the store prior to shutdown */
virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *) = 0;
virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *) = 0;
virtual void unlink (StoreEntry &);
};
#endif /* SQUID_SWAPDIR_H */
+
};
#endif /* _SQUID_TIMEORTAG_H */
+
delete extrasOwner;
delete mapOwner;
}
+
// TODO: Why use Store as a base? We are not really a cache.
#endif /* SQUID_TRANSIENTS_H */
+
void urlExtMethodConfigure(void);
#endif /* SQUID_SRC_URL_H_H */
+
static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { INFINITE, NULL, NULL, 1, Squid_SCAction };
static char REGKEY[256] = SOFTWARE "\\" VENDOR "\\" SOFTWARENAME "\\";
static char *keys[] = {
- SOFTWAREString, /* key[0] */
- VENDORString, /* key[1] */
+ SOFTWAREString, /* key[0] */
+ VENDORString, /* key[1] */
SOFTWARENAMEString, /* key[2] */
- NULL, /* key[3] */
- NULL /* key[4] */
+ NULL, /* key[3] */
+ NULL /* key[4] */
};
static int Squid_Aborting = 0;
while (keys[index]) {
unsigned long result;
- rv = RegCreateKeyEx(hKey, keys[index], /* subkey */
- 0, /* reserved */
- NULL, /* class */
+ rv = RegCreateKeyEx(hKey, keys[index], /* subkey */
+ 0, /* reserved */
+ NULL, /* class */
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKeyNext, &result);
if (rv != ERROR_SUCCESS) {
}
/* Now set the value and data */
- rv = RegSetValueEx(hKey, key, /* value key name */
- 0, /* reserved */
- type, /* type */
- value, /* value data */
- (DWORD) value_size); /* for size of "value" */
+ rv = RegSetValueEx(hKey, key, /* value key name */
+ 0, /* reserved */
+ type, /* type */
+ value, /* value data */
+ (DWORD) value_size); /* for size of "value" */
- retval = 0; /* Return value */
+ retval = 0; /* Return value */
if (rv != ERROR_SUCCESS) {
fprintf(stderr, "RegQueryValueEx(key %s),%d\n", key, (int) rv);
word = cmd;
while (*cmd) {
- ++cmd; /* Skip over this character */
+ ++cmd; /* Skip over this character */
- if (xisspace(*cmd)) /* End of argument if space */
+ if (xisspace(*cmd)) /* End of argument if space */
break;
}
if (*cmd)
- *cmd++ = '\0'; /* Terminate `word' */
+ *cmd++ = '\0'; /* Terminate `word' */
/* See if we need to allocate more space for argv */
if (WIN32_argc >= argvlen) {
keys[4] = const_cast<char*>(service);
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
- SC_MANAGER_ALL_ACCESS /* access required */
+ schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
+ NULL, /* database (NULL == default) */
+ SC_MANAGER_ALL_ACCESS /* access required */
);
if (!schSCManager)
}
snprintf(szPath, sizeof(szPath), "%s %s:" SQUIDSBUFPH, ServicePath, _WIN_SQUID_SERVICE_OPTION, SQUIDSBUFPRINT(service_name));
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
- SC_MANAGER_ALL_ACCESS /* access required */
+ schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
+ NULL, /* database (NULL == default) */
+ SC_MANAGER_ALL_ACCESS /* access required */
);
if (!schSCManager) {
exit(1);
} else {
schService = CreateService(schSCManager, /* SCManager database */
- service, /* name of service */
- service, /* name to display */
- SERVICE_ALL_ACCESS, /* desired access */
- SERVICE_WIN32_OWN_PROCESS, /* service type */
- SERVICE_AUTO_START, /* start type */
- SERVICE_ERROR_NORMAL, /* error control type */
- (const char *) szPath, /* service's binary */
- NULL, /* no load ordering group */
- NULL, /* no tag identifier */
- "Tcpip\0AFD\0", /* dependencies */
- NULL, /* LocalSystem account */
- NULL); /* no password */
+ service, /* name of service */
+ service, /* name to display */
+ SERVICE_ALL_ACCESS, /* desired access */
+ SERVICE_WIN32_OWN_PROCESS, /* service type */
+ SERVICE_AUTO_START, /* start type */
+ SERVICE_ERROR_NORMAL, /* error control type */
+ (const char *) szPath, /* service's binary */
+ NULL, /* no load ordering group */
+ NULL, /* no tag identifier */
+ "Tcpip\0AFD\0", /* dependencies */
+ NULL, /* LocalSystem account */
+ NULL); /* no password */
if (schService) {
if (WIN32_OS_version > _WIN_OS_WINNT) {
if (service_name.isEmpty())
service_name = SBuf(APP_SHORTNAME);
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
- SC_MANAGER_ALL_ACCESS /* access required */
+ schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
+ NULL, /* database (NULL == default) */
+ SC_MANAGER_ALL_ACCESS /* access required */
);
if (!schSCManager) {
/* The required service object access depends on the control. */
switch (WIN32_signal) {
- case 0: /* SIGNULL */
+ case 0: /* SIGNULL */
fdwAccess = SERVICE_INTERROGATE;
fdwControl = _WIN_SQUID_SERVICE_CONTROL_INTERROGATE;
break;
}
/* Open a handle to the service. */
- schService = OpenService(schSCManager, /* SCManager database */
- service_name.c_str(), /* name of service */
- fdwAccess); /* specify access */
+ schService = OpenService(schSCManager, /* SCManager database */
+ service_name.c_str(), /* name of service */
+ fdwAccess); /* specify access */
if (schService == NULL) {
fprintf(stderr, "%s: ERROR: Could not open Service " SQUIDSBUFPH "\n", APP_SHORTNAME, SQUIDSBUFPRINT(service_name));
} else {
/* Send a control value to the service. */
- if (!ControlService(schService, /* handle of service */
- fdwControl, /* control value to send */
- &ssStatus)) { /* address of status info */
+ if (!ControlService(schService, /* handle of service */
+ fdwControl, /* control value to send */
+ &ssStatus)) { /* address of status info */
fprintf(stderr, "%s: ERROR: Could not Control Service " SQUIDSBUFPH "\n",
APP_SHORTNAME, SQUIDSBUFPRINT(service_name));
exit(1);
{
return;
}
+
#endif /* _SQUID_WINDOWS_ */
#endif /* WINSVC_H_ */
+
{
option = beSet ? +1 : -1;
}
+
};
#endif /* SQUID_YESNONONE_H_ */
+
}
ACL::ACL() :
- cfgline(NULL),
- next(NULL),
- registered(false)
+ cfgline(NULL),
+ next(NULL),
+ registered(false)
{
*name = 0;
}
* Here we set AclMatchedName in case we need to use it in a
* warning message in aclDomainCompare().
*/
- AclMatchedName = A->name; /* ugly */
+ AclMatchedName = A->name; /* ugly */
A->flags.parseFlags();
/*
* Clear AclMatchedName from our temporary hack
*/
- AclMatchedName = NULL; /* ugly */
+ AclMatchedName = NULL; /* ugly */
if (!new_acl)
return;
/* This is a fatal to ensure that cacheMatchAcl calls are _only_
* made for supported acl types */
fatal("aclCacheMatchAcl: unknown or unexpected ACL type");
- return 0; /* NOTREACHED */
+ return 0; /* NOTREACHED */
}
/*
a = a->next;
}
}
+
/// \ingroup ACLAPI
/// XXX: find a way to remove or at least use a refcounted ACL pointer
-extern const char *AclMatchedName; /* NULL */
+extern const char *AclMatchedName; /* NULL */
#endif /* SQUID_ACL_H */
+
#include "AclAddress.h"
//TODO: fill in
+
};
#endif /* ACLADDRESS_H_ */
+
};
#endif /* SQUID_ACLDENYINFOLIST_H_ */
+
// TODO: convert to a std::list<string>
#endif /* SQUID_ACLNAMELIST_H_ */
+
};
#endif /* SQUID_ACLSIZELIMIT_H_ */
+
}
ACLAdaptationServiceStrategy ACLAdaptationServiceStrategy::Instance_;
+
};
#endif /* SQUID_ACLADAPTATIONSERVICE_H */
+
};
#endif /* SQUID_ADAPTATIONSERVICEDATA_H */
+
} // namespace Acl
#endif /* SQUID_ACL_ALL_OF_H */
+
} // namespace Acl
#endif /* SQUID_ACL_ANY_OF_H */
+
/* ==== END ARP ACL SUPPORT =============================================== */
#endif /* USE_SQUID_EUI */
+
};
#endif /* SQUID_ACLARP_H */
+
#include "StoreClient.h"
#define WHOIS_PORT 43
-#define AS_REQBUF_SZ 4096
+#define AS_REQBUF_SZ 4096
/* BEGIN of definitions for radix tree entries */
*/
struct as_info {
CbDataList<int> *as_number;
- time_t expires; /* NOTUSED */
+ time_t expires; /* NOTUSED */
};
class ASState
CBDATA_CLASS_INIT(ASState);
ASState::ASState() :
- entry(NULL),
- sc(NULL),
- request(NULL),
- as_number(0),
- offset(0),
- reqofs(0),
- dataRead(false)
+ entry(NULL),
+ sc(NULL),
+ request(NULL),
+ as_number(0),
+ offset(0),
+ reqofs(0),
+ dataRead(false)
{
memset(reqbuf, 0, AS_REQBUF_SZ);
}
extern "C" {
#endif
- static int destroyRadixNode(struct squid_radix_node *rn, void *w);
- static int printRadixNode(struct squid_radix_node *rn, void *sentry);
+static int destroyRadixNode(struct squid_radix_node *rn, void *w);
+static int printRadixNode(struct squid_radix_node *rn, void *sentry);
#if defined(__cplusplus)
}
/* initialize the radix tree structure */
-SQUIDCEXTERN int squid_max_keylen; /* yuck.. this is in lib/radix.c */
+SQUIDCEXTERN int squid_max_keylen; /* yuck.. this is in lib/radix.c */
void
asnInit(void)
e->e_info = asinfo;
}
- if (rn == 0) { /* assert might expand to nothing */
+ if (rn == 0) { /* assert might expand to nothing */
xfree(asinfo);
delete q;
xfree(e);
}
ACLDestinationASNStrategy ACLDestinationASNStrategy::Instance_;
+
};
#endif /* SQUID_ACLASN_H */
+
ACLAtStepStrategy ACLAtStepStrategy::Instance_;
#endif /* USE_OPENSSL */
+
#endif /* USE_OPENSSL */
#endif /* SQUID_ACLATSTEP_H */
+
}
#endif /* USE_OPENSSL */
+
#endif /* USE_OPENSSL */
#endif /* SQUID_ACLSSL_ERRORDATA_H */
+
// Not implemented: OrNode cannot be configured directly. See Acl::AnyOf.
assert(false);
}
+
} // namespace Acl
#endif /* SQUID_ACL_LOGIC_H */
+
};
#endif /* SQUID_ACLBROWSER_H */
+
ACLCertificateStrategy ACLCertificateStrategy::Instance_;
#endif /* USE_OPENSSL */
+
};
#endif /* SQUID_ACLCERTIFICATE_H */
+
/* Splay trees don't clone yet. */
return new ACLCertificateData(*this);
}
+
};
#endif /* SQUID_ACLCERTIFICATEDATA_H */
+
}
ACLChecklist::ACLChecklist() :
- accessList (NULL),
- callback (NULL),
- callback_data (NULL),
- asyncCaller_(false),
- occupied_(false),
- finished_(false),
- allow_(ACCESS_DENIED),
- asyncStage_(asyncNone),
- state_(NullState::Instance()),
- asyncLoopDepth_(0)
+ accessList (NULL),
+ callback (NULL),
+ callback_data (NULL),
+ asyncCaller_(false),
+ occupied_(false),
+ finished_(false),
+ allow_(ACCESS_DENIED),
+ asyncStage_(asyncNone),
+ state_(NullState::Instance()),
+ asyncLoopDepth_(0)
{
}
{
return !cbdataReferenceValid(callback_data);
}
+
/** \ingroup ACLAPI
Base class for maintaining Squid and transaction state for access checks.
- Provides basic ACL checking methods. Its only child, ACLFilledChecklist,
- keeps the actual state data. The split is necessary to avoid exposing
+ Provides basic ACL checking methods. Its only child, ACLFilledChecklist,
+ keeps the actual state data. The split is necessary to avoid exposing
all ACL-related code to virtually Squid data types. */
class ACLChecklist
{
};
#endif /* SQUID_ACLCHECKLIST_H */
+
};
#endif /* SQUID_ACLDATA_H */
+
};
#endif /* SQUID_ACLDESTINATIONASN_H */
+
}
ACLDestinationDomainStrategy ACLDestinationDomainStrategy::Instance_;
+
};
#endif /* SQUID_ACLDESTINATIONDOMAIN_H */
+
{
return new ACLDestinationIP(*this);
}
+
};
#endif /* SQUID_ACLDESTINATIONIP_H */
+
assert (!domains);
return new ACLDomainData;
}
+
};
#endif /* SQUID_ACLDOMAINDATA_H */
+
}
#endif /* USE_SQUID_EUI */
+
};
#endif /* SQUID_ACLEUI64_H */
+
}
#endif /* USE_AUTH */
+
#endif /* USE_AUTH */
#endif /* SQUID_EXTUSER_H */
+
CBDATA_CLASS_INIT(ACLFilledChecklist);
ACLFilledChecklist::ACLFilledChecklist() :
- dst_peer(NULL),
- dst_rdns(NULL),
- request (NULL),
- reply (NULL),
+ dst_peer(NULL),
+ dst_rdns(NULL),
+ request (NULL),
+ reply (NULL),
#if USE_AUTH
- auth_user_request (NULL),
+ auth_user_request (NULL),
#endif
#if SQUID_SNMP
- snmp_community(NULL),
+ snmp_community(NULL),
#endif
#if USE_OPENSSL
- sslErrors(NULL),
+ sslErrors(NULL),
#endif
- conn_(NULL),
- fd_(-1),
- destinationDomainChecked_(false),
- sourceDomainChecked_(false)
+ conn_(NULL),
+ fd_(-1),
+ destinationDomainChecked_(false),
+ sourceDomainChecked_(false)
{
my_addr.setEmpty();
src_addr.setEmpty();
* checkCallback() will delete the list (i.e., self).
*/
ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request, const char *ident):
- dst_peer(NULL),
- dst_rdns(NULL),
- request(NULL),
- reply(NULL),
+ dst_peer(NULL),
+ dst_rdns(NULL),
+ request(NULL),
+ reply(NULL),
#if USE_AUTh
- auth_user_request(NULL),
+ auth_user_request(NULL),
#endif
#if SQUID_SNMP
- snmp_community(NULL),
+ snmp_community(NULL),
#endif
#if USE_OPENSSL
- sslErrors(NULL),
+ sslErrors(NULL),
#endif
- conn_(NULL),
- fd_(-1),
- destinationDomainChecked_(false),
- sourceDomainChecked_(false)
+ conn_(NULL),
+ fd_(-1),
+ destinationDomainChecked_(false),
+ sourceDomainChecked_(false)
{
my_addr.setEmpty();
src_addr.setEmpty();
xstrncpy(rfc931, ident, USER_IDENT_SZ);
#endif
}
+
}
#endif /* SQUID_ACLFILLED_CHECKLIST_H */
+
for (B = *head, T = head; B; T = &B->next, B = B->next)
- ; /* find the tail */
+ ; /* find the tail */
*T = A;
}
*list = NULL;
}
+
void dump_acl_list(StoreEntry * entry, ACLList * head);
#endif /* SQUID_ACL_GADGETS_H */
+
}
ACLHierCodeStrategy ACLHierCodeStrategy::Instance_;
+
};
#endif /* SQUID_ACLHIERCODE_H */
+
{
return new ACLHierCodeData(*this);
}
+
};
#endif /* SQUID_ACLHIERCODEDATA_H */
+
result->hdrName = hdrName;
return result;
}
+
};
#endif /* SQUID_ACLHTTPHEADERDATA_H */
+
};
#endif /* SQUID_ACLHTTPREPHEADER_H */
+
};
#endif /* SQUID_ACLHTTPREQHEADER_H */
+
};
#endif /* SQUID_ACLHTTPSTATUS_H */
+
// merges async and failures (-1) into "not matched"
return result == 1;
}
+
} // namespace Acl
#endif /* SQUID_ACL_INNER_NODE_H */
+
};
#endif /* SQUID_ACLINTRANGE_H */
+
/**
* Writes an IP ACL data into a buffer, then copies the buffer into the wordlist given
*
- \param ip ACL data structure to display
- \param state wordlist structure which is being generated
+ \param ip ACL data structure to display
+ \param state wordlist structure which is being generated
*/
void
ACLIP::DumpIpListWalkee(acl_ip_data * const & ip, void *state)
/**
* print/format an acl_ip_data structure for debugging output.
*
- \param buf string buffer to write to
- \param len size of the buffer available
+ \param buf string buffer to write to
+ \param len size of the buffer available
*/
void
acl_ip_data::toStr(char *buf, int len) const
acl_ip_data::acl_ip_data() :addr1(), addr2(), mask(), next (NULL) {}
acl_ip_data::acl_ip_data(Ip::Address const &anAddress1, Ip::Address const &anAddress2, Ip::Address const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext) {}
+
Ip::Address mask; /**< \todo This should perhapse be stored as a CIDR range now instead of a full IP mask. */
- acl_ip_data *next; /**< used for parsing, not for storing */
+ acl_ip_data *next; /**< used for parsing, not for storing */
private:
};
#endif /* SQUID_ACLIP_H */
+
{
return new ACLLocalIP(*this);
}
+
};
#endif /* SQUID_ACLLOCALIP_H */
+
}
ACLLocalPortStrategy ACLLocalPortStrategy::Instance_;
+
};
#endif /* SQUID_ACLLOCALPORT_H */
+
debugs(22, DBG_CRITICAL, "WARNING: 'maxconn' ACL (" << name << ") won't work with client_db disabled");
}
+
};
#endif /* SQUID_ACLMAXCONNECTION_H */
+
}
ACLMethodStrategy ACLMethodStrategy::Instance_;
+
};
#endif /* SQUID_ACLMETHOD_H */
+
assert(values.empty());
return new ACLMethodData(*this);
}
+
};
#endif /* SQUID_ACLMETHODDATA_H */
+
}
ACLMyPortNameStrategy ACLMyPortNameStrategy::Instance_;
+
};
#endif /* SQUID_ACLMYPORTNAME_H */
+
};
#endif /* SQUID_ACLNOTE_H */
+
result->name = name;
return result;
}
+
};
#endif /* SQUID_ACLNOTEDATA_H */
+
}
ACLPeerNameStrategy ACLPeerNameStrategy::Instance_;
+
};
#endif /* SQUID_ACLPEERNAME_H */
+
}
ACLProtocolStrategy ACLProtocolStrategy::Instance_;
+
};
#endif /* SQUID_ACLPROTOCOL_H */
+
assert(values.empty());
return new ACLProtocolData(*this);
}
+
};
#endif /* SQUID_ACLPROTOCOLDATA_H */
+
sl.push_back(SBuf(pattern));
return sl;
}
+
};
#endif /* SQUID_ACL_RANDOM_H */
+
};
#endif /* SQUID_ACLREFERER_H */
+
assert (!data);
return new ACLRegexData;
}
+
};
#endif /* SQUID_ACLREGEXDATA_H */
+
ACLReplyHeaderStrategy<header> * ACLReplyHeaderStrategy<header>::Instance_ = NULL;
#endif /* SQUID_REPLYHEADERSTRATEGY_H */
+
}
#endif /* SQUID_ACLREPLYMIMETYPE_H */
+
ACLRequestHeaderStrategy<header> * ACLRequestHeaderStrategy<header>::Instance_ = NULL;
#endif /* SQUID_REQUESTHEADERSTRATEGY_H */
+
}
#endif /* SQUID_ACLREQUESTMIMETYPE_H */
+
ACLServerCertificateStrategy ACLServerCertificateStrategy::Instance_;
#endif /* USE_OPENSSL */
+
};
#endif /* SQUID_ACLSERVERCERTIFICATE_H */
+
};
#endif /* SQUID_ACL_SOURCEASN_H */
+
}
ACLSourceDomainStrategy ACLSourceDomainStrategy::Instance_;
+
};
#endif /* SQUID_ACLSOURCEDOMAIN_H */
+
{
return new ACLSourceIP(*this);
}
+
};
#endif /* SQUID_ACLSOURCEIP_H */
+
}
ACLSslErrorStrategy ACLSslErrorStrategy::Instance_;
+
};
#endif /* SQUID_ACLSSL_ERROR_H */
+
assert (!values);
return new ACLSslErrorData(*this);
}
+
};
#endif /* SQUID_ACLSSL_ERRORDATA_H */
+
/* ACLLocalPort + ACLSslError */
template class ACLStrategised<int>;
+
}
#endif /* SQUID_ACLSTRATEGISED_H */
+
};
#endif /* SQUID_ACLSTRATEGY_H */
+
assert (!values);
return new ACLStringData(*this);
}
+
};
#endif /* SQUID_ACLSTRINGDATA_H */
+
}
ACLTagStrategy ACLTagStrategy::Instance_;
+
};
#endif /* SQUID_ACLMYPORTNAME_H */
+
}
ACLTimeStrategy ACLTimeStrategy::Instance_;
+
};
#endif /* SQUID_ACLTIME_H */
+
{
return new ACLTimeData(*this);
}
+
};
#endif /* SQUID_ACLTIMEDATA_H */
+
} // namespace Acl
#endif /* SQUID_ACL_TREE_H */
+
}
ACLUrlStrategy ACLUrlStrategy::Instance_;
+
};
#endif /* SQUID_ACLURL_H */
+
}
ACLUrlLoginStrategy ACLUrlLoginStrategy::Instance_;
+
};
#endif /* SQUID_ACLURLLOGIN_H */
+
}
ACLUrlPathStrategy ACLUrlPathStrategy::Instance_;
+
};
#endif /* SQUID_ACLURLPATH_H */
+
}
ACLUrlPortStrategy ACLUrlPortStrategy::Instance_;
+
};
#endif /* SQUID_ACLURLPORT_H */
+
assert (!names);
return new ACLUserData;
}
+
};
#endif /* SQUID_ACLUSERDATA_H */
+
typedef RefCount<ExternalACLEntry> ExternalACLEntryPointer;
#endif /* SQUID_ACL_FORWARD_H */
+
Adaptation::AccessCheck::AccessCheck(const ServiceFilter &aFilter,
Adaptation::Initiator *initiator):
- AsyncJob("AccessCheck"), filter(aFilter),
- theInitiator(initiator),
- acl_checklist(NULL)
+ AsyncJob("AccessCheck"), filter(aFilter),
+ theInitiator(initiator),
+ acl_checklist(NULL)
{
#if ICAP_CLIENT
Adaptation::Icap::History::Pointer h = filter.request->icapHistory();
debugs(93,7,HERE << r.groupId << (wants ? " wants" : " ignores"));
return wants;
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__ACCESS_RULE_H */
+
Adaptation::Answer::Answer(Kind aKind): final(true), kind(aKind)
{
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__ANSWER_H */
+
}
Adaptation::Config::Config() :
- onoff(0), service_failure_limit(0), oldest_service_failure(0),
- service_revival_delay(0)
+ onoff(0), service_failure_limit(0), oldest_service_failure(0),
+ service_revival_delay(0)
{}
// XXX: this is called for ICAP and eCAP configs, but deals mostly
{
freeService();
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__CONFIG_H */
+
id.clean();
services.clear();
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION_ELEMENTS_H */
+
const static char *TheNullServices = ",null,";
Adaptation::History::Entry::Entry(const String &serviceId, const timeval &when):
- service(serviceId), start(when), theRptm(-1), retried(false)
+ service(serviceId), start(when), theRptm(-1), retried(false)
{
}
Adaptation::History::Entry::Entry():
- start(current_time), theRptm(-1), retried(false)
+ start(current_time), theRptm(-1), retried(false)
{
}
}
Adaptation::History::History():
- lastMeta(hoReply),
- allMeta(hoReply),
- theNextServices(TheNullServices)
+ lastMeta(hoReply),
+ allMeta(hoReply),
+ theNextServices(TheNullServices)
{
}
theFutureServices.clear();
return true;
}
+
} // namespace Adaptation
#endif
+
{
public:
AnswerCall(const char *aName, const AnswerDialer &aDialer) :
- AsyncCallT<AnswerDialer>(93, 5, aName, aDialer), fired(false) {}
+ AsyncCallT<AnswerDialer>(93, 5, aName, aDialer), fired(false) {}
virtual void fire() {
fired = true;
AsyncCallT<AnswerDialer>::fire();
{
return AsyncJob::status(); // for now
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__INITIATE_H */
+
CallJobHere(93, 5, x, Initiate, noteInitiatorAborted);
clearAdaptation(x);
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__INITIATOR_H */
+
HttpMsg *aMsg, HttpRequest *aCause,
AccessLogEntry::Pointer &alp,
const ServiceGroupPointer &aGroup):
- AsyncJob("Iterator"),
- Adaptation::Initiate("Iterator"),
- theGroup(aGroup),
- theMsg(aMsg),
- theCause(aCause),
- al(alp),
- theLauncher(0),
- iterations(0),
- adapted(false)
+ AsyncJob("Iterator"),
+ Adaptation::Initiate("Iterator"),
+ theGroup(aGroup),
+ theMsg(aMsg),
+ theCause(aCause),
+ al(alp),
+ theLauncher(0),
+ iterations(0),
+ adapted(false)
{
if (theCause != NULL)
HTTPMSGLOCK(theCause);
}
CBDATA_NAMESPACED_CLASS_INIT(Adaptation, Iterator);
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__ITERATOR_H */
+
}
dest.set(src.header->clone());
}
+
// TODO: replace ICAPInOut with Adaptation::Message (adding one for "cause")
#endif /* SQUID__ADAPTATION__MESSAGE_H */
+
AllServices().pop_back();
}
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__SERVICE_H */
+
#include <set>
Adaptation::ServiceConfig::ServiceConfig():
- port(-1), method(methodNone), point(pointNone),
- bypass(false), maxConn(-1), onOverload(srvWait),
- routing(false), ipv6(false)
+ port(-1), method(methodNone), point(pointNone),
+ bypass(false), maxConn(-1), onOverload(srvWait),
+ routing(false), ipv6(false)
{}
const char *
name << '=' << value);
return false;
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__SERVICE_CONFIG_H */
+
#include "HttpRequest.h"
Adaptation::ServiceFilter::ServiceFilter(Method aMethod, VectPoint aPoint, HttpRequest *aReq, HttpReply *aRep, AccessLogEntry::Pointer const &alp):
- method(aMethod),
- point(aPoint),
- request(aReq),
- reply(aRep),
- al(alp)
+ method(aMethod),
+ point(aPoint),
+ request(aReq),
+ reply(aRep),
+ al(alp)
{
if (reply)
HTTPMSGLOCK(reply);
}
Adaptation::ServiceFilter::ServiceFilter(const ServiceFilter &f):
- method(f.method),
- point(f.point),
- request(f.request),
- reply(f.reply),
- al(f.al)
+ method(f.method),
+ point(f.point),
+ request(f.request),
+ reply(f.reply),
+ al(f.al)
{
if (request)
HTTPMSGLOCK(request);
}
return *this;
}
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__SERVICE_FILTER_H */
+
#include "wordlist.h"
Adaptation::ServiceGroup::ServiceGroup(const String &aKind, bool allSame):
- kind(aKind), method(methodNone), point(pointNone),
- allServicesSame(allSame)
+ kind(aKind), method(methodNone), point(pointNone),
+ allServicesSame(allSame)
{
}
/* SingleService */
Adaptation::SingleService::SingleService(const String &aServiceId):
- ServiceGroup("single-service group", false)
+ ServiceGroup("single-service group", false)
{
id = aServiceId;
services.push_back(aServiceId);
Adaptation::ServicePlan::ServicePlan(const ServiceGroupPointer &g,
const ServiceFilter &filter):
- group(g), pos(0), atEof(!g || !g->has(pos))
+ group(g), pos(0), atEof(!g || !g->has(pos))
{
// this will find the first service because starting pos is zero
if (!atEof && !group->findService(filter, pos))
return NULL;
}
+
} // namespace Adaptation
#endif /* SQUID_ECAP_CONFIG_H */
+
libecap::RegisterHost(TheHost);
}
}
+
} // namespace Adaptation
#endif /* SQUID_ECAP_HOST_H */
+
/* HeaderRep */
Adaptation::Ecap::HeaderRep::HeaderRep(HttpMsg &aMessage): theHeader(aMessage.header),
- theMessage(aMessage)
+ theMessage(aMessage)
{
}
/* RequestHeaderRep */
Adaptation::Ecap::RequestLineRep::RequestLineRep(HttpRequest &aMessage):
- FirstLineRep(aMessage), theMessage(aMessage)
+ FirstLineRep(aMessage), theMessage(aMessage)
{
}
/* ReplyHeaderRep */
Adaptation::Ecap::StatusLineRep::StatusLineRep(HttpReply &aMessage):
- FirstLineRep(aMessage), theMessage(aMessage)
+ FirstLineRep(aMessage), theMessage(aMessage)
{
}
/* MessageRep */
Adaptation::Ecap::MessageRep::MessageRep(HttpMsg *rawHeader):
- theMessage(rawHeader), theFirstLineRep(NULL),
- theHeaderRep(NULL), theBodyRep(NULL)
+ theMessage(rawHeader), theFirstLineRep(NULL),
+ theHeaderRep(NULL), theBodyRep(NULL)
{
Must(theMessage.header); // we do not want to represent a missing message
{
return theBodyRep;
}
+
} // namespace Adaptation
#endif /* SQUID__E_CAP__MESSAGE_REP_H */
+
#include "squid.h"
// TBD
+
* Please see the COPYING and CONTRIBUTORS files for details.
*/
-// TBD\r
+// TBD
+
/* Adaptation::Ecap::ServiceRep */
Adaptation::Ecap::ServiceRep::ServiceRep(const ServiceConfigPointer &cfg):
- /*AsyncJob("Adaptation::Ecap::ServiceRep"),*/ Adaptation::Service(cfg),
- isDetached(false)
+/*AsyncJob("Adaptation::Ecap::ServiceRep"),*/ Adaptation::Service(cfg),
+ isDetached(false)
{
}
"ecap_service config option: " << loaded->second->uri());
}
}
+
} // namespace Adaptation
#endif /* SQUID_ECAP_SERVICE_REP_H */
+
Adaptation::Ecap::XactionRep::XactionRep(
HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp,
const Adaptation::ServicePointer &aService):
- AsyncJob("Adaptation::Ecap::XactionRep"),
- Adaptation::Initiate("Adaptation::Ecap::XactionRep"),
- theService(aService),
- theVirginRep(virginHeader), theCauseRep(NULL),
- makingVb(opUndecided), proxyingAb(opUndecided),
- adaptHistoryId(-1),
- vbProductionFinished(false),
- abProductionFinished(false), abProductionAtEnd(false),
- al(alp)
+ AsyncJob("Adaptation::Ecap::XactionRep"),
+ Adaptation::Initiate("Adaptation::Ecap::XactionRep"),
+ theService(aService),
+ theVirginRep(virginHeader), theCauseRep(NULL),
+ makingVb(opUndecided), proxyingAb(opUndecided),
+ adaptHistoryId(-1),
+ vbProductionFinished(false),
+ abProductionFinished(false), abProductionAtEnd(false),
+ al(alp)
{
if (virginCause)
theCauseRep = new MessageRep(virginCause);
return buf.content();
}
+
xaction that Squid communicates with. One eCAP module may register many
eCAP xactions. */
class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction,
- public BodyConsumer, public BodyProducer
+ public BodyConsumer, public BodyProducer
{
CBDATA_CLASS(XactionRep);
} // namespace Adaptation
#endif /* SQUID_ECAP_XACTION_REP_H */
+
} // namespace Adaptation
#endif /* SQUID_ADAPTATION__FORWARD_H */
+
void Adaptation::Icap::CleanModule()
{
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPCLIENT_H */
+
Adaptation::Icap::Config Adaptation::Icap::TheConfig;
Adaptation::Icap::Config::Config() :
- default_options_ttl(0),
- preview_enable(0), preview_size(0), allow206_enable(0),
- connect_timeout_raw(0), io_timeout_raw(0), reuse_connections(0),
- client_username_header(NULL), client_username_encode(0), repeat(NULL),
- repeat_limit(0)
+ default_options_ttl(0),
+ preview_enable(0), preview_size(0), allow206_enable(0),
+ connect_timeout_raw(0), io_timeout_raw(0), reuse_connections(0),
+ client_username_header(NULL), client_username_encode(0), repeat(NULL),
+ repeat_limit(0)
{
}
// can still be bypassed
return ::Config.Timeout.read;
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPCONFIG_H */
+
} // namespace Icap
} // namespace Adaptation
+
} // namespace Adaptation
#endif /* SQUID_ICAPCLIENT_H */
+
#include "SquidTime.h"
Adaptation::Icap::History::History():
- logType(LOG_TAG_NONE),
- req_sz(0),
- concurrencyLevel(0)
+ logType(LOG_TAG_NONE),
+ req_sz(0),
+ concurrencyLevel(0)
{
memset(¤tStart, 0, sizeof(currentStart));
memset(&pastTime, 0, sizeof(pastTime));
current.tv_usec = 0;
}
}
+
} // namespace Adaptation
#endif /*SQUID_HISTORY_H*/
+
} // namespace Adaptation
#endif /* SQUID_ICAPINOUT_H */
+
Adaptation::Icap::Launcher::Launcher(const char *aTypeName,
Adaptation::ServicePointer &aService):
- AsyncJob(aTypeName),
- Adaptation::Initiate(aTypeName),
- theService(aService), theXaction(0), theLaunches(0)
+ AsyncJob(aTypeName),
+ Adaptation::Initiate(aTypeName),
+ theService(aService), theXaction(0), theLaunches(0)
{
}
Adaptation::Icap::XactAbortInfo::XactAbortInfo(HttpRequest *anIcapRequest,
HttpReply *anIcapReply, bool beRetriable, bool beRepeatable):
- icapRequest(anIcapRequest),
- icapReply(anIcapReply),
- isRetriable(beRetriable),
- isRepeatable(beRepeatable)
+ icapRequest(anIcapRequest),
+ icapReply(anIcapReply),
+ isRetriable(beRetriable),
+ isRepeatable(beRepeatable)
{
if (icapRequest)
HTTPMSGLOCK(icapRequest);
}
Adaptation::Icap::XactAbortInfo::XactAbortInfo(const Adaptation::Icap::XactAbortInfo &i):
- icapRequest(i.icapRequest),
- icapReply(i.icapReply),
- isRetriable(i.isRetriable),
- isRepeatable(i.isRepeatable)
+ icapRequest(i.icapRequest),
+ icapReply(i.icapReply),
+ isRetriable(i.isRetriable),
+ isRepeatable(i.isRepeatable)
{
if (icapRequest)
HTTPMSGLOCK(icapRequest);
HTTPMSGUNLOCK(icapRequest);
HTTPMSGUNLOCK(icapReply);
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPLAUNCHER_H */
+
Adaptation::Icap::ModXact::ModXact(HttpMsg *virginHeader,
HttpRequest *virginCause, AccessLogEntry::Pointer &alp, Adaptation::Icap::ServiceRep::Pointer &aService):
- AsyncJob("Adaptation::Icap::ModXact"),
- Adaptation::Icap::Xaction("Adaptation::Icap::ModXact", aService),
- virginConsumed(0),
- bodyParser(NULL),
- canStartBypass(false), // too early
- protectGroupBypass(true),
- replyHttpHeaderSize(-1),
- replyHttpBodySize(-1),
- adaptHistoryId(-1),
- alMaster(alp)
+ AsyncJob("Adaptation::Icap::ModXact"),
+ Adaptation::Icap::Xaction("Adaptation::Icap::ModXact", aService),
+ virginConsumed(0),
+ bodyParser(NULL),
+ canStartBypass(false), // too early
+ protectGroupBypass(true),
+ replyHttpHeaderSize(-1),
+ replyHttpBodySize(-1),
+ adaptHistoryId(-1),
+ alMaster(alp)
{
assert(virginHeader);
// TODO: Move SizedEstimate and Preview elsewhere
Adaptation::Icap::SizedEstimate::SizedEstimate()
- : theData(dtUnexpected)
+ : theData(dtUnexpected)
{}
void Adaptation::Icap::SizedEstimate::expect(int64_t aSize)
/* Adaptation::Icap::ModXactLauncher */
Adaptation::Icap::ModXactLauncher::ModXactLauncher(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, Adaptation::ServicePointer aService):
- AsyncJob("Adaptation::Icap::ModXactLauncher"),
- Adaptation::Icap::Launcher("Adaptation::Icap::ModXactLauncher", aService),
- al(alp)
+ AsyncJob("Adaptation::Icap::ModXactLauncher"),
+ Adaptation::Icap::Launcher("Adaptation::Icap::ModXactLauncher", aService),
+ al(alp)
{
virgin.setHeader(virginHeader);
virgin.setCause(virginCause);
}
}
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPMOD_XACT_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, OptXactLauncher);
Adaptation::Icap::OptXact::OptXact(Adaptation::Icap::ServiceRep::Pointer &aService):
- AsyncJob("Adaptation::Icap::OptXact"),
- Adaptation::Icap::Xaction("Adaptation::Icap::OptXact", aService),
- readAll(false)
+ AsyncJob("Adaptation::Icap::OptXact"),
+ Adaptation::Icap::Xaction("Adaptation::Icap::OptXact", aService),
+ readAll(false)
{
}
/* Adaptation::Icap::OptXactLauncher */
Adaptation::Icap::OptXactLauncher::OptXactLauncher(Adaptation::ServicePointer aService):
- AsyncJob("Adaptation::Icap::OptXactLauncher"),
- Adaptation::Icap::Launcher("Adaptation::Icap::OptXactLauncher", aService)
+ AsyncJob("Adaptation::Icap::OptXactLauncher"),
+ Adaptation::Icap::Launcher("Adaptation::Icap::OptXactLauncher", aService)
{
}
Must(s != NULL);
return new Adaptation::Icap::OptXact(s);
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPOPTXACT_H */
+
#include "wordlist.h"
Adaptation::Icap::Options::Options() :
- error("unconfigured"),
- max_connections(-1),
- allow204(false),
- allow206(false),
- preview(-1),
- theTTL(-1),
- theTimestamp(0)
+ error("unconfigured"),
+ max_connections(-1),
+ allow204(false),
+ allow206(false),
+ preview(-1),
+ theTTL(-1),
+ theTimestamp(0)
{
theTransfers.preview.name = "Transfer-Preview";
theTransfers.preview.kind = xferPreview;
/* Adaptation::Icap::Options::TransferList */
Adaptation::Icap::Options::TransferList::TransferList(): extensions(NULL), name(NULL),
- kind(xferNone)
+ kind(xferNone)
{
};
debugs(93,level, prefix << "no " << name << " extensions");
}
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPOPTIONS_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, ServiceRep);
Adaptation::Icap::ServiceRep::ServiceRep(const ServiceConfigPointer &svcCfg):
- AsyncJob("Adaptation::Icap::ServiceRep"), Adaptation::Service(svcCfg),
- theOptions(NULL), theOptionsFetcher(0), theLastUpdate(0),
- theBusyConns(0),
- theAllWaiters(0),
- connOverloadReported(false),
- theIdleConns(NULL),
- isSuspended(0), notifying(false),
- updateScheduled(false),
- wasAnnouncedUp(true), // do not announce an "up" service at startup
- isDetached(false)
+ AsyncJob("Adaptation::Icap::ServiceRep"), Adaptation::Service(svcCfg),
+ theOptions(NULL), theOptionsFetcher(0), theLastUpdate(0),
+ theBusyConns(0),
+ theAllWaiters(0),
+ connOverloadReported(false),
+ theIdleConns(NULL),
+ isSuspended(0), notifying(false),
+ updateScheduled(false),
+ wasAnnouncedUp(true), // do not announce an "up" service at startup
+ isDetached(false)
{
setMaxConnections();
theIdleConns = new IdleConnList("ICAP Service", NULL);
Adaptation::Icap::ConnWaiterDialer::ConnWaiterDialer(const CbcPointer<Adaptation::Icap::ModXact> &xact,
Adaptation::Icap::ConnWaiterDialer::Parent::Method aHandler):
- Parent(xact, aHandler)
+ Parent(xact, aHandler)
{
theService = &xact->service();
theService->noteNewWaiter();
{
theService->noteGoneWaiter();
}
+
*/
class ServiceRep : public RefCountable, public Adaptation::Service,
- public Adaptation::Initiator
+ public Adaptation::Initiator
{
CBDATA_CLASS(ServiceRep);
} // namespace Adaptation
#endif /* SQUID_ICAPSERVICEREP_H */
+
#include "SquidTime.h"
Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::ServiceRep::Pointer &aService):
- AsyncJob(aTypeName),
- Adaptation::Initiate(aTypeName),
- icapRequest(NULL),
- icapReply(NULL),
- attempts(0),
- connection(NULL),
- theService(aService),
- commBuf(NULL),
- commBufSize(0),
- commEof(false),
- reuseConnection(true),
- isRetriable(true),
- isRepeatable(true),
- ignoreLastWrite(false),
- stopReason(NULL),
- connector(NULL),
- reader(NULL),
- writer(NULL),
- closer(NULL),
- alep(new AccessLogEntry),
- al(*alep),
- cs(NULL)
+ AsyncJob(aTypeName),
+ Adaptation::Initiate(aTypeName),
+ icapRequest(NULL),
+ icapReply(NULL),
+ attempts(0),
+ connection(NULL),
+ theService(aService),
+ commBuf(NULL),
+ commBufSize(0),
+ commEof(false),
+ reuseConnection(true),
+ isRetriable(true),
+ isRepeatable(true),
+ ignoreLastWrite(false),
+ stopReason(NULL),
+ connector(NULL),
+ reader(NULL),
+ writer(NULL),
+ closer(NULL),
+ alep(new AccessLogEntry),
+ al(*alep),
+ cs(NULL)
{
debugs(93,3, typeName << " constructed, this=" << this <<
" [icapx" << id << ']'); // we should not call virtual status() here
const bool parsed = msg->parse(&readBuf, commEof, &error);
Must(parsed || !error); // success or need more data
- if (!parsed) { // need more data
+ if (!parsed) { // need more data
Must(mayReadMore());
msg->reset();
return false;
{
return false;
}
+
} // namespace Adaptation
#endif /* SQUID_ICAPXACTION_H */
+
accessLogLogTo(Config.Log.icaplogs, al, &checklist);
}
}
+
extern int IcapLogfileStatus;
#endif /*ICAP_LOG_H_*/
+
int HttpSockets[MAXTCPLISTENPORTS];
AnyP::PortCfg::PortCfg() :
- next(),
- s(),
- transport(AnyP::PROTO_HTTP,1,1), // "Squid is an HTTP proxy", etc.
- name(NULL),
- defaultsite(NULL),
- flags(),
- allow_direct(false),
- vhost(false),
- actAsOrigin(false),
- ignore_cc(false),
- connection_auth_disabled(false),
- ftp_track_dirs(false),
- vport(0),
- disable_pmtu_discovery(0),
- listenConn()
+ next(),
+ s(),
+ transport(AnyP::PROTO_HTTP,1,1), // "Squid is an HTTP proxy", etc.
+ name(NULL),
+ defaultsite(NULL),
+ flags(),
+ allow_direct(false),
+ vhost(false),
+ actAsOrigin(false),
+ ignore_cc(false),
+ connection_auth_disabled(false),
+ ftp_track_dirs(false),
+ vport(0),
+ disable_pmtu_discovery(0),
+ listenConn()
#if USE_OPENSSL
- ,cert(NULL),
- key(NULL),
- version(0),
- cipher(NULL),
- options(NULL),
- clientca(NULL),
- cafile(NULL),
- capath(NULL),
- crlfile(NULL),
- dhfile(NULL),
- sslflags(NULL),
- sslContextSessionId(NULL),
- generateHostCertificates(false),
- dynamicCertMemCacheSize(std::numeric_limits<size_t>::max()),
- staticSslContext(),
- signingCert(),
- signPkey(),
- certsToChain(),
- untrustedSigningCert(),
- untrustedSignPkey(),
- clientVerifyCrls(),
- clientCA(),
- dhParams(),
- contextMethod(),
- sslContextFlags(0),
- sslOptions(0)
+ ,cert(NULL),
+ key(NULL),
+ version(0),
+ cipher(NULL),
+ options(NULL),
+ clientca(NULL),
+ cafile(NULL),
+ capath(NULL),
+ crlfile(NULL),
+ dhfile(NULL),
+ sslflags(NULL),
+ sslContextSessionId(NULL),
+ generateHostCertificates(false),
+ dynamicCertMemCacheSize(std::numeric_limits<size_t>::max()),
+ staticSslContext(),
+ signingCert(),
+ signPkey(),
+ certsToChain(),
+ untrustedSigningCert(),
+ untrustedSignPkey(),
+ clientVerifyCrls(),
+ clientCA(),
+ dhParams(),
+ contextMethod(),
+ sslContextFlags(0),
+ sslOptions(0)
#endif
{
memset(&tcp_keepalive, 0, sizeof(tcp_keepalive));
}
}
#endif
+
extern int HttpSockets[MAXTCPLISTENPORTS];
#endif /* SQUID_ANYP_PORTCFG_H */
+
} // namespace AnyP
#endif /* _SQUID_SRC_ANYP_PROTOCOLTYPE_H */
+
} // namespace AnyP
#endif /* SQUID_ANYP_PROTOCOLVERSION_H */
+
} // namespace AnyP
#endif
+
out[p] = '\0';
return out;
}
+
}
#endif /* SQUID_ANYP_URISCHEME_H */
+
return ACCESS_DENIED;
}
}
+
#endif /* USE_AUTH */
#endif /* SQUID_AUTH_ACL_H */
+
ACLFlag ACLMaxUserIP::SupportedFlags[] = {ACL_F_STRICT, ACL_F_END};
ACLMaxUserIP::ACLMaxUserIP(char const *theClass) :
- ACL(SupportedFlags),
- class_(theClass),
- maximum(0)
+ ACL(SupportedFlags),
+ class_(theClass),
+ maximum(0)
{}
ACLMaxUserIP::ACLMaxUserIP(ACLMaxUserIP const &old) :
- class_(old.class_),
- maximum(old.maximum)
+ class_(old.class_),
+ maximum(old.maximum)
{
flags = old.flags;
}
sl.push_back(s);
return sl;
}
+
#endif /* USE_AUTH */
#endif /* SQUID_ACLMAXUSERIP_H */
+
checklist->auth_user_request = NULL;
return result;
}
+
#endif /* USE_AUTH */
#endif /* SQUID_ACLPROXYAUTH_H */
+
#endif /* USE_AUTH */
#endif /* _SQUID__SRC_AUTH_AUTHACLSTATE_H */
+
/**
* Used by squid to determine whether the auth module has successfully initialised itself with the current configuration.
*
- \retval true Authentication Module loaded and running.
- \retval false No Authentication Module loaded.
+ \retval true Authentication Module loaded and running.
+ \retval false No Authentication Module loaded.
*/
virtual bool active() const = 0;
* linking to a AuthUser object and for storing any needed details to complete
* authentication in Auth::UserRequest::authenticate().
*
- \param proxy_auth Login Pattern to parse.
- \retval * Details needed to authenticate.
+ \param proxy_auth Login Pattern to parse.
+ \retval * Details needed to authenticate.
*/
virtual UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm) = 0;
* The configured function is used to see if the auth module has been given valid
* parameters and is able to handle authentication requests.
*
- \retval true Authentication Module configured ready for use.
- \retval false Not configured or Configuration Error.
- * No other module functions except Shutdown/Dump/Parse/FreeConfig will be called by Squid.
+ \retval true Authentication Module configured ready for use.
+ \retval false Not configured or Configuration Error.
+ * No other module functions except Shutdown/Dump/Parse/FreeConfig will be called by Squid.
*/
virtual bool configured() const = 0;
#endif /* USE_AUTH */
#endif /* SQUID_AUTHCONFIG_H */
+
} // namespace Auth
#endif /* _SQUID_AUTH_CREDENTIALSTATE_H */
+
}
AuthUserHashPointer::AuthUserHashPointer(Auth::User::Pointer anAuth_user):
- auth_user(anAuth_user)
+ auth_user(anAuth_user)
{
key = (void *)anAuth_user->userKey();
next = NULL;
{
return auth_user;
}
+
#endif /* USE_AUTH */
#endif /* SQUID_AUTH_GADGETS_H */
+
public:
QueueNode(Auth::UserRequest *aRequest, AUTHCB *aHandler, void *aData) :
- next(NULL),
- auth_user_request(aRequest),
- handler(aHandler),
- data(cbdataReference(aData)) {}
+ next(NULL),
+ auth_user_request(aRequest),
+ handler(aHandler),
+ data(cbdataReference(aData)) {}
~QueueNode() {
cbdataReferenceDone(data);
while (next) {
} // namespace Auth
#endif /* SQUID_SRC_AUTH_QUEUENODE_H */
+
scheme->shutdownCleanup();
}
}
+
#include <vector>
/**
- \defgroup AuthSchemeAPI Authentication Scheme API
+ \defgroup AuthSchemeAPI Authentication Scheme API
\ingroup AuthAPI
*/
#endif /* USE_AUTH */
#endif /* SQUID_AUTH_SCHEME_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Auth, StateData);
#endif /* USE_AUTH */
+
public:
StateData(const UserRequest::Pointer &r, AUTHCB *h, void *d) :
- data(cbdataReference(d)),
- auth_user_request(r),
- handler(h) {}
+ data(cbdataReference(d)),
+ auth_user_request(r),
+ handler(h) {}
~StateData() {
auth_user_request = NULL;
#endif /* USE_AUTH */
#endif /* __AUTH_AUTHENTICATE_STATE_T__ */
+
#endif /* USE_AUTH */
#endif
+
time_t Auth::User::last_discard = 0;
Auth::User::User(Auth::Config *aConfig, const char *aRequestRealm) :
- auth_type(Auth::AUTH_UNKNOWN),
- config(aConfig),
- ipcount(0),
- expiretime(0),
- notes(),
- credentials_state(Auth::Unchecked),
- username_(NULL),
- requestRealm_(aRequestRealm)
+ auth_type(Auth::AUTH_UNKNOWN),
+ config(aConfig),
+ ipcount(0),
+ expiretime(0),
+ notes(),
+ credentials_state(Auth::Unchecked),
+ username_(NULL),
+ requestRealm_(aRequestRealm)
{
proxy_match_cache.head = proxy_match_cache.tail = NULL;
ip_list.head = ip_list.tail = NULL;
safe_free(username_);
}
}
+
#endif /* USE_AUTH */
#endif /* SQUID_AUTH_USER_H */
+
}
Auth::UserRequest::UserRequest():
- _auth_user(NULL),
- message(NULL),
- lastReply(AUTH_ACL_CANNOT_AUTHENTICATE)
+ _auth_user(NULL),
+ message(NULL),
+ lastReply(AUTH_ACL_CANNOT_AUTHENTICATE)
{
debugs(29, 5, HERE << "initialised request " << this);
}
request->auth_user_request = *auth_user_request;
}
- /* fallthrough to ERROR case and do the challenge */
+ /* fallthrough to ERROR case and do the challenge */
case Auth::CRED_ERROR:
/* this ACL check is finished. */
}
return NULL;
}
+
/**
* Used by squid to determine what the next step in performing authentication for a given scheme is.
*
- * \retval CRED_ERROR ERROR in the auth module. Cannot determine request direction.
- * \retval CRED_LOOKUP The auth module needs to send data to an external helper.
- * Squid will prepare for a callback on the request and call the AUTHSSTART function.
- * \retval CRED_VALID The auth module has all the information it needs to perform the authentication
- * and provide a succeed/fail result.
- * \retval CRED_CHALLENGE The auth module needs to send a new challenge to the request originator.
- * Squid will return the appropriate status code (401 or 407) and call the registered
- * FixError function to allow the auth module to insert it's challenge.
+ * \retval CRED_ERROR ERROR in the auth module. Cannot determine request direction.
+ * \retval CRED_LOOKUP The auth module needs to send data to an external helper.
+ * Squid will prepare for a callback on the request and call the AUTHSSTART function.
+ * \retval CRED_VALID The auth module has all the information it needs to perform the authentication
+ * and provide a succeed/fail result.
+ * \retval CRED_CHALLENGE The auth module needs to send a new challenge to the request originator.
+ * Squid will return the appropriate status code (401 or 407) and call the registered
+ * FixError function to allow the auth module to insert it's challenge.
*/
Direction direction();
/**
* Used by squid to determine whether the auth scheme has successfully authenticated the user request.
*
- \retval true User has successfully been authenticated.
- \retval false Timeouts on cached credentials have occurred or for any reason the credentials are not valid.
+ \retval true User has successfully been authenticated.
+ \retval false Timeouts on cached credentials have occurred or for any reason the credentials are not valid.
*/
virtual int authenticated() const = 0;
* \retval false User credentials use an unknown scheme type.
* \retval false User credentials are broken for their scheme.
*
- * \retval true User credentials exist and may be able to authenticate.
+ * \retval true User credentials exist and may be able to authenticate.
*/
bool valid() const;
* The given callback will be called when the auth module has performed
* it's external activities.
*
- * \param handler Handler to process the callback when its run
- * \param data CBDATA for handler
+ * \param handler Handler to process the callback when its run
+ * \param data CBDATA for handler
*/
void start(HttpRequest *request, AccessLogEntry::Pointer &al, AUTHCB *handler, void *data);
* This function must return a pointer to a NULL terminated string to be used in logging the request.
* The string should NOT be allocated each time this function is called.
*
- \retval NULL No username/usercode is known.
- \retval * Null-terminated username string.
+ \retval NULL No username/usercode is known.
+ \retval * Null-terminated username string.
*/
char const *username() const;
#endif /* USE_AUTH */
#endif /* SQUID_AUTHUSERREQUEST_H */
+
}
Auth::Basic::Config::Config() :
- credentialsTTL( 2*60*60 ),
- casesensitive(0),
- utf8(0)
+ credentialsTTL( 2*60*60 ),
+ casesensitive(0),
+ utf8(0)
{
static const SBuf defaultRealm("Squid proxy-caching web server");
realm = defaultRealm;
"Basic User Authenticator Stats",
authenticateBasicStats, 0, 1);
}
+
extern helper *basicauthenticators;
#endif /* __AUTH_BASIC_H__ */
+
Auth::Basic::Config *newCfg = new Auth::Basic::Config;
return dynamic_cast<Auth::Config*>(newCfg);
}
+
} // namespace Auth
#endif /* SQUID_AUTH_BASIC_SCHEME_H */
+
#include "SquidTime.h"
Auth::Basic::User::User(Auth::Config *aConfig, const char *aRequestRealm) :
- Auth::User(aConfig, aRequestRealm),
- passwd(NULL),
- queue(NULL),
- currentRequest(NULL)
+ Auth::User(aConfig, aRequestRealm),
+ passwd(NULL),
+ queue(NULL),
+ currentRequest(NULL)
{}
Auth::Basic::User::~User()
} // namespace Auth
#endif /* _SQUID_AUTH_BASIC_USER_H */
+
} // namespace Auth
#endif /* _SQUID_SRC_AUTH_BASIC_USERREQUEST_H */
+
}
Auth::Digest::Config::Config() :
- nonceGCInterval(5*60),
- noncemaxduration(30*60),
- noncemaxuses(50),
- NonceStrictness(0),
- CheckNonceCount(1),
- PostWorkaround(0),
- utf8(0)
+ nonceGCInterval(5*60),
+ noncemaxduration(30*60),
+ noncemaxuses(50),
+ NonceStrictness(0),
+ CheckNonceCount(1),
+ PostWorkaround(0),
+ utf8(0)
{}
void
return digest_request;
}
+
extern helper *digestauthenticators;
#endif
+
} // namespace Auth
#endif /* SQUID_AUTH_DIGEST_SCHEME_H */
+
#include "SquidTime.h"
Auth::Digest::User::User(Auth::Config *aConfig, const char *aRequestRealm) :
- Auth::User(aConfig, aRequestRealm),
- HA1created(0)
+ Auth::User(aConfig, aRequestRealm),
+ HA1created(0)
{
memset(HA1, 0, sizeof(HA1));
}
}
return nonce;
}
+
} // namespace Auth
#endif /* _SQUID_AUTH_DIGEST_USER_H */
+
#include "SquidTime.h"
Auth::Digest::UserRequest::UserRequest() :
- nonceb64(NULL),
- cnonce(NULL),
- realm(NULL),
- pszPass(NULL),
- algorithm(NULL),
- pszMethod(NULL),
- qop(NULL),
- uri(NULL),
- response(NULL),
- nonce(NULL)
+ nonceb64(NULL),
+ cnonce(NULL),
+ realm(NULL),
+ pszPass(NULL),
+ algorithm(NULL),
+ pszMethod(NULL),
+ qop(NULL),
+ uri(NULL),
+ response(NULL),
+ nonce(NULL)
{
memset(nc, 0, sizeof(nc));
memset(&flags, 0, sizeof(flags));
case Helper::TT:
debugs(29, DBG_IMPORTANT, "ERROR: Digest auth does not support the result code received. Using the wrong helper program? received: " << reply);
- // fall through to next case. Handle this as an ERR response.
+ // fall through to next case. Handle this as an ERR response.
case Helper::TimedOut:
case Helper::BrokenHelper:
- // TODO retry the broken lookup on another helper?
- // fall through to next case for now. Handle this as an ERR response silently.
+ // TODO retry the broken lookup on another helper?
+ // fall through to next case for now. Handle this as an ERR response silently.
case Helper::Error: {
/* allow this because the digest_request pointer is purely local */
Auth::Digest::UserRequest *digest_request = dynamic_cast<Auth::Digest::UserRequest *>(auth_user_request.getRaw());
delete replyData;
}
+
} // namespace Auth
#endif /* _SQUID_SRC_AUTH_DIGEST_USERREQUEST_H */
+
* tied to it, even if MAYBE the client could handle it - Kinkie */
rep->header.delByName("keep-alive");
request->flags.proxyKeepalive = false;
- /* fall through */
+ /* fall through */
case Auth::Ok:
/* Special case: authentication finished OK but disallowed by ACL.
debugs(29, 9, HERE << "decode Negotiate authentication");
return auth_user_request;
}
+
extern statefulhelper *negotiateauthenticators;
#endif
+
Auth::Negotiate::Config *negotiateCfg = new Auth::Negotiate::Config;
return dynamic_cast<Auth::Config*>(negotiateCfg);
}
+
} // namespace Auth
#endif /* SQUID_AUTH_NEGOTIATE_SCHEME_H */
+
#include "Debug.h"
Auth::Negotiate::User::User(Auth::Config *aConfig, const char *aRequestRealm) :
- Auth::User(aConfig, aRequestRealm)
+ Auth::User(aConfig, aRequestRealm)
{
}
{
return -1; // Negotiate cannot be cached.
}
+
} // namespace Auth
#endif /* _SQUID_AUTH_NEGOTIATE_USER_H */
+
case Helper::Unknown:
debugs(29, DBG_IMPORTANT, "ERROR: Negotiate Authentication Helper '" << reply.whichServer << "' crashed!.");
- /* continue to the next case */
+ /* continue to the next case */
case Helper::TimedOut:
case Helper::BrokenHelper: {
safe_free(server_blob);
}
+
} // namespace Auth
#endif /* _SQUID_SRC_AUTH_NEGOTIATE_USERREQUEST_H */
+
/* here it makes sense to drop the connection, as auth is
* tied to it, even if MAYBE the client could handle it - Kinkie */
request->flags.proxyKeepalive = false;
- /* fall through */
+ /* fall through */
case Auth::Ok:
- /* Special case: authentication finished OK but disallowed by ACL.
- * Need to start over to give the client another chance.
- */
- /* fall through */
+ /* Special case: authentication finished OK but disallowed by ACL.
+ * Need to start over to give the client another chance.
+ */
+ /* fall through */
case Auth::Unchecked:
/* semantic change: do not drop the connection.
debugs(29, 9, HERE << "decode: NTLM authentication");
return auth_user_request;
}
+
extern statefulhelper *ntlmauthenticators;
#endif
+
Auth::Ntlm::Config *ntlmCfg = new Auth::Ntlm::Config;
return dynamic_cast<Auth::Config*>(ntlmCfg);
}
+
} // namespace Auth
#endif /* SQUID_AUTH_NTLM_SCHEME_H */
+
#include "Debug.h"
Auth::Ntlm::User::User(Auth::Config *aConfig, const char *aRequestRealm) :
- Auth::User(aConfig, aRequestRealm)
+ Auth::User(aConfig, aRequestRealm)
{
}
{
return -1; // NTLM credentials cannot be cached.
}
+
} // namespace Auth
#endif /* _SQUID_AUTH_NTLM_USER_H */
+
case Helper::Unknown:
debugs(29, DBG_IMPORTANT, "ERROR: NTLM Authentication Helper '" << reply.whichServer << "' crashed!.");
- /* continue to the next case */
+ /* continue to the next case */
case Helper::TimedOut:
case Helper::BrokenHelper: {
r->handler(r->data);
delete r;
}
+
} // namespace Auth
#endif /* _SQUID_SRC_AUTH_NTLM_USERREQUEST_H */
+
AsyncCall::AsyncCall(int aDebugSection, int aDebugLevel,
const char *aName): name(aName), debugSection(aDebugSection),
- debugLevel(aDebugLevel), theNext(0), isCanceled(NULL)
+ debugLevel(aDebugLevel), theNext(0), isCanceled(NULL)
{
debugs(debugSection, debugLevel, "The AsyncCall " << name << " constructed, this=" << this <<
" [" << id << ']');
public:
AsyncCallT(int aDebugSection, int aDebugLevel, const char *aName,
const Dialer &aDialer): AsyncCall(aDebugSection, aDebugLevel, aName),
- dialer(aDialer) {}
+ dialer(aDialer) {}
AsyncCallT(const AsyncCallT<Dialer> &o):
- AsyncCall(o.debugSection, o.debugLevel, o.name),
- dialer(o.dialer) {}
+ AsyncCall(o.debugSection, o.debugLevel, o.name),
+ dialer(o.dialer) {}
~AsyncCallT() {}
#define ScheduleCallHere(call) ScheduleCall(__FILE__, __LINE__, (call))
#endif /* SQUID_ASYNCCALL_H */
+
};
#endif /* SQUID_ASYNCCALLQUEUE_H */
+
typedef void Handler(Argument1 *);
UnaryCbdataDialer(Handler *aHandler, Argument1 *aArg) :
- arg1(aArg),
- handler(aHandler) {}
+ arg1(aArg),
+ handler(aHandler) {}
virtual bool canDial(AsyncCall &call) { return arg1.valid(); }
void dial(AsyncCall &call) { handler(arg1.get()); }
}
#endif
+
}
AsyncJob::AsyncJob(const char *aTypeName) :
- stopReason(NULL), typeName(aTypeName), inCall(NULL)
+ stopReason(NULL), typeName(aTypeName), inCall(NULL)
{
debugs(93,5, "AsyncJob constructed, this=" << this <<
" type=" << typeName << " [" << id << ']');
};
#endif /* SQUID_ASYNC_JOB_H */
+
public:
typedef void (Job::*Method)();
explicit NullaryMemFunT(const CbcPointer<Job> &aJob, Method aMethod):
- JobDialer<Job>(aJob), method(aMethod) {}
+ JobDialer<Job>(aJob), method(aMethod) {}
virtual void print(std::ostream &os) const { os << "()"; }
typedef void (Job::*Method)(Argument1);
explicit UnaryMemFunT(const CbcPointer<Job> &aJob, Method aMethod,
const Data &anArg1): JobDialer<Job>(aJob),
- method(aMethod), arg1(anArg1) {}
+ method(aMethod), arg1(anArg1) {}
virtual void print(std::ostream &os) const { os << '(' << arg1 << ')'; }
}
#endif /* SQUID_ASYNCJOBCALLS_H */
+
}
#endif /* SQUID_CBDATALIST_H */
+
}
#endif /* SQUID_CBC_POINTER_H */
+
}
CharacterSet::CharacterSet(const char *label, const char * const c) :
- name(label == NULL ? "anonymous" : label),
- chars_(Storage(256,0))
+ name(label == NULL ? "anonymous" : label),
+ chars_(Storage(256,0))
{
const size_t clen = strlen(c);
for (size_t i = 0; i < clen; ++i)
}
CharacterSet::CharacterSet(const char *label, unsigned char low, unsigned char high) :
- name(label == NULL ? "anonymous" : label),
- chars_(Storage(256,0))
+ name(label == NULL ? "anonymous" : label),
+ chars_(Storage(256,0))
{
addRange(low,high);
}
const CharacterSet
// RFC 5234
CharacterSet::ALPHA("ALPHA", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
-CharacterSet::BIT("BIT","01"),
-CharacterSet::CR("CR","\r"),
+ CharacterSet::BIT("BIT","01"),
+ CharacterSet::CR("CR","\r"),
#if __cplusplus == 201103L
//CharacterSet::CTL("CTL",{{0x01,0x1f},{0x7f,0x7f}}),
#endif
-CharacterSet::DIGIT("DIGIT","0123456789"),
-CharacterSet::DQUOTE("DQUOTE","\""),
-CharacterSet::HEXDIG("HEXDIG","0123456789aAbBcCdDeEfF"),
-CharacterSet::HTAB("HTAB","\t"),
-CharacterSet::LF("LF","\n"),
-CharacterSet::SP("SP"," "),
-CharacterSet::VCHAR("VCHAR", 0x21, 0x7e),
+ CharacterSet::DIGIT("DIGIT","0123456789"),
+ CharacterSet::DQUOTE("DQUOTE","\""),
+ CharacterSet::HEXDIG("HEXDIG","0123456789aAbBcCdDeEfF"),
+ CharacterSet::HTAB("HTAB","\t"),
+ CharacterSet::LF("LF","\n"),
+ CharacterSet::SP("SP"," "),
+ CharacterSet::VCHAR("VCHAR", 0x21, 0x7e),
// RFC 7230
-CharacterSet::WSP("WSP"," \t"),
+ CharacterSet::WSP("WSP"," \t"),
#if __cplusplus == 201103L
//CharacterSet::CTEXT("ctext",{{0x09,0x09},{0x20,0x20},{0x2a,0x5b},{0x5d,0x7e},{0x80,0xff}}),
#endif
-CharacterSet::TCHAR("TCHAR","!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
-CharacterSet::SPECIAL("SPECIAL","()<>@,;:\\\"/[]?={}"),
+ CharacterSet::TCHAR("TCHAR","!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+ CharacterSet::SPECIAL("SPECIAL","()<>@,;:\\\"/[]?={}"),
#if __cplusplus == 201103L
//CharacterSet::QDTEXT("QDTEXT",{{0x09,0x09},{0x20,0x21},{0x23,0x5b},{0x5d,0x7e},{0x80,0xff}}),
#endif
-CharacterSet::OBSTEXT("OBSTEXT",0x80,0xff),
+ CharacterSet::OBSTEXT("OBSTEXT",0x80,0xff),
// RFC 7232
#if __cplusplus == 201103L
//CharacterSet::ETAGC("ETAGC",{{0x21,0x21},{0x23,0x7e},{0x80,0xff}}),
#endif
// RFC 7235
-CharacterSet::TOKEN68C("TOKEN68C","-._~+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
-;
+ CharacterSet::TOKEN68C("TOKEN68C","-._~+/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ ;
+
};
#endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */
+
}
#endif /* SQUID_BASE_INSTANCE_ID_H */
+
#define RefCountable virtual Lock
#endif /* SQUID_SRC_BASE_LOCK_H */
+
}
#endif /* SQUID_REFCOUNT_H_ */
+
UseThisStatic(& Who ## _Registered_);
#endif /* SQUID_BASE_RUNNERSREGISTRY_H */
+
};
#endif /* _SQUID_BASE_SUBSCRIPTION_H */
+
}
TextException::TextException(const TextException& right) :
- message((right.message?xstrdup(right.message):NULL)), theFileName(right.theFileName), theLineNo(right.theLineNo), theId(right.theId)
+ message((right.message?xstrdup(right.message):NULL)), theFileName(right.theFileName), theLineNo(right.theLineNo), theId(right.theId)
{
}
TextException::TextException(const char *aMsg, const char *aFileName, int aLineNo, unsigned int anId):
- message(aMsg?xstrdup(aMsg):NULL), theFileName(aFileName), theLineNo(aLineNo), theId(anId)
+ message(aMsg?xstrdup(aMsg):NULL), theFileName(aFileName), theLineNo(aLineNo), theId(anId)
{}
TextException::~TextException() throw()
throw TextException(message, fileName, lineNo, id);
}
+
#endif
#endif /* SQUID__TEXTEXCEPTION_H */
+
/// Delete callback.
typedef void DCB (T *t);
TidyPointer(T *t = NULL)
- : raw(t) {}
+ : raw(t) {}
public:
bool operator !() const { return !raw; }
/// Returns raw and possibly NULL pointer
}
#endif // SQUID_BASE_TIDYPOINTER_H
+
CPPUNIT_ASSERT_EQUAL(CharacterSet::HEXDIG[j],hex[j]);
}
}
+
};
#endif /* SQUID_BASE_TESTCHARACTERSET_H */
+
new_lineno = strtol(token, &file, 0) - 1;
if (file == token)
- continue; /* Not a valid #line directive, may be a comment */
+ continue; /* Not a valid #line directive, may be a comment */
while (*file && xisspace((unsigned char) *file))
++file;
if (*file) {
if (*file != '"')
- continue; /* Not a valid #line directive, may be a comment */
+ continue; /* Not a valid #line directive, may be a comment */
xstrncpy(new_file_name, file + 1, sizeof(new_file_name));
if (Config.Announce.period > 0) {
Config.onoff.announce = 1;
} else {
- Config.Announce.period = 86400 * 365; /* one year */
+ Config.Announce.period = 86400 * 365; /* one year */
Config.onoff.announce = 0;
}
d = xatof(token);
- m = u; /* default to 'units' if none specified */
+ m = u; /* default to 'units' if none specified */
bool hasUnits = false;
if (0 == d)
d = xatof(token);
- m = u; /* default to 'units' if none specified */
+ m = u; /* default to 'units' if none specified */
if (0.0 == d)
(void) 0;
d = xatof(token);
- m = u; /* default to 'units' if none specified */
+ m = u; /* default to 'units' if none specified */
if (0.0 == d)
(void) 0;
d = xatof(token);
- m = u; /* default to 'units' if none specified */
+ m = u; /* default to 'units' if none specified */
if (0.0 == d)
(void) 0;
parse_acl_address(AclAddress ** head)
{
AclAddress *l;
- AclAddress **tail = head; /* sane name below */
+ AclAddress **tail = head; /* sane name below */
CBDATA_INIT_TYPE_FREECB(AclAddress, freed_acl_address);
l = cbdataAlloc(AclAddress);
parse_address(&l->addr);
parse_acl_tos(acl_tos ** head)
{
acl_tos *l;
- acl_tos **tail = head; /* sane name below */
+ acl_tos **tail = head; /* sane name below */
unsigned int tos; /* Initially uint for strtoui. Casted to tos_t before return */
char *token = ConfigParser::NextToken();
parse_acl_nfmark(acl_nfmark ** head)
{
acl_nfmark *l;
- acl_nfmark **tail = head; /* sane name below */
+ acl_nfmark **tail = head; /* sane name below */
nfmark_t mark;
char *token = ConfigParser::NextToken();
parse_acl_b_size_t(AclSizeLimit ** head)
{
AclSizeLimit *l;
- AclSizeLimit **tail = head; /* sane name below */
+ AclSizeLimit **tail = head; /* sane name below */
CBDATA_INIT_TYPE_FREECB(AclSizeLimit, freed_acl_b_size_t);
}
/**
- \param proto 'tcp' or 'udp' for protocol
+ \param proto 'tcp' or 'udp' for protocol
\returns Port the named service is supposed to be listening on.
*/
static unsigned short
l = static_cast<CachePeerDomainList *>(xcalloc(1, sizeof(CachePeerDomainList)));
l->do_ping = true;
- if (*domain == '!') { /* check for !.edu */
+ if (*domain == '!') { /* check for !.edu */
l->do_ping = false;
++domain;
}
pattern = xstrdup(token);
- i = GetInteger(); /* token: min */
+ i = GetInteger(); /* token: min */
/* catch negative and insanely huge values close to 32-bit wrap */
if (i < 0) {
i = 60*24*365;
}
- min = (time_t) (i * 60); /* convert minutes to seconds */
+ min = (time_t) (i * 60); /* convert minutes to seconds */
- i = GetPercentage(); /* token: pct */
+ i = GetPercentage(); /* token: pct */
pct = (double) i / 100.0;
- i = GetInteger(); /* token: max */
+ i = GetInteger(); /* token: max */
/* catch negative and insanely huge values close to 32-bit wrap */
if (i < 0) {
i = 60*24*365;
}
- max = (time_t) (i * 60); /* convert minutes to seconds */
+ max = (time_t) (i * 60); /* convert minutes to seconds */
/* Options */
while ((token = ConfigParser::NextToken()) != NULL) {
ConfigParser::RecognizeQuotedValues = false;
ConfigParser::StrictMode = false;
}
+
char *strtokFile(void);
#endif /* SQUID_CACHE_CF_H_ */
+
typedef struct {
const char *name;
hash_table *hash;
- int count; /* #currently cached entries */
- int scanned_count; /* #scanned entries */
- int bad_add_count; /* #duplicate adds */
- int bad_del_count; /* #dels with no prior add */
+ int count; /* #currently cached entries */
+ int scanned_count; /* #scanned entries */
+ int bad_add_count; /* #duplicate adds */
+ int bad_del_count; /* #dels with no prior add */
} CacheIndex;
typedef struct _CacheEntry {
return 1;
}
+
/**
\ingroup CacheManagerInternal
*
- \retval 0 if mgr->password is good or "none"
- \retval 1 if mgr->password is "disable"
- \retval !0 if mgr->password does not match configured password
+ \retval 0 if mgr->password is good or "none"
+ \retval 1 if mgr->password is "disable"
+ \retval !0 if mgr->password does not match configured password
*/
int
CacheManager::CheckPassword(const Mgr::Command &cmd)
}
return instance;
}
+
*/
K = n_carp_peers;
- P_last = 0.0; /* Empty P_0 */
+ P_last = 0.0; /* Empty P_0 */
- Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
+ Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
- X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
+ X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
for (k = 1; k <= K; ++k) {
double Kk1 = (double) (K - k + 1);
sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);
}
}
+
CachePeer *carpSelectParent(HttpRequest *);
#endif /* SQUID_CARP_H_ */
+
* safe access to data - RBC 20030902 */
public:
#if HASHED_CBDATA
- hash_link hash; // Must be first
+ hash_link hash; // Must be first
#endif
#if USE_CBDATA_DEBUG
cbdata *c;
if (p == NULL)
- return 1; /* A NULL pointer cannot become invalid */
+ return 1; /* A NULL pointer cannot become invalid */
debugs(45, 9, p);
}
#endif
+
*
\section Examples Examples
\par
- * Here you can find some examples on how to use cbdata, and why.
+ * Here you can find some examples on how to use cbdata, and why.
*
\subsection AsyncOpWithoutCBDATA Asynchronous operation without cbdata, showing why cbdata is needed
\par
- * For a asyncronous operation with callback functions, the normal
- * sequence of events in programs NOT using cbdata is as follows:
+ * For a asyncronous operation with callback functions, the normal
+ * sequence of events in programs NOT using cbdata is as follows:
*
\code
- // initialization
- type_of_data our_data;
- ...
- our_data = malloc(...);
- ...
- // Initiate a asyncronous operation, with our_data as callback_data
- fooOperationStart(bar, callback_func, our_data);
- ...
- // The asyncronous operation completes and makes the callback
- callback_func(callback_data, ....);
- // Some time later we clean up our data
- free(our_data);
+ // initialization
+ type_of_data our_data;
+ ...
+ our_data = malloc(...);
+ ...
+ // Initiate a asyncronous operation, with our_data as callback_data
+ fooOperationStart(bar, callback_func, our_data);
+ ...
+ // The asyncronous operation completes and makes the callback
+ callback_func(callback_data, ....);
+ // Some time later we clean up our data
+ free(our_data);
\endcode
*
\par
- * However, things become more interesting if we want or need
- * to free the callback_data, or otherwise cancel the callback,
- * before the operation completes. In constructs like this you
- * can quite easily end up with having the memory referenced
- * pointed to by callback_data freed before the callback is invoked
- * causing a program failure or memory corruption:
+ * However, things become more interesting if we want or need
+ * to free the callback_data, or otherwise cancel the callback,
+ * before the operation completes. In constructs like this you
+ * can quite easily end up with having the memory referenced
+ * pointed to by callback_data freed before the callback is invoked
+ * causing a program failure or memory corruption:
*
\code
- // initialization
- type_of_data our_data;
- ...
- our_data = malloc(...);
- ...
- // Initiate a asyncronous operation, with our_data as callback_data
- fooOperationStart(bar, callback_func, our_data);
- ...
- // ouch, something bad happened elsewhere.. try to cleanup
- // but the programmer forgot there is a callback pending from
- // fooOperationsStart() (an easy thing to forget when writing code
- // to deal with errors, especially if there may be many different
- // pending operation)
- free(our_data);
- ...
- // The asyncronous operation completes and makes the callback
- callback_func(callback_data, ....);
- // CRASH, the memory pointer to by callback_data is no longer valid
- // at the time of the callback
+ // initialization
+ type_of_data our_data;
+ ...
+ our_data = malloc(...);
+ ...
+ // Initiate a asyncronous operation, with our_data as callback_data
+ fooOperationStart(bar, callback_func, our_data);
+ ...
+ // ouch, something bad happened elsewhere.. try to cleanup
+ // but the programmer forgot there is a callback pending from
+ // fooOperationsStart() (an easy thing to forget when writing code
+ // to deal with errors, especially if there may be many different
+ // pending operation)
+ free(our_data);
+ ...
+ // The asyncronous operation completes and makes the callback
+ callback_func(callback_data, ....);
+ // CRASH, the memory pointer to by callback_data is no longer valid
+ // at the time of the callback
\endcode
*
\subsection AsyncOpWithCBDATA Asyncronous operation with cbdata
*
\par
- * The callback data allocator lets us do this in a uniform and
- * safe manner. The callback data allocator is used to allocate,
- * track and free memory pool objects used during callback
- * operations. Allocated memory is locked while the asyncronous
- * operation executes elsewhere, and is freed when the operation
- * completes. The normal sequence of events is:
+ * The callback data allocator lets us do this in a uniform and
+ * safe manner. The callback data allocator is used to allocate,
+ * track and free memory pool objects used during callback
+ * operations. Allocated memory is locked while the asyncronous
+ * operation executes elsewhere, and is freed when the operation
+ * completes. The normal sequence of events is:
*
\code
- // initialization
- type_of_data our_data;
- ...
- our_data = cbdataAlloc(type_of_data);
- ...
- // Initiate a asyncronous operation, with our_data as callback_data
- fooOperationStart(..., callback_func, our_data);
- ...
- // foo
- void *local_pointer = cbdataReference(callback_data);
- ....
- // The asyncronous operation completes and makes the callback
- void *cbdata;
- if (cbdataReferenceValidDone(local_pointer, &cbdata))
- callback_func(...., cbdata);
- ...
- cbdataFree(our_data);
+ // initialization
+ type_of_data our_data;
+ ...
+ our_data = cbdataAlloc(type_of_data);
+ ...
+ // Initiate a asyncronous operation, with our_data as callback_data
+ fooOperationStart(..., callback_func, our_data);
+ ...
+ // foo
+ void *local_pointer = cbdataReference(callback_data);
+ ....
+ // The asyncronous operation completes and makes the callback
+ void *cbdata;
+ if (cbdataReferenceValidDone(local_pointer, &cbdata))
+ callback_func(...., cbdata);
+ ...
+ cbdataFree(our_data);
\endcode
*
\subsection AsynchronousOpCancelledByCBDATA Asynchronous operation cancelled by cbdata
*
\par
- * With this scheme, nothing bad happens if cbdataFree() gets called
- * before fooOperantionComplete(...).
+ * With this scheme, nothing bad happens if cbdataFree() gets called
+ * before fooOperantionComplete(...).
*
- \par Initalization
+ \par Initalization
\code
- type_of_data our_data;
- ...
- our_data = cbdataAlloc(type_of_data);
+ type_of_data our_data;
+ ...
+ our_data = cbdataAlloc(type_of_data);
\endcode
- * Initiate a asyncronous operation, with our_data as callback_data
+ * Initiate a asyncronous operation, with our_data as callback_data
\code
- fooOperationStart(..., callback_func, our_data);
+ fooOperationStart(..., callback_func, our_data);
\endcode
- * do some stuff with it
+ * do some stuff with it
\code
- void *local_pointer = cbdataReference(callback_data);
+ void *local_pointer = cbdataReference(callback_data);
\endcode
- * something bad happened elsewhere.. cleanup
+ * something bad happened elsewhere.. cleanup
\code
- cbdataFree(our_data);
+ cbdataFree(our_data);
\endcode
- * The asyncronous operation completes and tries to make the callback
+ * The asyncronous operation completes and tries to make the callback
\code
- void *cbdata;
- if (cbdataReferenceValidDone(local_pointer, &cbdata))
+ void *cbdata;
+ if (cbdataReferenceValidDone(local_pointer, &cbdata))
{
\endcode
- * won't be called, as the data is no longer valid
+ * won't be called, as the data is no longer valid
\code
- callback_func(...., cbdata);
- }
+ callback_func(...., cbdata);
+ }
\endcode
*
\par
- * In this case, when cbdataFree() is called before
- * cbdataReferenceValidDone(), the callback_data gets marked as invalid.
- * When the callback_data is invalid before executing the callback
- * function, cbdataReferenceValidDone() will return 0 and
- * callback_func is never executed.
+ * In this case, when cbdataFree() is called before
+ * cbdataReferenceValidDone(), the callback_data gets marked as invalid.
+ * When the callback_data is invalid before executing the callback
+ * function, cbdataReferenceValidDone() will return 0 and
+ * callback_func is never executed.
*
\subsection AddingCBDATAType Adding a new cbdata registered type
*
\par
- * To add new module specific data types to the allocator one uses the
- * macro CBDATA_CLASS() in the class private section, and CBDATA_CLASS_INIT()
+ * To add new module specific data types to the allocator one uses the
+ * macro CBDATA_CLASS() in the class private section, and CBDATA_CLASS_INIT()
* or CBDATA_NAMESPACED_CLASS_INIT() in the .cc file.
* This creates new(), delete() and toCbdata() methods
- * definition in class scope. Any allocate calls must be made with
+ * definition in class scope. Any allocate calls must be made with
* new() and destruction with delete(), they may be called from anywhere.
*/
*/
void *cbdataInternalFree(void *p, const char *, int);
/// \deprecated use CBDATA_CLASS() instead
-#define cbdataFree(var) do {if (var) {cbdataInternalFree(var,__FILE__,__LINE__); var = NULL;}} while(0)
+#define cbdataFree(var) do {if (var) {cbdataInternalFree(var,__FILE__,__LINE__); var = NULL;}} while(0)
#if USE_CBDATA_DEBUG
void cbdataInternalLockDbg(const void *p, const char *, int);
-#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__)
+#define cbdataInternalLock(a) cbdataInternalLockDbg(a,__FILE__,__LINE__)
void cbdataInternalUnlockDbg(const void *p, const char *, int);
-#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__)
+#define cbdataInternalUnlock(a) cbdataInternalUnlockDbg(a,__FILE__,__LINE__)
int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int);
#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValidDbg((void **)&(var), (ptr), __FILE__,__LINE__)
callback(..., cbdata);
\endcode
*
- \param var The reference variable. Will be automatically cleared to NULL.
- \param ptr A temporary pointer to the referenced data (if valid).
+ \param var The reference variable. Will be automatically cleared to NULL.
+ \param ptr A temporary pointer to the referenced data (if valid).
*/
int cbdataInternalReferenceDoneValid(void **p, void **tp);
#define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr))
#endif /* !CBDATA_DEBUG */
/**
- * \param p A cbdata entry reference pointer.
+ * \param p A cbdata entry reference pointer.
*
- * \retval 0 A reference is stale. The pointer refers to a entry freed by cbdataFree().
- * \retval true The reference is valid and active.
+ * \retval 0 A reference is stale. The pointer refers to a entry freed by cbdataFree().
+ * \retval true The reference is valid and active.
*/
int cbdataReferenceValid(const void *p);
* This needs to be defined FIRST in the class definition.
* It plays with private/public states in C++.
*/
-#define CBDATA_CLASS(type) \
- public: \
- void *operator new(size_t size) { \
- assert(size == sizeof(type)); \
- if (!CBDATA_##type) \
+#define CBDATA_CLASS(type) \
+ public: \
+ void *operator new(size_t size) { \
+ assert(size == sizeof(type)); \
+ if (!CBDATA_##type) \
CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), NULL); \
- return (type *)cbdataInternalAlloc(CBDATA_##type,__FILE__,__LINE__); \
- } \
- void operator delete (void *address) { \
- if (address) cbdataInternalFree(address,__FILE__,__LINE__);\
- } \
+ return (type *)cbdataInternalAlloc(CBDATA_##type,__FILE__,__LINE__); \
+ } \
+ void operator delete (void *address) { \
+ if (address) cbdataInternalFree(address,__FILE__,__LINE__);\
+ } \
void *toCbdata() { return this; } \
- private: \
- static cbdata_type CBDATA_##type;
+ private: \
+ static cbdata_type CBDATA_##type;
/**
\par
* is quite different. It is best if the reference is thought of
* and handled as a "void *".
*/
-#define cbdataReference(var) (cbdataInternalLock(var), var)
+#define cbdataReference(var) (cbdataInternalLock(var), var)
/**
\ingroup CBDATAAPI
* Removes a reference created by cbdataReference().
*
- \param var The reference variable. Will be automatically cleared to NULL.
+ \param var The reference variable. Will be automatically cleared to NULL.
*/
#define cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = NULL;}} while(0)
* restrictions on scope.
* \deprecated Use CBDATA_CLASS() instead
*/
-#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = CBDATA_UNKNOWN
+#define CBDATA_TYPE(type) static cbdata_type CBDATA_##type = CBDATA_UNKNOWN
/**
\ingroup CBDATAAPI
\par
* Alternative to CBDATA_INIT_TYPE()
*
- \param type Type being initialized
- \param free_func The freehandler called when the last known reference to an allocated entry goes away.
+ \param type Type being initialized
+ \param free_func The freehandler called when the last known reference to an allocated entry goes away.
*/
#define CBDATA_INIT_TYPE_FREECB(type, free_func) do { if (!CBDATA_##type) CBDATA_##type = cbdataInternalAddType(CBDATA_##type, #type, sizeof(type), free_func); } while (false)
\par
* Alternative to CBDATA_INIT_TYPE_FREECB()
*
- \param type Type being initialized
+ \param type Type being initialized
*
* \deprecated Use CBDATA_CLASS() instead
*/
-#define CBDATA_INIT_TYPE(type) CBDATA_INIT_TYPE_FREECB(type, NULL)
+#define CBDATA_INIT_TYPE(type) CBDATA_INIT_TYPE_FREECB(type, NULL)
/**
\ingroup CBDATA
};
#endif /* SQUID_CBDATA_H */
+
/* DEBUG: none Generate squid.conf.default and cf_parser.cci */
/*****************************************************************************
- * Abstract: This program parses the input file and generates code and
- * files used to configure the variables in squid.
- * (ie it creates the squid.conf.default file from the cf.data file)
+ * Abstract: This program parses the input file and generates code and
+ * files used to configure the variables in squid.
+ * (ie it creates the squid.conf.default file from the cf.data file)
*
- * The output files are as follows:
- * cf_parser.cci - this file contains, default_all() which
- * initializes variables with the default
- * values, parse_line() that parses line from
- * squid.conf.default, dump_config that dumps the
- * current the values of the variables.
- * squid.conf.default - default configuration file given to the server
- * administrator.
+ * The output files are as follows:
+ * cf_parser.cci - this file contains, default_all() which
+ * initializes variables with the default
+ * values, parse_line() that parses line from
+ * squid.conf.default, dump_config that dumps the
+ * current the values of the variables.
+ * squid.conf.default - default configuration file given to the server
+ * administrator.
*****************************************************************************/
/*
#include "cf_gen_defines.cci"
-#define MAX_LINE 1024 /* longest configuration line */
-#define _PATH_PARSER "cf_parser.cci"
-#define _PATH_SQUID_CONF "squid.conf.documented"
-#define _PATH_SQUID_CONF_SHORT "squid.conf.default"
-#define _PATH_CF_DEPEND "cf.data.depend"
+#define MAX_LINE 1024 /* longest configuration line */
+#define _PATH_PARSER "cf_parser.cci"
+#define _PATH_SQUID_CONF "squid.conf.documented"
+#define _PATH_SQUID_CONF_SHORT "squid.conf.default"
+#define _PATH_CF_DEPEND "cf.data.depend"
enum State {
sSTART,
{
public:
Entry(const char *str) :
- name(str), alias(),type(), loc(),
- defaults(), comment(), ifdef(), doc(), nocomment(),
- array_flag(0) {}
+ name(str), alias(),type(), loc(),
+ defaults(), comment(), ifdef(), doc(), nocomment(),
+ array_flag(0) {}
~Entry() {}
std::string name;
break;
case sEXIT:
- assert(0); /* should never get here */
+ assert(0); /* should never get here */
break;
}
}
fout << "/*\n" <<
- " * Generated automatically from " << input_filename << " by " <<
- argv[0] << "\n"
- " *\n"
- " * Abstract: This file contains routines used to configure the\n"
- " * variables in the squid server.\n"
- " */\n"
- "\n";
+ " * Generated automatically from " << input_filename << " by " <<
+ argv[0] << "\n"
+ " *\n"
+ " * Abstract: This file contains routines used to configure the\n"
+ " * variables in the squid server.\n"
+ " */\n"
+ "\n";
rc = gen_default(entries, fout);
{
int rc = 0;
fout << "static void" << std::endl <<
- "default_line(const char *s)" << std::endl <<
- "{" << std::endl <<
- " LOCAL_ARRAY(char, tmp_line, BUFSIZ);" << std::endl <<
- " xstrncpy(tmp_line, s, BUFSIZ);" << std::endl <<
- " xstrncpy(config_input_line, s, BUFSIZ);" << std::endl <<
- " config_lineno++;" << std::endl <<
- " parse_line(tmp_line);" << std::endl <<
- "}" << std::endl << std::endl;
+ "default_line(const char *s)" << std::endl <<
+ "{" << std::endl <<
+ " LOCAL_ARRAY(char, tmp_line, BUFSIZ);" << std::endl <<
+ " xstrncpy(tmp_line, s, BUFSIZ);" << std::endl <<
+ " xstrncpy(config_input_line, s, BUFSIZ);" << std::endl <<
+ " config_lineno++;" << std::endl <<
+ " parse_line(tmp_line);" << std::endl <<
+ "}" << std::endl << std::endl;
fout << "static void" << std::endl <<
- "default_all(void)" << std::endl <<
- "{" << std::endl <<
- " cfg_filename = \"Default Configuration\";" << std::endl <<
- " config_lineno = 0;" << std::endl;
+ "default_all(void)" << std::endl <<
+ "{" << std::endl <<
+ " cfg_filename = \"Default Configuration\";" << std::endl <<
+ " config_lineno = 0;" << std::endl;
for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
assert(entry->name.size());
}
fout << " cfg_filename = NULL;" << std::endl <<
- "}" << std::endl << std::endl;
+ "}" << std::endl << std::endl;
return rc;
}
gen_default_if_none(const EntryList &head, std::ostream &fout)
{
fout << "static void" << std::endl <<
- "defaults_if_none(void)" << std::endl <<
- "{" << std::endl <<
- " cfg_filename = \"Default Configuration (if absent)\";" << std::endl <<
- " config_lineno = 0;" << std::endl;
+ "defaults_if_none(void)" << std::endl <<
+ "{" << std::endl <<
+ " cfg_filename = \"Default Configuration (if absent)\";" << std::endl <<
+ " config_lineno = 0;" << std::endl;
for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
assert(entry->name.size());
}
fout << " cfg_filename = NULL;" << std::endl <<
- "}" << std::endl << std::endl;
+ "}" << std::endl << std::endl;
}
/// append configuration options specified by POSTSCRIPTUM lines
gen_default_postscriptum(const EntryList &head, std::ostream &fout)
{
fout << "static void" << std::endl <<
- "defaults_postscriptum(void)" << std::endl <<
- "{" << std::endl <<
- " cfg_filename = \"Default Configuration (postscriptum)\";" << std::endl <<
- " config_lineno = 0;" << std::endl;
+ "defaults_postscriptum(void)" << std::endl <<
+ "{" << std::endl <<
+ " cfg_filename = \"Default Configuration (postscriptum)\";" << std::endl <<
+ " config_lineno = 0;" << std::endl;
for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
assert(entry->name.size());
}
fout << " cfg_filename = NULL;" << std::endl <<
- "}" << std::endl << std::endl;
+ "}" << std::endl << std::endl;
}
void
fout << " cfg_directive = NULL;" << std::endl;
if (ifdef.size()) {
fout <<
- "#else" << std::endl <<
- " debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), \"ERROR: '" << name << "' requires " << available_if(ifdef) << "\");" << std::endl <<
- "#endif" << std::endl;
+ "#else" << std::endl <<
+ " debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT), \"ERROR: '" << name << "' requires " << available_if(ifdef) << "\");" << std::endl <<
+ "#endif" << std::endl;
}
fout << " return 1;" << std::endl;
fout << " };" << std::endl;
gen_parse(const EntryList &head, std::ostream &fout)
{
fout <<
- "static int\n"
- "parse_line(char *buff)\n"
- "{\n"
- "\tchar\t*token;\n"
- "\tif ((token = strtok(buff, w_space)) == NULL) \n"
- "\t\treturn 1;\t/* ignore empty lines */\n"
- "\tConfigParser::SetCfgLine(strtok(NULL, \"\"));\n";
+ "static int\n"
+ "parse_line(char *buff)\n"
+ "{\n"
+ "\tchar\t*token;\n"
+ "\tif ((token = strtok(buff, w_space)) == NULL) \n"
+ "\t\treturn 1;\t/* ignore empty lines */\n"
+ "\tConfigParser::SetCfgLine(strtok(NULL, \"\"));\n";
for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e)
e->genParse(fout);
fout << "\treturn 0; /* failure */\n"
- "}\n\n";
+ "}\n\n";
}
gen_dump(const EntryList &head, std::ostream &fout)
{
fout <<
- "static void" << std::endl <<
- "dump_config(StoreEntry *entry)" << std::endl <<
- "{" << std::endl <<
- " debugs(5, 4, HERE);" << std::endl;
+ "static void" << std::endl <<
+ "dump_config(StoreEntry *entry)" << std::endl <<
+ "{" << std::endl <<
+ " debugs(5, 4, HERE);" << std::endl;
for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e) {
gen_free(const EntryList &head, std::ostream &fout)
{
fout <<
- "static void" << std::endl <<
- "free_all(void)" << std::endl <<
- "{" << std::endl <<
- " debugs(5, 4, HERE);" << std::endl;
+ "static void" << std::endl <<
+ "free_all(void)" << std::endl <<
+ "{" << std::endl <<
+ " debugs(5, 4, HERE);" << std::endl;
for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e) {
if (!e->loc.size() || e->loc.compare("none") == 0)
if (!isDefined(entry->ifdef)) {
if (verbose_output) {
fout << "# Note: This option is only available if Squid is rebuilt with the" << std::endl <<
- "# " << available_if(entry->ifdef) << std::endl <<
- "#" << std::endl;
+ "# " << available_if(entry->ifdef) << std::endl <<
+ "#" << std::endl;
}
enabled = 0;
}
return esc.c_str();
}
+
\ingroup ClientStreamInternal
* Call the previous node in the chain to read some data
*
- \param thisObject ??
- \param http ??
- \param readBuffer ??
+ \param thisObject ??
+ \param http ??
+ \param readBuffer ??
*/
void
clientStreamRead(clientStreamNode * thisObject, ClientHttpRequest * http,
\ingroup ClientStreamInternal
* Detach from the stream - only allowed for terminal members
*
- \param thisObject ??
- \param http ??
+ \param thisObject ??
+ \param http ??
*/
void
clientStreamDetach(clientStreamNode * thisObject, ClientHttpRequest * http)
\ingroup ClientStreamInternal
* Abort the stream - detach every node in the pipeline.
*
- \param thisObject ??
- \param http ??
+ \param thisObject ??
+ \param http ??
*/
void
clientStreamAbort(clientStreamNode * thisObject, ClientHttpRequest * http)
\ingroup ClientStreamInternal
* Call the upstream node to find it's status
*
- \param thisObject ??
- \param http ??
+ \param thisObject ??
+ \param http ??
*/
clientStream_status_t
clientStreamStatus(clientStreamNode * thisObject, ClientHttpRequest * http)
else
return NULL;
}
+
*
\todo ClientStreams: These details should really be codified as a class which all ClientStream nodes inherit from.
*
- \par Each node must have:
- \li read method - to allow loose coupling in the pipeline. (The reader may
+ \par Each node must have:
+ \li read method - to allow loose coupling in the pipeline. (The reader may
therefore change if the pipeline is altered, even mid-flow).
- \li callback method - likewise.
- \li status method - likewise.
- \li detach method - used to ensure all resources are cleaned up properly.
- \li dlink head pointer - to allow list inserts and deletes from within a node.
- \li context data - to allow the called back nodes to maintain their private information.
- \li read request parameters - For two reasons:
- \li To allow a node to determine the requested data offset, length and target buffer dynamically. Again, this is to promote loose coupling.
- \li Because of the callback nature of squid, every node would have to keep these parameters in their context anyway, so this reduces programmer overhead.
+ \li callback method - likewise.
+ \li status method - likewise.
+ \li detach method - used to ensure all resources are cleaned up properly.
+ \li dlink head pointer - to allow list inserts and deletes from within a node.
+ \li context data - to allow the called back nodes to maintain their private information.
+ \li read request parameters - For two reasons:
+ \li To allow a node to determine the requested data offset, length and target buffer dynamically. Again, this is to promote loose coupling.
+ \li Because of the callback nature of squid, every node would have to keep these parameters in their context anyway, so this reduces programmer overhead.
*/
/// \ingroup ClientStreamAPI
clientStreamNode *next() const;
void removeFromStream();
dlink_node node;
- dlink_list *head; /* sucks I know, but hey, the interface is limited */
+ dlink_list *head; /* sucks I know, but hey, the interface is limited */
CSR *readfunc;
CSCB *callback;
- CSD *detach; /* tell this node the next one downstream wants no more data */
+ CSD *detach; /* tell this node the next one downstream wants no more data */
CSS *status;
- ClientStreamData data; /* Context for the node */
- StoreIOBuffer readBuffer; /* what, where and how much this node wants */
+ ClientStreamData data; /* Context for the node */
+ StoreIOBuffer readBuffer; /* what, where and how much this node wants */
};
/// \ingroup ClientStreamAPI
* Return data to the next node in the stream.
* The data may be returned immediately, or may be delayed for a later scheduling cycle.
*
- \param thisObject 'this' reference for the client stream
- \param http Superset of request data, being winnowed down over time. MUST NOT be NULL.
- \param rep Not NULL on the first call back only. Ownership is passed down the pipeline.
- Each node may alter the reply if appropriate.
- \param replyBuffer - buffer, length - where and how much.
+ \param thisObject 'this' reference for the client stream
+ \param http Superset of request data, being winnowed down over time. MUST NOT be NULL.
+ \param rep Not NULL on the first call back only. Ownership is passed down the pipeline.
+ Each node may alter the reply if appropriate.
+ \param replyBuffer - buffer, length - where and how much.
*/
void clientStreamCallback(clientStreamNode *thisObject, ClientHttpRequest *http, HttpReply *rep, StoreIOBuffer replyBuffer);
* metainformation and (if appropriate) the offset,length and buffer
* parameters.
*
- \param thisObject 'this' reference for the client stream
- \param http Superset of request data, being winnowed down over time. MUST NOT be NULL.
- \param readBuffer - offset, length, buffer - what, how much and where.
+ \param thisObject 'this' reference for the client stream
+ \param http Superset of request data, being winnowed down over time. MUST NOT be NULL.
+ \param readBuffer - offset, length, buffer - what, how much and where.
*/
void clientStreamRead(clientStreamNode *thisObject, ClientHttpRequest *http, StoreIOBuffer readBuffer);
* This node MUST have cleaned up all context data, UNLESS scheduled callbacks will take care of that.
* Informs the prev node in the list of this nodes detachment.
*
- \param thisObject 'this' reference for the client stream
- \param http MUST NOT be NULL.
+ \param thisObject 'this' reference for the client stream
+ \param http MUST NOT be NULL.
*/
void clientStreamDetach(clientStreamNode *thisObject, ClientHttpRequest *http);
* Detachs the tail of the stream. CURRENTLY DOES NOT clean up the tail node data -
* this must be done separately. Thus Abort may ONLY be called by the tail node.
*
- \param thisObject 'this' reference for the client stream
- \param http MUST NOT be NULL.
+ \param thisObject 'this' reference for the client stream
+ \param http MUST NOT be NULL.
*/
void clientStreamAbort(clientStreamNode *thisObject, ClientHttpRequest *http);
\ingroup ClientStreamAPI
*
* Allows nodes to query the upstream nodes for :
- \li stream ABORTS - request cancelled for some reason. upstream will not accept further reads().
- \li stream COMPLETION - upstream has completed and will not accept further reads().
- \li stream UNPLANNED COMPLETION - upstream has completed, but not at a pre-planned location (used for keepalive checking), and will not accept further reads().
- \li stream NONE - no special status, further reads permitted.
+ \li stream ABORTS - request cancelled for some reason. upstream will not accept further reads().
+ \li stream COMPLETION - upstream has completed and will not accept further reads().
+ \li stream UNPLANNED COMPLETION - upstream has completed, but not at a pre-planned location (used for keepalive checking), and will not accept further reads().
+ \li stream NONE - no special status, further reads permitted.
*
- \param thisObject 'this' reference for the client stream
- \param http MUST NOT be NULL.
+ \param thisObject 'this' reference for the client stream
+ \param http MUST NOT be NULL.
*/
clientStream_status_t clientStreamStatus(clientStreamNode *thisObject, ClientHttpRequest *http);
#endif /* SQUID_CLIENTSTREAM_H */
+
typedef clientStream_status_t CSS(clientStreamNode *, ClientHttpRequest *);
#endif /* SQUID_CLIENTSTREAM_FORWARD_H */
+
}
#endif /*SQUID_SNMP */
+
#endif
#endif /* SQUID_CLIENT_DB_H_ */
+
public:
typedef void (*Handler)(AnyP::PortCfgPointer &portCfg, const Ipc::FdNoteId note, const Subscription::Pointer &sub);
ListeningStartedDialer(Handler aHandler, AnyP::PortCfgPointer &aPortCfg, const Ipc::FdNoteId note, const Subscription::Pointer &aSub):
- handler(aHandler), portCfg(aPortCfg), portTypeNote(note), sub(aSub) {}
+ handler(aHandler), portCfg(aPortCfg), portTypeNote(note), sub(aSub) {}
virtual void print(std::ostream &os) const {
startPrint(os) <<
- ", " << FdNote(portTypeNote) << " port=" << (void*)&portCfg << ')';
+ ", " << FdNote(portTypeNote) << " port=" << (void*)&portCfg << ')';
}
virtual bool canDial(AsyncCall &) const { return true; }
}
ClientSocketContext::ClientSocketContext(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq) :
- clientConnection(aConn),
- http(aReq),
- reply(NULL),
- next(NULL),
- writtenToSocket(0),
- mayUseConnection_ (false),
- connRegistered_ (false)
+ clientConnection(aConn),
+ http(aReq),
+ reply(NULL),
+ next(NULL),
+ writtenToSocket(0),
+ mayUseConnection_ (false),
+ connRegistered_ (false)
{
assert(http != NULL);
memset (reqbuf, '\0', sizeof (reqbuf));
{
debugs(33, 2, HERE << clientConnection);
flags.readMore = false;
- clientdbEstablished(clientConnection->remote, -1); /* decrement */
+ clientdbEstablished(clientConnection->remote, -1); /* decrement */
assert(areAllContextsForThisConnection());
freeAllContexts();
{
if (Config.maxRequestBodySize &&
bodyLength > Config.maxRequestBodySize)
- return 1; /* too large */
+ return 1; /* too large */
return 0;
}
if (http->multipartRangeRequest() && i->debt() == i->currentSpec()->length) {
assert(http->memObject());
clientPackRangeHdr(
- http->memObject()->getReply(), /* original reply */
- i->currentSpec(), /* current range */
- i->boundary, /* boundary, the same for all */
+ http->memObject()->getReply(), /* original reply */
+ i->currentSpec(), /* current range */
+ i->boundary, /* boundary, the same for all */
mb);
}
(rep_tag.str ? rep_tag.str : "<none>"));
if (!rep_tag.str)
- return 0; /* entity has no etag to compare with! */
+ return 0; /* entity has no etag to compare with! */
if (spec.tag.weak || rep_tag.weak) {
debugs(33, DBG_IMPORTANT, "clientIfRangeMatch: Weak ETags are not allowed in If-Range: " << spec.tag.str << " ? " << rep_tag.str);
- return 0; /* must use strong validator for sub-range requests */
+ return 0; /* must use strong validator for sub-range requests */
}
return etagIsStrongEqual(rep_tag, spec.tag);
return http->storeEntry()->lastmod <= spec.time;
}
- assert(0); /* should not happen */
+ assert(0); /* should not happen */
return 0;
}
else if (rep->content_length < 0)
range_err = "unknown length";
else if (rep->content_length != http->memObject()->getReply()->content_length)
- range_err = "INCONSISTENT length"; /* a bug? */
+ range_err = "INCONSISTENT length"; /* a bug? */
/* hits only - upstream CachePeer determines correct behaviour on misses, and client_side_reply determines
* hits candidates
/* filter out data according to range specs */
assert (canPackMoreRanges());
{
- int64_t start; /* offset of still missing data */
+ int64_t start; /* offset of still missing data */
assert(http->range_iter.currentSpec());
start = http->range_iter.currentSpec()->offset + http->range_iter.currentSpec()->length - http->range_iter.debt();
debugs(33, 3, "clientPackMoreRanges: in: offset: " << http->out.offset);
" len: " << http->range_iter.currentSpec()->length <<
" debt: " << http->range_iter.debt());
if (http->range_iter.currentSpec()->length != -1)
- assert(http->out.offset <= start); /* we did not miss it */
+ assert(http->out.offset <= start); /* we did not miss it */
return start;
}
// skip the authority segment
// RFC 3986 complex nested ABNF for "authority" boils down to this:
static const CharacterSet authority = CharacterSet("authority","-._~%:@[]!$&'()*+,;=") +
- CharacterSet::HEXDIG + CharacterSet::ALPHA + CharacterSet::DIGIT;
+ CharacterSet::HEXDIG + CharacterSet::ALPHA + CharacterSet::DIGIT;
if (!tok.skipAll(authority))
break;
} else if (conn->port->defaultsite /* && !vhost */) {
debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: defaultsite=" << conn->port->defaultsite << " + vport=" << vport);
const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen +
- strlen(conn->port->defaultsite);
+ strlen(conn->port->defaultsite);
http->uri = (char *)xcalloc(url_sz, 1);
char vportStr[32];
vportStr[0] = '\0';
if (const char *host = hp->getHeaderField("Host")) {
const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen +
- strlen(host);
+ strlen(host);
http->uri = (char *)xcalloc(url_sz, 1);
snprintf(http->uri, url_sz, "%s://%s" SQUIDSBUFPH,
- AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, SQUIDSBUFPRINT(hp->requestUri()));
+ AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, SQUIDSBUFPRINT(hp->requestUri()));
debugs(33, 5, "TRANSPARENT HOST REWRITE: " << http->uri);
} else {
/* Put the local socket IP address as the hostname. */
/* Continue to process previously read data */
break;
- // case Comm::COMM_ERROR:
+ // case Comm::COMM_ERROR:
default: // no other flags should ever occur
debugs(33, 2, io.conn << ": got flag " << rd.flag << "; " << xstrerr(rd.xerrno));
notifyAllContexts(rd.xerrno);
}
ConnStateData::ConnStateData(const MasterXaction::Pointer &xact) :
- AsyncJob("ConnStateData"), // kids overwrite
- nrequests(0),
+ AsyncJob("ConnStateData"), // kids overwrite
+ nrequests(0),
#if USE_OPENSSL
- sslBumpMode(Ssl::bumpEnd),
+ sslBumpMode(Ssl::bumpEnd),
#endif
- needProxyProtocolHeader_(false),
+ needProxyProtocolHeader_(false),
#if USE_OPENSSL
- switchedToHttps_(false),
- sslServerBump(NULL),
- signAlgorithm(Ssl::algSignTrusted),
+ switchedToHttps_(false),
+ sslServerBump(NULL),
+ signAlgorithm(Ssl::algSignTrusted),
#endif
- stoppedSending_(NULL),
- stoppedReceiving_(NULL)
+ stoppedSending_(NULL),
+ stoppedReceiving_(NULL)
{
flags.readMore = true; // kids may overwrite
flags.swanSang = false;
AsyncCall::Pointer listenCall = asyncCall(33, 2, "clientListenerConnectionOpened",
ListeningStartedDialer(&clientListenerConnectionOpened,
- s, Ipc::fdnHttpsSocket, sub));
+ s, Ipc::fdnHttpsSocket, sub));
Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->listenConn, Ipc::fdnHttpsSocket, listenCall);
HttpSockets[NHttpSockets] = -1;
++NHttpSockets;
}
ConnStateData::In::In() :
- bodyParser(NULL),
- buf()
+ bodyParser(NULL),
+ buf()
{}
ConnStateData::In::~In()
/* NOTE: pinning.pinned should be kept. This combined with fd == -1 at the end of a request indicates that the host
* connection has gone away */
}
+
void keepaliveNextRequest();
Comm::ConnectionPointer clientConnection; /// details about the client connection socket.
- ClientHttpRequest *http; /* we pretend to own that job */
+ ClientHttpRequest *http; /* we pretend to own that job */
HttpReply *reply;
char reqbuf[HTTP_REQBUF_SZ];
Pointer next;
void clientPostHttpsAccept(ConnStateData *);
#endif /* SQUID_CLIENTSIDE_H */
+
if (http->storeEntry() == NULL) {
debugs(88, 5, "clientReplyStatus: no storeEntry");
- return STREAM_FAILED; /* yuck, but what can we do? */
+ return STREAM_FAILED; /* yuck, but what can we do? */
}
if (EBIT_TEST(http->storeEntry()->flags, ENTRY_ABORTED)) {
return err;
}
+
ClientHttpRequest *http;
int headers_sz;
- store_client *sc; /* The store_client we're using */
- StoreIOBuffer tempBuffer; /* For use in validating requests via IMS */
- int old_reqsize; /* ... again, for the buffer */
+ store_client *sc; /* The store_client we're using */
+ StoreIOBuffer tempBuffer; /* For use in validating requests via IMS */
+ int old_reqsize; /* ... again, for the buffer */
size_t reqsize;
size_t reqofs;
- char tempbuf[HTTP_REQBUF_SZ]; /* a temporary buffer if we need working storage */
+ char tempbuf[HTTP_REQBUF_SZ]; /* a temporary buffer if we need working storage */
#if USE_CACHE_DIGESTS
- const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */
+ const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */
#endif
struct {
unsigned storelogiccomplete:1;
- unsigned complete:1; /* we have read all we can from upstream */
+ unsigned complete:1; /* we have read all we can from upstream */
bool headersSent;
} flags;
- clientStreamNode *ourNode; /* This will go away if/when this file gets refactored some more */
+ clientStreamNode *ourNode; /* This will go away if/when this file gets refactored some more */
private:
clientStreamNode *getNextNode() const;
void sendNotModifiedOrPreconditionFailedError();
StoreEntry *old_entry;
- store_client *old_sc; /* ... for entry to be validated */
+ store_client *old_sc; /* ... for entry to be validated */
bool deleting;
};
#endif /* SQUID_CLIENTSIDEREPLY_H */
+
ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) :
#if USE_ADAPTATION
- AsyncJob("ClientHttpRequest"),
+ AsyncJob("ClientHttpRequest"),
#endif
- loggingEntry_(NULL)
+ loggingEntry_(NULL)
{
setConn(aConn);
al = new AccessLogEntry;
hit_only_mode_until = squid_curtime + FAILURE_MODE_TIME;
- request_failure_ratio = 0.8; /* reset to something less than 1.0 */
+ request_failure_ratio = 0.8; /* reset to something less than 1.0 */
}
ClientHttpRequest::~ClientHttpRequest()
request->indirect_client_addr.setNoAddr();
#endif /* FOLLOW_X_FORWARDED_FOR */
- request->my_addr.setNoAddr(); /* undefined for internal requests */
+ request->my_addr.setNoAddr(); /* undefined for internal requests */
request->my_addr.port(0);
break;
case Helper::TimedOut:
- // Timeouts for storeID are not implemented
+ // Timeouts for storeID are not implemented
case Helper::BrokenHelper:
debugs(85, DBG_IMPORTANT, "ERROR: storeID helper: " << reply);
break;
getConn()->sslBumpMode = sslBumpNeed_;
AsyncCall::Pointer bumpCall = commCbCall(85, 5, "ClientSocketContext::sslBumpEstablish",
- CommIoCbPtrFun(&SslBumpEstablish, this));
+ CommIoCbPtrFun(&SslBumpEstablish, this));
if (request->flags.interceptTproxy || request->flags.intercepted) {
CommIoCbParams ¶ms = GetCommParams<CommIoCbParams>(bumpCall);
void
ClientHttpRequest::noteAdaptationAnswer(const Adaptation::Answer &answer)
{
- assert(cbdataReferenceValid(this)); // indicates bug
+ assert(cbdataReferenceValid(this)); // indicates bug
clearAdaptation(virginHeadSource);
assert(!adaptedBodySource);
{
return loggingEntry_;
}
+
class ClientHttpRequest
#if USE_ADAPTATION
- : public Adaptation::Initiator, // to start adaptation transactions
- public BodyConsumer // to receive reply bodies in request satisf. mode
+ : public Adaptation::Initiator, // to start adaptation transactions
+ public BodyConsumer // to receive reply bodies in request satisf. mode
#endif
{
CBDATA_CLASS(ClientHttpRequest);
*/
Comm::ConnectionPointer clientConnection;
- HttpRequest *request; /* Parsed URL ... */
+ HttpRequest *request; /* Parsed URL ... */
char *uri;
char *log_uri;
String store_id; /* StoreID for transactions where the request member is nil */
size_t headers_sz;
} out;
- HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
- size_t req_sz; /* raw request size on input, not current request size */
+ HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
+ size_t req_sz; /* raw request size on input, not current request size */
/// the processing tags associated with this request transaction.
// NP: still an enum so each stage altering it must take care when replacing it.
void startAdaptation(const Adaptation::ServiceGroupPointer &g);
private:
- /// Handles an adaptation client request failure.
+ /// Handles an adaptation client request failure.
/// Bypasses the error if possible, or build an error reply.
void handleAdaptationFailure(int errDetail, bool bypassable = false);
#endif
#endif /* SQUID_CLIENTSIDEREQUEST_H */
+
void purgeEntriesByUrl(HttpRequest * req, const char *url);
Client::Client(FwdState *theFwdState): AsyncJob("Client"),
- completed(false),
- currentOffset(0),
- responseBodyBuffer(NULL),
- fwd(theFwdState),
- requestSender(NULL),
+ completed(false),
+ currentOffset(0),
+ responseBodyBuffer(NULL),
+ fwd(theFwdState),
+ requestSender(NULL),
#if USE_ADAPTATION
- adaptedHeadSource(NULL),
- adaptationAccessCheckPending(false),
- startedAdaptation(false),
+ adaptedHeadSource(NULL),
+ adaptationAccessCheckPending(false),
+ startedAdaptation(false),
#endif
- receivedWholeRequestBody(false),
- theVirginReply(NULL),
- theFinalReply(NULL)
+ receivedWholeRequestBody(false),
+ theVirginReply(NULL),
+ theFinalReply(NULL)
{
entry = fwd->entry;
entry->lock("Client");
}
size_t Client::replyBodySpace(const MemBuf &readBuf,
- const size_t minSpace) const
+ const size_t minSpace) const
{
size_t space = readBuf.spaceSize(); // available space w/o heroic measures
if (space < minSpace) {
#if USE_ADAPTATION
if (responseBodyBuffer) {
- return 0; // Stop reading if already overflowed waiting for ICAP to catch up
+ return 0; // Stop reading if already overflowed waiting for ICAP to catch up
}
if (virginBodyDestination != NULL) {
return space;
}
+
*/
class Client:
#if USE_ADAPTATION
- public Adaptation::Initiator,
- public BodyProducer,
+ public Adaptation::Initiator,
+ public BodyProducer,
#endif
- public BodyConsumer
+ public BodyConsumer
{
public:
void adjustBodyBytesRead(const int64_t delta);
// These should be private
- int64_t currentOffset; /**< Our current offset in the StoreEntry */
- MemBuf *responseBodyBuffer; /**< Data temporarily buffered for ICAP */
+ int64_t currentOffset; /**< Our current offset in the StoreEntry */
+ MemBuf *responseBodyBuffer; /**< Data temporarily buffered for ICAP */
public: // should not be
StoreEntry *entry;
};
#endif /* SQUID_SRC_CLIENTS_CLIENT_H */
+
/* Ftp::CtrlChannel */
Ftp::CtrlChannel::CtrlChannel():
- buf(NULL),
- size(0),
- offset(0),
- message(NULL),
- last_command(NULL),
- last_reply(NULL),
- replycode(0)
+ buf(NULL),
+ size(0),
+ offset(0),
+ message(NULL),
+ last_command(NULL),
+ last_reply(NULL),
+ replycode(0)
{
buf = static_cast<char*>(memAllocBuf(4096, &size));
}
/* Ftp::DataChannel */
Ftp::DataChannel::DataChannel():
- readBuf(NULL),
- host(NULL),
- port(0),
- read_pending(false)
+ readBuf(NULL),
+ host(NULL),
+ port(0),
+ read_pending(false)
{
}
/* Ftp::Client */
Ftp::Client::Client(FwdState *fwdState):
- AsyncJob("Ftp::Client"),
- ::Client(fwdState),
- ctrl(),
- data(),
- state(BEGIN),
- old_request(NULL),
- old_reply(NULL),
- shortenReadTimeout(false)
+ AsyncJob("Ftp::Client"),
+ ::Client(fwdState),
+ ctrl(),
+ data(),
+ state(BEGIN),
+ old_request(NULL),
+ old_reply(NULL),
+ shortenReadTimeout(false)
{
++statCounter.server.all.requests;
++statCounter.server.ftp.requests;
state = SENT_EPSV_2;
break;
}
- // else fall through to skip EPSV 2
+ // else fall through to skip EPSV 2
case SENT_EPSV_2: /* EPSV IPv6 failed. Try EPSV IPv4 */
if (ctrl.conn->local.isIPv4()) {
failed(ERR_FTP_FAILURE, 0);
return false;
}
- // else fall through to skip EPSV 1
+ // else fall through to skip EPSV 1
case SENT_EPSV_1: /* EPSV options exhausted. Try PASV now. */
debugs(9, 5, "FTP Channel (" << ctrl.conn->remote << ") rejects EPSV connection attempts. Trying PASV instead.");
}
}; // namespace Ftp
+
} // namespace Ftp
#endif /* SQUID_FTP_CLIENT_H */
+
String cwd_message;
char *old_filepath;
char typecode;
- MemBuf listing; ///< FTP directory listing in HTML format.
+ MemBuf listing; ///< FTP directory listing in HTML format.
GatewayFlags flags;
/************************************************
** Debugs Levels used here **
*************************************************
-0 CRITICAL Events
-1 IMPORTANT Events
- Protocol and Transmission failures.
-2 FTP Protocol Chatter
-3 Logic Flows
-4 Data Parsing Flows
-5 Data Dumps
-7 ??
+0 CRITICAL Events
+1 IMPORTANT Events
+ Protocol and Transmission failures.
+2 FTP Protocol Chatter
+3 Logic Flows
+4 Data Parsing Flows
+5 Data Dumps
+7 ??
************************************************/
/************************************************
** State Machine Description (excluding hacks) **
*************************************************
-From To
+From To
---------------------------------------
-Welcome User
-User Pass
-Pass Type
-Type TraverseDirectory / GetFile
-TraverseDirectory Cwd / GetFile / ListDir
-Cwd TraverseDirectory / Mkdir
-GetFile Mdtm
-Mdtm Size
-Size Epsv
-ListDir Epsv
-Epsv FileOrList
-FileOrList Rest / Retr / Nlst / List / Mkdir (PUT /xxx;type=d)
-Rest Retr
-Retr / Nlst / List DataRead* (on datachannel)
-DataRead* ReadTransferDone
-ReadTransferDone DataTransferDone
-Stor DataWrite* (on datachannel)
-DataWrite* RequestPutBody** (from client)
-RequestPutBody** DataWrite* / WriteTransferDone
-WriteTransferDone DataTransferDone
-DataTransferDone Quit
-Quit -
+Welcome User
+User Pass
+Pass Type
+Type TraverseDirectory / GetFile
+TraverseDirectory Cwd / GetFile / ListDir
+Cwd TraverseDirectory / Mkdir
+GetFile Mdtm
+Mdtm Size
+Size Epsv
+ListDir Epsv
+Epsv FileOrList
+FileOrList Rest / Retr / Nlst / List / Mkdir (PUT /xxx;type=d)
+Rest Retr
+Retr / Nlst / List DataRead* (on datachannel)
+DataRead* ReadTransferDone
+ReadTransferDone DataTransferDone
+Stor DataWrite* (on datachannel)
+DataWrite* RequestPutBody** (from client)
+RequestPutBody** DataWrite* / WriteTransferDone
+WriteTransferDone DataTransferDone
+DataTransferDone Quit
+Quit -
************************************************/
FTPSM *FTP_SM_FUNCS[] = {
- ftpReadWelcome, /* BEGIN */
- ftpReadUser, /* SENT_USER */
- ftpReadPass, /* SENT_PASS */
- ftpReadType, /* SENT_TYPE */
- ftpReadMdtm, /* SENT_MDTM */
- ftpReadSize, /* SENT_SIZE */
- ftpReadEPRT, /* SENT_EPRT */
- ftpReadPORT, /* SENT_PORT */
- ftpReadEPSV, /* SENT_EPSV_ALL */
- ftpReadEPSV, /* SENT_EPSV_1 */
- ftpReadEPSV, /* SENT_EPSV_2 */
- ftpReadPasv, /* SENT_PASV */
- ftpReadCwd, /* SENT_CWD */
- ftpReadList, /* SENT_LIST */
- ftpReadList, /* SENT_NLST */
- ftpReadRest, /* SENT_REST */
- ftpReadRetr, /* SENT_RETR */
- ftpReadStor, /* SENT_STOR */
- ftpReadQuit, /* SENT_QUIT */
- ftpReadTransferDone, /* READING_DATA (RETR,LIST,NLST) */
- ftpWriteTransferDone, /* WRITING_DATA (STOR) */
- ftpReadMkdir, /* SENT_MKDIR */
- NULL, /* SENT_FEAT */
- NULL, /* SENT_PWD */
- NULL, /* SENT_CDUP*/
- NULL, /* SENT_DATA_REQUEST */
- NULL /* SENT_COMMAND */
+ ftpReadWelcome, /* BEGIN */
+ ftpReadUser, /* SENT_USER */
+ ftpReadPass, /* SENT_PASS */
+ ftpReadType, /* SENT_TYPE */
+ ftpReadMdtm, /* SENT_MDTM */
+ ftpReadSize, /* SENT_SIZE */
+ ftpReadEPRT, /* SENT_EPRT */
+ ftpReadPORT, /* SENT_PORT */
+ ftpReadEPSV, /* SENT_EPSV_ALL */
+ ftpReadEPSV, /* SENT_EPSV_1 */
+ ftpReadEPSV, /* SENT_EPSV_2 */
+ ftpReadPasv, /* SENT_PASV */
+ ftpReadCwd, /* SENT_CWD */
+ ftpReadList, /* SENT_LIST */
+ ftpReadList, /* SENT_NLST */
+ ftpReadRest, /* SENT_REST */
+ ftpReadRetr, /* SENT_RETR */
+ ftpReadStor, /* SENT_STOR */
+ ftpReadQuit, /* SENT_QUIT */
+ ftpReadTransferDone, /* READING_DATA (RETR,LIST,NLST) */
+ ftpWriteTransferDone, /* WRITING_DATA (STOR) */
+ ftpReadMkdir, /* SENT_MKDIR */
+ NULL, /* SENT_FEAT */
+ NULL, /* SENT_PWD */
+ NULL, /* SENT_CDUP*/
+ NULL, /* SENT_DATA_REQUEST */
+ NULL /* SENT_COMMAND */
};
/// handler called by Comm when FTP data channel is closed unexpectedly
}
Ftp::Gateway::Gateway(FwdState *fwdState):
- AsyncJob("FtpStateData"),
- Ftp::Client(fwdState),
- password_url(0),
- reply_hdr(NULL),
- reply_hdr_state(0),
- conn_att(0),
- login_att(0),
- mdtm(-1),
- theSize(-1),
- pathcomps(NULL),
- filepath(NULL),
- dirpath(NULL),
- restart_offset(0),
- proxy_host(NULL),
- list_width(0),
- old_filepath(NULL),
- typecode('\0')
+ AsyncJob("FtpStateData"),
+ Ftp::Client(fwdState),
+ password_url(0),
+ reply_hdr(NULL),
+ reply_hdr_state(0),
+ conn_att(0),
+ login_att(0),
+ mdtm(-1),
+ theSize(-1),
+ pathcomps(NULL),
+ filepath(NULL),
+ dirpath(NULL),
+ restart_offset(0),
+ proxy_host(NULL),
+ list_width(0),
+ old_filepath(NULL),
+ typecode('\0')
{
debugs(9, 3, entry->url());
if (regexec(&scan_ftp_integer, day, 0, NULL, 0) != 0)
continue;
- if (regexec(&scan_ftp_time, year, 0, NULL, 0) != 0) /* Yr | hh:mm */
+ if (regexec(&scan_ftp_time, year, 0, NULL, 0) != 0) /* Yr | hh:mm */
continue;
snprintf(tbuf, 128, "%s %2s %5s",
tm = (time_t) strtol(ct + 1, &tmp, 0);
if (tmp != ct + 1)
- break; /* not a valid integer */
+ break; /* not a valid integer */
p->date = xstrdup(ctime(&tm));
xfree(tokens[i]);
if (!p->name)
- ftpListPartsFree(&p); /* cleanup */
+ ftpListPartsFree(&p); /* cleanup */
return p;
}
snprintf(icon, 2048, "<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
mimeGetIconURL("internal-dir"),
"[DIR]");
- strcat(href, "/"); /* margin is allocated above */
+ strcat(href, "/"); /* margin is allocated above */
break;
case 'l':
Ftp::Gateway::parseListing()
{
char *buf = data.readBuf->content();
- char *sbuf; /* NULL-terminated copy of termedBuf */
+ char *sbuf; /* NULL-terminated copy of termedBuf */
char *end;
char *line;
char *s;
* TODO: we might be able to do something about locating username from other sources:
* ie, external ACL user=* tag or ident lookup
*
- \retval 1 if we have everything needed to complete this request.
- \retval 0 if something is missing.
+ \retval 1 if we have everything needed to complete this request.
+ \retval 0 if something is missing.
*/
int
Ftp::Gateway::checkAuth(const HttpHeader * req_hdr)
}
}
- return 0; /* different username */
+ return 0; /* different username */
}
static String str_type_eq;
if (!l) {
flags.isdir = 1;
flags.root_dir = 1;
- flags.need_base_href = 1; /* Work around broken browsers */
+ flags.need_base_href = 1; /* Work around broken browsers */
} else if (!request->urlpath.cmp("/%2f/")) {
/* UNIX root directory */
flags.isdir = 1;
debugs(9, 3, HERE << "path " << path << ", code " << code);
- if (code == 257) { /* success */
+ if (code == 257) { /* success */
ftpSendCwd(ftpState);
- } else if (code == 550) { /* dir exists */
+ } else if (code == 550) { /* dir exists */
if (ftpState->flags.put_mkdir) {
ftpState->flags.put_mkdir = 1;
ftpState->flags.isdir = 1;
if (ftpState->flags.put) {
- ftpSendMkdir(ftpState); /* PUT name;type=d */
+ ftpSendMkdir(ftpState); /* PUT name;type=d */
} else {
- ftpSendNlst(ftpState); /* GET name;type=d sec 3.2.2 of RFC 1738 */
+ ftpSendNlst(ftpState); /* GET name;type=d sec 3.2.2 of RFC 1738 */
}
} else if (ftpState->flags.put) {
ftpSendStor(ftpState);
/* QUIT operation handles sending the reply to client */
}
ftpSendQuit(ftpState);
- } else { /* != 226 */
+ } else { /* != 226 */
debugs(9, DBG_IMPORTANT, HERE << "Got code " << code << " after reading data");
ftpState->failed(ERR_FTP_FAILURE, 0);
/* failed closes ctrl.conn and frees ftpState */
return;
}
- ftpState->entry->timestampsSet(); /* XXX Is this needed? */
+ ftpState->entry->timestampsSet(); /* XXX Is this needed? */
ftpSendReply(ftpState);
}
"slashhack=" << (ftpState->request->urlpath.caseCmp("/%2f", 4)==0? "T":"F") );
/* Try the / hack to support "Netscape" FTP URL's for retreiving files */
- if (!ftpState->flags.isdir && /* Not a directory */
- !ftpState->flags.try_slash_hack && /* Not in slash hack */
- ftpState->mdtm <= 0 && ftpState->theSize < 0 && /* Not known as a file */
- ftpState->request->urlpath.caseCmp("/%2f", 4) != 0) { /* No slash encoded */
+ if (!ftpState->flags.isdir && /* Not a directory */
+ !ftpState->flags.try_slash_hack && /* Not in slash hack */
+ ftpState->mdtm <= 0 && ftpState->theSize < 0 && /* Not known as a file */
+ ftpState->request->urlpath.caseCmp("/%2f", 4) != 0) { /* No slash encoded */
switch (ftpState->state) {
EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
- entry->buffer(); /* released when done processing current data payload */
+ entry->buffer(); /* released when done processing current data payload */
filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.termedBuf();
* A hack to ensure we do not double-complete on the forward entry.
*
\todo Ftp::Gateway logic should probably be rewritten to avoid
- * double-completion or FwdState should be rewritten to allow it.
+ * double-completion or FwdState should be rewritten to allow it.
*/
void
Ftp::Gateway::completeForwarding()
/**
* Have we lost the FTP server control channel?
*
- \retval true The server control channel is available.
- \retval false The server control channel is not available.
+ \retval true The server control channel is available.
+ \retval false The server control channel is not available.
*/
bool
Ftp::Gateway::haveControlChannel(const char *caller_name) const
{
return AsyncJob::Start(new Ftp::Gateway(fwdState));
}
+
};
Ftp::Relay::Relay(FwdState *const fwdState):
- AsyncJob("Ftp::Relay"),
- Ftp::Client(fwdState),
- thePreliminaryCb(NULL),
- forwardingCompleted(false)
+ AsyncJob("Ftp::Relay"),
+ Ftp::Client(fwdState),
+ thePreliminaryCb(NULL),
+ forwardingCompleted(false)
{
savedReply.message = NULL;
savedReply.lastCommand = NULL;
forwardPreliminaryReply(&Ftp::Relay::startDataDownload);
else if (fwd->request->forcedBodyContinuation /*&& serverState() == fssHandleUploadRequest*/)
startDataUpload();
- else // serverState() == fssHandleUploadRequest
+ else // serverState() == fssHandleUploadRequest
forwardPreliminaryReply(&Ftp::Relay::startDataUpload);
} else
forwardReply();
{
return AsyncJob::Start(new Ftp::Relay(fwdState));
}
+
} // namespace Ftp
#endif /* SQUID_CLIENTS_FORWARD_H */
+
F->dynamicSslContext = NULL;
}
#endif
- fd_close(params.fd); /* update fdstat */
+ fd_close(params.fd); /* update fdstat */
close(params.fd);
++ statCounter.syscalls.sock.closes;
typedef CommCloseCbParams Params;
const Params ¶ms = GetCommParams<Params>(p);
if (call->dialer.handler == handler && params.data == data)
- break; /* This is our handler */
+ break; /* This is our handler */
}
// comm_close removes all close handlers so our handler may be gone
{
struct linger L;
- L.l_onoff = 0; /* off */
+ L.l_onoff = 0; /* off */
L.l_linger = 0;
if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0)
}
CommQuotaQueue::CommQuotaQueue(ClientInfo *info): clientInfo(info),
- ins(0), outs(0)
+ ins(0), outs(0)
{
assert(clientInfo);
}
if (F->type != FD_SOCKET)
continue;
- if (F->flags.ipc) /* don't close inter-process sockets */
+ if (F->flags.ipc) /* don't close inter-process sockets */
continue;
if (F->timeoutHandler != NULL) {
CommRead::CommRead() : conn(NULL), buf(NULL), len(0), callback(NULL) {}
CommRead::CommRead(const Comm::ConnectionPointer &c, char *buf_, int len_, AsyncCall::Pointer &callback_)
- : conn(c), buf(buf_), len(len_), callback(callback_) {}
+ : conn(c), buf(buf_), len(len_), callback(callback_) {}
DeferredRead::DeferredRead () : theReader(NULL), theContext(NULL), theRead(), cancelled(false) {}
return new_socket;
}
+
}; // namepace Comm
#endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Comm, ConnOpener);
Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &c, AsyncCall::Pointer &handler, time_t ctimeout) :
- AsyncJob("Comm::ConnOpener"),
- host_(NULL),
- temporaryFd_(-1),
- conn_(c),
- callback_(handler),
- totalTries_(0),
- failRetries_(0),
- deadline_(squid_curtime + static_cast<time_t>(ctimeout))
+ AsyncJob("Comm::ConnOpener"),
+ host_(NULL),
+ temporaryFd_(-1),
+ conn_(c),
+ callback_(handler),
+ totalTries_(0),
+ failRetries_(0),
+ deadline_(squid_curtime + static_cast<time_t>(ctimeout))
{}
Comm::ConnOpener::~ConnOpener()
}
delete ptr;
}
+
}; // namespace Comm
#endif /* _SQUID_SRC_COMM_CONNOPENER_H */
+
}
Comm::Connection::Connection() :
- local(),
- remote(),
- peerType(HIER_NONE),
- fd(-1),
- tos(0),
- nfmark(0),
- flags(COMM_NONBLOCKING),
- peer_(NULL),
- startTime_(squid_curtime)
+ local(),
+ remote(),
+ peerType(HIER_NONE),
+ fd(-1),
+ tos(0),
+ nfmark(0),
+ flags(COMM_NONBLOCKING),
+ peer_(NULL),
+ startTime_(squid_curtime)
{
*rfc931 = 0; // quick init the head. the rest does not matter.
}
peer_ = cbdataReference(p);
}
}
+
} // namespace Comm
#endif /* _SQUID_SRC_COMM_FLAG_H */
+
/* Reset for next round. */
reset();
}
+
} // namespace Comm
#endif /* _SQUID_COMM_IOCALLBACK_H */
+
} // namespace Comm
#endif /* _SQUID_SRC_COMM_LOOPS_H */
+
#define DEBUG_DEVPOLL 0
// OPEN_MAX is defined in <climits>
-#define DEVPOLL_UPDATESIZE OPEN_MAX
-#define DEVPOLL_QUERYSIZE OPEN_MAX
+#define DEVPOLL_UPDATESIZE OPEN_MAX
+#define DEVPOLL_QUERYSIZE OPEN_MAX
/* TYPEDEFS */
typedef short pollfd_events_t; /* type of pollfd.events from sys/poll.h */
}
#endif /* USE_DEVPOLL */
+
statCounter.select_fds_hist.count(num);
if (num == 0)
- return Comm::TIMEOUT; /* No error.. */
+ return Comm::TIMEOUT; /* No error.. */
PROF_start(comm_handle_ready_fd);
}
#endif /* USE_EPOLL */
+
getCurrentTime();
if (num == 0)
- return Comm::OK; /* No error.. */
+ return Comm::OK; /* No error.. */
for (i = 0; i < num; ++i) {
int fd = (int) ke[i].ident;
}
#endif /* USE_KQUEUE */
+
#endif
#endif
-static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
+static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
}
#endif /* USE_POLL */
+
#include <sys/stat.h>
#endif
-static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
+static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
for (j = 0; j < maxindex; ++j) {
if ((tmask = fdsp[j]) == 0)
- continue; /* no bits here */
+ continue; /* no bits here */
for (k = 0; k < FD_MASK_BITS; ++k) {
if (!EBIT_TEST(tmask, k))
for (j = 0; j < maxindex; ++j) {
if ((tmask = (fdsp[j] | pfdsp[j])) == 0)
- continue; /* no bits here */
+ continue; /* no bits here */
for (k = 0; k < FD_MASK_BITS; ++k) {
if (tmask == 0)
- break; /* no more bits left */
+ break; /* no more bits left */
if (!EBIT_TEST(tmask, k))
continue;
/* Found a set bit */
fd = (j * FD_MASK_BITS) + k;
- EBIT_CLR(tmask, k); /* this will be done */
+ EBIT_CLR(tmask, k); /* this will be done */
#if DEBUG_FDBITS
for (j = 0; j < maxindex; ++j) {
if ((tmask = fdsp[j]) == 0)
- continue; /* no bits here */
+ continue; /* no bits here */
for (k = 0; k < FD_MASK_BITS; ++k) {
if (tmask == 0)
- break; /* no more bits left */
+ break; /* no more bits left */
if (!EBIT_TEST(tmask, k))
continue;
/* Found a set bit */
fd = (j * FD_MASK_BITS) + k;
- EBIT_CLR(tmask, k); /* this will be done */
+ EBIT_CLR(tmask, k); /* this will be done */
#if DEBUG_FDBITS
}
#endif /* USE_SELECT */
+
#include <cerrno>
-static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
+static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
}
#endif /* USE_SELECT_WIN32 */
+
/* And the IO event */
Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
}
+
void comm_read_cancel(int fd, IOCB *callback, void *data);
#endif /* _SQUID_COMM_READ_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Comm, TcpAcceptor);
Comm::TcpAcceptor::TcpAcceptor(const Comm::ConnectionPointer &newConn, const char *note, const Subscription::Pointer &aSub) :
- AsyncJob("Comm::TcpAcceptor"),
- errcode(0),
- isLimited(0),
- theCallSub(aSub),
- conn(newConn),
- listenPort_()
+ AsyncJob("Comm::TcpAcceptor"),
+ errcode(0),
+ isLimited(0),
+ theCallSub(aSub),
+ conn(newConn),
+ listenPort_()
{}
Comm::TcpAcceptor::TcpAcceptor(const AnyP::PortCfgPointer &p, const char *note, const Subscription::Pointer &aSub) :
- AsyncJob("Comm::TcpAcceptor"),
- errcode(0),
- isLimited(0),
- theCallSub(aSub),
- conn(p->listenConn),
- listenPort_(p)
+ AsyncJob("Comm::TcpAcceptor"),
+ errcode(0),
+ isLimited(0),
+ theCallSub(aSub),
+ conn(p->listenConn),
+ listenPort_(p)
{}
void
PROF_stop(comm_accept);
return Comm::OK;
}
+
} // namespace Comm
#endif /* SQUID_COMM_TCPACCEPTOR_H */
+
/// dials a UDP port-opened call
class UdpOpenDialer: public CallDialer,
- public Ipc::StartListeningCb
+ public Ipc::StartListeningCb
{
public:
typedef void (*Handler)(const Comm::ConnectionPointer &conn, int errNo);
} // namespace Comm
#endif /* SQUID_COMM_UDPOPENDIALER_H */
+
PROF_stop(commHandleWrite);
}
+
} // namespace Comm
#endif /* _SQUID_COMM_IOWRITE_H */
+
void commStopHalfClosedMonitor(int fd);
#endif
+
}; // namespace Comm
#endif /* _SQUID_COMM_FORWARD_H */
+
#define SQUID_COMM_POLL_H
#endif /* SQUID_COMM_POLL_H */
+
if (debug_log_file)
xfree(debug_log_file);
- debug_log_file = xstrdup(logfile); /* keep a static copy */
+ debug_log_file = xstrdup(logfile); /* keep a static copy */
if (debug_log && debug_log != stderr)
fclose(debug_log);
if (CurrentDebug) {
*CurrentDebug << "assertion failed: " << file << ":" << line <<
- ": \"" << msg << "\"";
+ ": \"" << msg << "\"";
}
abort();
}
return os;
}
+
#define BROWSERNAMELEN 128
-#define ACL_SUNDAY 0x01
-#define ACL_MONDAY 0x02
-#define ACL_TUESDAY 0x04
-#define ACL_WEDNESDAY 0x08
-#define ACL_THURSDAY 0x10
-#define ACL_FRIDAY 0x20
-#define ACL_SATURDAY 0x40
-#define ACL_ALLWEEK 0x7F
-#define ACL_WEEKDAYS 0x3E
+#define ACL_SUNDAY 0x01
+#define ACL_MONDAY 0x02
+#define ACL_TUESDAY 0x04
+#define ACL_WEDNESDAY 0x08
+#define ACL_THURSDAY 0x10
+#define ACL_FRIDAY 0x20
+#define ACL_SATURDAY 0x40
+#define ACL_ALLWEEK 0x7F
+#define ACL_WEEKDAYS 0x3E
/* Select types. */
#define COMM_SELECT_READ (0x1)
#define DNS_INBUF_SZ 4096
-#define FD_DESC_SZ 64
+#define FD_DESC_SZ 64
-#define FQDN_LOOKUP_IF_MISS 0x01
+#define FQDN_LOOKUP_IF_MISS 0x01
#define FQDN_MAX_NAMES 5
#define HTTP_REPLY_FIELD_SZ 128
-#define BUF_TYPE_8K 1
+#define BUF_TYPE_8K 1
#define BUF_TYPE_MALLOC 2
-#define ANONYMIZER_NONE 0
-#define ANONYMIZER_STANDARD 1
-#define ANONYMIZER_PARANOID 2
+#define ANONYMIZER_NONE 0
+#define ANONYMIZER_STANDARD 1
+#define ANONYMIZER_PARANOID 2
#define USER_IDENT_SZ 64
#define IDENT_NONE 0
#define IDENT_PENDING 1
#define IDENT_DONE 2
-#define IP_LOOKUP_IF_MISS 0x01
+#define IP_LOOKUP_IF_MISS 0x01
#define MAX_MIME 4096
#define ICP_FLAG_SRC_RTT 0x40000000ul
/* Version */
-#define ICP_VERSION_2 2
-#define ICP_VERSION_3 3
-#define ICP_VERSION_CURRENT ICP_VERSION_2
+#define ICP_VERSION_2 2
+#define ICP_VERSION_3 3
+#define ICP_VERSION_CURRENT ICP_VERSION_2
#define DIRECT_UNKNOWN 0
#define DIRECT_NO 1
#define SM_PAGE_SIZE 4096
#define MAX_CLIENT_BUF_SZ 4096
-#define EBIT_SET(flag, bit) ((void)((flag) |= ((1L<<(bit)))))
-#define EBIT_CLR(flag, bit) ((void)((flag) &= ~((1L<<(bit)))))
-#define EBIT_TEST(flag, bit) ((flag) & ((1L<<(bit))))
+#define EBIT_SET(flag, bit) ((void)((flag) |= ((1L<<(bit)))))
+#define EBIT_CLR(flag, bit) ((void)((flag) &= ~((1L<<(bit)))))
+#define EBIT_TEST(flag, bit) ((flag) & ((1L<<(bit))))
/* bit opearations on a char[] mask of unlimited length */
#define CBIT_BIT(bit) (1<<((bit)%8))
#define CBIT_BIN(mask, bit) (mask)[(bit)>>3]
-#define CBIT_SET(mask, bit) ((void)(CBIT_BIN(mask, bit) |= CBIT_BIT(bit)))
-#define CBIT_CLR(mask, bit) ((void)(CBIT_BIN(mask, bit) &= ~CBIT_BIT(bit)))
-#define CBIT_TEST(mask, bit) (CBIT_BIN(mask, bit) & CBIT_BIT(bit))
+#define CBIT_SET(mask, bit) ((void)(CBIT_BIN(mask, bit) |= CBIT_BIT(bit)))
+#define CBIT_CLR(mask, bit) ((void)(CBIT_BIN(mask, bit) &= ~CBIT_BIT(bit)))
+#define CBIT_TEST(mask, bit) (CBIT_BIN(mask, bit) & CBIT_BIT(bit))
#define MAX_FILES_PER_DIR (1<<20)
#define PEER_MAX_ADDRESSES 10
#define RTT_AV_FACTOR 50
-#define RTT_BACKGROUND_AV_FACTOR 25 /* Background pings need a smaller factor since they are sent less frequently */
+#define RTT_BACKGROUND_AV_FACTOR 25 /* Background pings need a smaller factor since they are sent less frequently */
#define PEER_DEAD 0
#define PEER_ALIVE 1
#define FILE_MODE(x) ((x)&(O_RDONLY|O_WRONLY|O_RDWR))
#endif
-#define HTTP_REQBUF_SZ 4096
+#define HTTP_REQBUF_SZ 4096
/* CygWin & Windows NT Port */
#if _SQUID_WINDOWS_
#define _WIN_SQUID_SERVICE_CONTROL_STOP SERVICE_CONTROL_STOP
#define _WIN_SQUID_SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN
#define _WIN_SQUID_SERVICE_CONTROL_INTERROGATE SERVICE_CONTROL_INTERROGATE
-#define _WIN_SQUID_SERVICE_CONTROL_ROTATE 128
-#define _WIN_SQUID_SERVICE_CONTROL_RECONFIGURE 129
-#define _WIN_SQUID_SERVICE_CONTROL_DEBUG 130
-#define _WIN_SQUID_SERVICE_CONTROL_INTERRUPT 131
-#define _WIN_SQUID_SERVICE_OPTION "--ntservice"
-#define _WIN_SQUID_RUN_MODE_INTERACTIVE 0
-#define _WIN_SQUID_RUN_MODE_SERVICE 1
+#define _WIN_SQUID_SERVICE_CONTROL_ROTATE 128
+#define _WIN_SQUID_SERVICE_CONTROL_RECONFIGURE 129
+#define _WIN_SQUID_SERVICE_CONTROL_DEBUG 130
+#define _WIN_SQUID_SERVICE_CONTROL_INTERRUPT 131
+#define _WIN_SQUID_SERVICE_OPTION "--ntservice"
+#define _WIN_SQUID_RUN_MODE_INTERACTIVE 0
+#define _WIN_SQUID_RUN_MODE_SERVICE 1
#endif
#endif /* SQUID_DEFINES_H */
+
}
#endif /* USE_DELAY_POOLS */
+
{
#endif
debugs(6, 3, "diskHandleRead: FD " << fd << " seeking to offset " << ctrl_dat->offset);
- lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */
+ lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */
++ statCounter.syscalls.disk.seeks;
F->disk.offset = ctrl_dat->offset;
}
int xrename(const char *from, const char *to); //disk.cc
#endif /* SQUID_DISK_H_ */
+
m->next = m->prev = NULL;
}
+
dlink_node *dlinkNodeNew(void);
#endif /* SQUID_DLINK_H */
+
#if WHEN_EDNS_RESPONSES_ARE_PARSED
// TODO: actually gr the message right here.
-// pull out the DNS meta data we need (A records, AAAA records and EDNS OPT) and store in q
-// this is overall better than force-feeding A response with AAAA an section later anyway.
-// AND allows us to merge AN+AR sections from both responses (one day)
+// pull out the DNS meta data we need (A records, AAAA records and EDNS OPT) and store in q
+// this is overall better than force-feeding A response with AAAA an section later anyway.
+// AND allows us to merge AN+AR sections from both responses (one day)
if (q->edns_seen >= 0) {
if (max_shared_edns == nameservers[from_ns].last_seen_edns && max_shared_edns < q->edns_seen) {
}
#endif /*SQUID_SNMP */
+
* its status
*/
typedef enum {
- STREAM_NONE, /* No particular status */
- STREAM_COMPLETE, /* All data has been flushed, no more reads allowed */
+ STREAM_NONE, /* No particular status */
+ STREAM_COMPLETE, /* All data has been flushed, no more reads allowed */
/* an unpredicted end has occured, no more
* reads occured, but no need to tell
* downstream that an error occured
#endif /* USE_HTCP */
#endif /* SQUID_ENUMS_H */
+
extern const char *err_type_str[];
#endif /* _SQUID_ERR_TYPE_H */
+
* automagically to give you more control on the format
*/
static const struct {
- int type; /* and page_id */
+ int type; /* and page_id */
const char *text;
}
const char *
errorPageName(int pageId)
{
- if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */
+ if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */
return err_type_str[pageId];
if (pageId >= ERR_MAX && pageId - ERR_MAX < (ssize_t)ErrorDynamicPages.size())
return ErrorDynamicPages[pageId - ERR_MAX]->page_name;
- return "ERR_UNKNOWN"; /* should not happen */
+ return "ERR_UNKNOWN"; /* should not happen */
}
ErrorState *
}
ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) :
- type(t),
- page_id(t),
- err_language(NULL),
- httpStatus(status),
+ type(t),
+ page_id(t),
+ err_language(NULL),
+ httpStatus(status),
#if USE_AUTH
- auth_user_request (NULL),
+ auth_user_request (NULL),
#endif
- request(NULL),
- url(NULL),
- xerrno(0),
- port(0),
- dnsError(),
- ttl(0),
- src_addr(),
- redirect_url(NULL),
- callback(NULL),
- callback_data(NULL),
- request_hdrs(NULL),
- err_msg(NULL),
+ request(NULL),
+ url(NULL),
+ xerrno(0),
+ port(0),
+ dnsError(),
+ ttl(0),
+ src_addr(),
+ redirect_url(NULL),
+ callback(NULL),
+ callback_data(NULL),
+ request_hdrs(NULL),
+ err_msg(NULL),
#if USE_OPENSSL
- detail(NULL),
+ detail(NULL),
#endif
- detailCode(ERR_DETAIL_NONE)
+ detailCode(ERR_DETAIL_NONE)
{
memset(&ftp, 0, sizeof(ftp));
ErrorState::Convert(char token, bool building_deny_info_url, bool allowRecursion)
{
static MemBuf mb;
- const char *p = NULL; /* takes priority over mb if set */
+ const char *p = NULL; /* takes priority over mb if set */
int do_quote = 1;
int no_urlescape = 0; /* if true then item is NOT to be further URL-encoded */
char ntoabuf[MAX_IPSTRLEN];
}
if (!p)
- p = mb.buf; /* do not use mb after this assignment! */
+ p = mb.buf; /* do not use mb after this assignment! */
assert(p);
content->init();
while ((p = strchr(m, '%'))) {
- content->append(m, p - m); /* copy */
- const char *t = Convert(*++p, false, allowRecursion); /* convert */
- content->Printf("%s", t); /* copy */
- m = p + 1; /* advance */
+ content->append(m, p - m); /* copy */
+ const char *t = Convert(*++p, false, allowRecursion); /* convert */
+ content->Printf("%s", t); /* copy */
+ m = p + 1; /* advance */
}
if (*m)
- content->Printf("%s", m); /* copy tail */
+ content->Printf("%s", m); /* copy tail */
content->terminate();
return content;
}
+
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos);
#endif /* SQUID_ERRORPAGE_H */
+
}
#endif /* USE_SQUID_ESI == 1 */
+
};
#endif /* SQUID_ESIASSIGN_H */
+
};
#endif /* SQUID_ESIATTEMPT_H */
+
}
#endif /* USE_SQUID_ESI == 1 */
+
public:
typedef RefCount<ESIContext> Pointer;
ESIContext() :
- thisNode(NULL),
- http(NULL),
- errorpage(ERR_NONE),
- errorstatus(Http::scNone),
- errormessage(NULL),
- rep(NULL),
- outbound_offset(0),
- readpos(0),
- pos(0),
- varState(NULL),
- cachedASTInUse(false),
- reading_(true),
- processing(false) {
+ thisNode(NULL),
+ http(NULL),
+ errorpage(ERR_NONE),
+ errorstatus(Http::scNone),
+ errormessage(NULL),
+ rep(NULL),
+ outbound_offset(0),
+ readpos(0),
+ pos(0),
+ varState(NULL),
+ cachedASTInUse(false),
+ reading_(true),
+ processing(false) {
memset(&flags, 0, sizeof(flags));
}
};
#endif /* SQUID_ESICONTEXT_H */
+
}
ESICustomParser::ESICustomParser(ESIParserClient *aClient) :
- theClient(aClient),
- lastTag(ESITAG)
+ theClient(aClient),
+ lastTag(ESITAG)
{}
ESICustomParser::~ESICustomParser()
else
return "Parsing error strings not implemented";
}
+
};
#endif /* SQUID_ESICUSTOMPARSER_H */
+
};
#endif /* SQUID_ESIELEMENT_H */
+
};
#endif /* SQUID_ELEMENTLIST_H */
+
switch (context->kick ()) {
case ESIContext::ESI_KICK_FAILED:
- /* this can not happen - processing can't fail until we have data,
- * and when we come here we have sent data to the client
- */
+ /* this can not happen - processing can't fail until we have data,
+ * and when we come here we have sent data to the client
+ */
case ESIContext::ESI_KICK_SENT:
}
ESIContext::ParserState::ParserState() :
- stackdepth(0),
- parsing(0),
- inited_(false)
+ stackdepth(0),
+ parsing(0),
+ inited_(false)
{}
bool
}
esiLiteral::esiLiteral(esiLiteral const &old) : buffer (old.buffer->cloneList()),
- varState (NULL)
+ varState (NULL)
{
flags.donevars = 0;
}
}
esiTry::esiTry(esiTreeParentPtr aParent) :
- parent(aParent),
- exceptbuffer(NULL)
+ parent(aParent),
+ exceptbuffer(NULL)
{
memset(&flags, 0, sizeof(flags));
}
/* esiWhen */
esiWhen::esiWhen(esiTreeParentPtr aParent, int attrcount, const char **attr,ESIVarState *aVar) :
- esiSequence(aParent),
- testValue(false),
- unevaluatedExpression(NULL),
- varState(NULL)
+ esiSequence(aParent),
+ testValue(false),
+ unevaluatedExpression(NULL),
+ varState(NULL)
{
char const *expression = NULL;
}
esiWhen::esiWhen(esiWhen const &old) :
- esiSequence(old),
- testValue(false),
- unevaluatedExpression(NULL),
- varState(NULL)
+ esiSequence(old),
+ testValue(false),
+ unevaluatedExpression(NULL),
+ varState(NULL)
{
if (old.unevaluatedExpression)
unevaluatedExpression = xstrdup(old.unevaluatedExpression);
}
#endif /* USE_SQUID_ESI == 1 */
+
int esiEnableProcessing (HttpReply *);
#endif /* SQUID_ESI_H */
+
};
#endif /* SQUID_ESIEXCEPT_H */
+
}
#endif /* USE_SQUID_ESI */
+
ESIExpatParser(ESIParserClient *);
~ESIExpatParser();
- /** \retval true on success */
+ /** \retval true on success */
bool parse(char const *dataToParse, size_t const lengthOfData, bool const endOfStream);
long int lineNumber() const;
#endif /* USE_SQUID_ESI */
#endif /* SQUID_ESIEXPATPARSER_H */
+
ESI_EXPR_LESSEQ,
ESI_EXPR_MORE,
ESI_EXPR_MOREEQ,
- ESI_EXPR_EXPR /* the result of an expr PRI 1 */
+ ESI_EXPR_EXPR /* the result of an expr PRI 1 */
} evaltype;
typedef enum {
/* invalid comparison */
return 1;
- stackpop(stack, depth); /* arg rhs */
+ stackpop(stack, depth); /* arg rhs */
- stackpop(stack, depth); /* me */
+ stackpop(stack, depth); /* me */
- stackpop(stack, depth); /* arg lhs */
+ stackpop(stack, depth); /* arg lhs */
srv.valuetype = ESI_EXPR_EXPR;
/* invalid comparison */
return 1;
- stackpop(stack, depth); /* arg rhs */
+ stackpop(stack, depth); /* arg rhs */
- stackpop(stack, depth); /* me */
+ stackpop(stack, depth); /* me */
- stackpop(stack, depth); /* arg lhs */
+ stackpop(stack, depth); /* arg lhs */
srv.valuetype = ESI_EXPR_EXPR;
/* invalid comparison */
return 1;
- stackpop(stack, depth); /* arg rhs */
+ stackpop(stack, depth); /* arg rhs */
- stackpop(stack, depth); /* me */
+ stackpop(stack, depth); /* me */
- stackpop(stack, depth); /* arg lhs */
+ stackpop(stack, depth); /* arg lhs */
srv.valuetype = ESI_EXPR_EXPR;
char const *origs = s;
/* trim whitespace */
s = trim(s);
- rv.eval = NULL; /* A literal */
+ rv.eval = NULL; /* A literal */
rv.valuetype = ESI_EXPR_INVALID;
rv.valuestored = ESI_LITERAL_INVALID;
rv.precedence = 1; /* A literal */
return stack[0].value.integral ? 1 : 0;
}
+
};
#endif /* SQUID_ESIEXPRESSION_H */
+
}
ESIInclude::ESIInclude(ESIInclude const &old) :
- varState(NULL),
- srcurl(NULL),
- alturl(NULL),
- parent(NULL),
- started(false),
- sent(false)
+ varState(NULL),
+ srcurl(NULL),
+ alturl(NULL),
+ parent(NULL),
+ started(false),
+ sent(false)
{
memset(&flags, 0, sizeof(flags));
flags.onerrorcontinue = old.flags.onerrorcontinue;
}
ESIInclude::ESIInclude(esiTreeParentPtr aParent, int attrcount, char const **attr, ESIContext *aContext) :
- varState(NULL),
- srcurl(NULL),
- alturl(NULL),
- parent(aParent),
- started(false),
- sent(false)
+ varState(NULL),
+ srcurl(NULL),
+ alturl(NULL),
+ parent(aParent),
+ started(false),
+ sent(false)
{
assert (aContext);
memset(&flags, 0, sizeof(flags));
}
#endif /* USE_SQUID_ESI == 1 */
+
};
#endif /* SQUID_ESIINCLUDE_H */
+
}
#endif /* USE_SQUID_ESI */
+
#endif /* USE_SQUID_ESI */
#endif /* SQUID_ESILIBXML2PARSER_H */
+
};
#endif /* SQUID_ESILITERAL_H */
+
delete prCustom;
prCustom = NULL;
}
+
} // namespace Esi
#endif /* SQUID_ESI_MODULE_H */
+
assert(ESIParser::Parsers == this);
ESIParser::Parsers = next;
}
+
#define EsiParserDefinition(ThisClass) \
ESIParser::Pointer ThisClass::NewParser(ESIParserClient *aClient) \
{ \
- return new ThisClass (aClient); \
+ return new ThisClass (aClient); \
}
#define EsiParserDeclaration \
static ESIParser::Pointer NewParser(ESIParserClient *aClient)
#endif /* SQUID_ESIPARSER_H */
+
temp.limitInit(buf, len);
debugs(86, 9, "ESISegment::dumpOne: \"" << temp << "\"");
}
+
void ESISegmentFreeList (ESISegment::Pointer &head);
#endif /* SQUID_ESISEGMENT_H */
+
}
esiSequence::esiSequence(esiTreeParentPtr aParent, bool incrementalFlag) :
- elements(),
- processedcount(0),
- parent(aParent),
- mayFail_(true),
- failed(false),
- provideIncrementalData(incrementalFlag),
- processing(false),
- processingResult(ESI_PROCESS_COMPLETE),
- nextElementToProcess_(0)
+ elements(),
+ processedcount(0),
+ parent(aParent),
+ mayFail_(true),
+ failed(false),
+ provideIncrementalData(incrementalFlag),
+ processing(false),
+ processingResult(ESI_PROCESS_COMPLETE),
+ nextElementToProcess_(0)
{
memset(&flags, 0, sizeof(flags));
}
}
esiSequence::esiSequence(esiSequence const &old) :
- processedcount(0),
- parent(NULL),
- mayFail_(old.mayFail_),
- failed(old.failed),
- provideIncrementalData(old.provideIncrementalData),
- processing(false),
- processingResult(ESI_PROCESS_COMPLETE),
- nextElementToProcess_(0)
+ processedcount(0),
+ parent(NULL),
+ mayFail_(old.mayFail_),
+ failed(old.failed),
+ provideIncrementalData(old.provideIncrementalData),
+ processing(false),
+ processingResult(ESI_PROCESS_COMPLETE),
+ nextElementToProcess_(0)
{
flags.dovars = old.flags.dovars;
}
}
#endif /* USE_SQUID_ESI == 1 */
+
};
#endif /* SQUID_ESISEQUENCE_H */
+
};
#endif /* SQUID_ESIVAR_H */
+
}
ESIVarState::ESIVarState(HttpHeader const *aHeader, char const *uri) :
- output(NULL),
- hdr(hoReply)
+ output(NULL),
+ hdr(hoReply)
{
memset(&flags, 0, sizeof(flags));
#define LOOKFORSTART 0
ESIVariableProcessor::ESIVariableProcessor(char *aString, ESISegment::Pointer &aSegment, Trie &aTrie, ESIVarState *aState) :
- string(aString), output (aSegment), variables(aTrie), varState (aState),
- state(LOOKFORSTART), pos(0), var_pos(0), done_pos(0), found_subref (NULL),
- found_default (NULL), currentFunction(NULL)
+ string(aString), output (aSegment), variables(aTrie), varState (aState),
+ state(LOOKFORSTART), pos(0), var_pos(0), done_pos(0), found_subref (NULL),
+ found_default (NULL), currentFunction(NULL)
{
len = strlen (string);
vartype = varState->GetVar("",0);
};
#endif /* SQUID_ESIVARSTATE_H */
+
#include "eui/Config.h"
Eui::EuiConfig Eui::TheConfig;
+
} // namespace Eui
#endif /* SQUID_EUI_CONFIG_H */
+
if (sscanf(asc, "%x:%x:%x:%x:%x:%x", &a1, &a2, &a3, &a4, &a5, &a6) != 6) {
debugs(28, DBG_CRITICAL, "Decode EUI-48: Invalid ethernet address '" << asc << "'");
clear();
- return false; /* This is not valid address */
+ return false; /* This is not valid address */
}
eui[0] = (u_char) a1;
/* ==== END EUI LOOKUP SUPPORT =============================================== */
#endif /* USE_SQUID_EUI */
+
#endif /* USE_SQUID_EUI */
#endif /* _SQUID_EUI_EUI48_H */
+
}
#endif /* USE_SQUID_EUI */
+
#endif /* USE_SQUID_EUI */
#endif /* _SQUID_EUI_EUI64_H */
+
};
EventDialer::EventDialer(EVH *aHandler, void *anArg, bool lockedArg):
- theHandler(aHandler), theArg(anArg), isLockedArg(lockedArg)
+ theHandler(aHandler), theArg(anArg), isLockedArg(lockedArg)
{
if (isLockedArg)
(void)cbdataReference(theArg);
}
EventDialer::EventDialer(const EventDialer &d):
- theHandler(d.theHandler), theArg(d.theArg), isLockedArg(d.isLockedArg)
+ theHandler(d.theHandler), theArg(d.theArg), isLockedArg(d.isLockedArg)
{
if (isLockedArg)
(void)cbdataReference(theArg);
ev_entry::ev_entry(char const * aName, EVH * aFunction, void * aArgument, double evWhen,
int aWeight, bool haveArgument) : name(aName), func(aFunction),
- arg(haveArgument ? cbdataReference(aArgument) : aArgument), when(evWhen), weight(aWeight),
- cbdata(haveArgument)
+ arg(haveArgument ? cbdataReference(aArgument) : aArgument), when(evWhen), weight(aWeight),
+ cbdata(haveArgument)
{
}
while (e != NULL) {
storeAppendPrintf(sentry, "%-25s\t%0.3f sec\t%5d\t %s\n",
e->name, e->when ? e->when - current_dtime : 0, e->weight,
- (e->arg && e->cbdata) ? cbdataReferenceValid(e->arg) ? "yes" : "no" : "N/A");
+ (e->arg && e->cbdata) ? cbdataReferenceValid(e->arg) ? "yes" : "no" : "N/A");
e = e->next;
}
}
event->next = *E;
*E = event;
}
+
};
#endif /* SQUID_EVENT_H */
+
*
* user= The users name (login)
* message= Message describing the reason
- * tag= A string tag to be applied to the request that triggered the acl match.
- * applies to both OK and ERR responses.
- * Won't override existing request tags.
- * log= A string to be used in access logging
+ * tag= A string tag to be applied to the request that triggered the acl match.
+ * applies to both OK and ERR responses.
+ * Won't override existing request tags.
+ * log= A string to be used in access logging
*
* Other keywords may be added to the protocol later
*
return false;
#endif
}
+
void fatal_dump(const char *message);
#endif /* SQUID_FATAL_H */
+
" due to failures (" << (Squid_MaxFD - newReserve) << "/" << Squid_MaxFD << " file descriptors available)");
RESERVED_FD = newReserve;
}
+
int default_write_method(int, const char *, int);
#endif /* SQUID_FD_H_ */
+
#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
#endif /* SQUID_FDE_H */
+
#define FM_INITIAL_NUMBER (1<<14)
FileMap::FileMap() :
- capacity_(FM_INITIAL_NUMBER), usedSlots_(0),
- nwords(capacity_ >> LONG_BIT_SHIFT)
+ capacity_(FM_INITIAL_NUMBER), usedSlots_(0),
+ nwords(capacity_ >> LONG_BIT_SHIFT)
{
debugs(8, 3, HERE << "creating space for " << capacity_ << " files");
debugs(8, 5, "--> " << nwords << " words of " << sizeof(*bitmap) << " bytes each");
int old_sz = nwords * sizeof(*bitmap);
void *old_map = bitmap;
capacity_ <<= 1;
- assert(capacity_ <= (1 << 24)); /* swap_filen is 25 bits, signed */
+ assert(capacity_ <= (1 << 24)); /* swap_filen is 25 bits, signed */
nwords = capacity_ >> LONG_BIT_SHIFT;
debugs(8, 3, HERE << " creating space for " << capacity_ << " files");
debugs(8, 5, "--> " << nwords << " words of " << sizeof(*bitmap) << " bytes each");
{
safe_free(bitmap);
}
+
* Bytecodes for the configureable format stuff
*/
typedef enum {
- LFT_NONE, /* dummy */
+ LFT_NONE, /* dummy */
/* arbitrary string between tokens */
LFT_STRING,
#endif
LFT_NOTE,
- LFT_PERCENT, /* special string cases for escaped chars */
+ LFT_PERCENT, /* special string cases for escaped chars */
// TODO assign better bytecode names and Token strings for these
LFT_EXT_ACL_USER_CERT_RAW,
} // namespace Format
#endif /* _SQUID_FMT_BYTECODE_H */
+
else
debugs(0, DBG_CRITICAL, "BUG: format tokens for '" << nsName << "' missing!");
}
+
#define dump_format(E,N,D) (D).dumpFormats((E),(N))
#endif
+
#define strOrNull(s) ((s)==NULL||(s)[0]=='\0'?NULL:(s))
Format::Format::Format(const char *n) :
- format(NULL),
- next(NULL)
+ format(NULL),
+ next(NULL)
{
name = xstrdup(n);
}
ByteCode_t type = t->type;
switch (type) {
- /* special cases */
+ /* special cases */
case LFT_STRING:
break;
char tmp[1024];
String sb;
- for (Token *fmt = format; fmt != NULL; fmt = fmt->next) { /* for each token */
+ for (Token *fmt = format; fmt != NULL; fmt = fmt->next) { /* for each token */
const char *out = NULL;
int quote = 0;
long int outint = 0;
case LFT_TIME_START:
outtv = al->cache.start_time;
doSec = 1;
- break;
+ break;
case LFT_TIME_TO_HANDLE_REQUEST:
outtv = al->cache.trTime;
out = strOrNull(al->cache.extuser);
break;
- /* case LFT_USER_REALM: */
- /* case LFT_USER_SCHEME: */
+ /* case LFT_USER_REALM: */
+ /* case LFT_USER_SCHEME: */
- // the fmt->type can not be LFT_HTTP_SENT_STATUS_CODE_OLD_30
- // but compiler complains if ommited
+ // the fmt->type can not be LFT_HTTP_SENT_STATUS_CODE_OLD_30
+ // but compiler complains if ommited
case LFT_HTTP_SENT_STATUS_CODE_OLD_30:
case LFT_HTTP_SENT_STATUS_CODE:
outint = al->http.code;
doint = 1;
}
break;
- /* case LFT_HTTP_STATUS:
- * out = statusline->text;
- * quote = 1;
- * break;
- */
+ /* case LFT_HTTP_STATUS:
+ * out = statusline->text;
+ * quote = 1;
+ * break;
+ */
case LFT_HTTP_BODY_BYTES_READ:
if (al->hier.bodyBytesRead >= 0) {
outoff = al->hier.bodyBytesRead;
dooff =1;
break;
- /*case LFT_REQUEST_SIZE_BODY: */
- /*case LFT_REQUEST_SIZE_BODY_NO_TE: */
+ /*case LFT_REQUEST_SIZE_BODY: */
+ /*case LFT_REQUEST_SIZE_BODY_NO_TE: */
case LFT_ADAPTED_REPLY_SIZE_TOTAL:
outoff = al->http.clientReplySz.messageTotal();
doint = 1;
break;
- /*case LFT_REPLY_SIZE_BODY: */
- /*case LFT_REPLY_SIZE_BODY_NO_TE: */
+ /*case LFT_REPLY_SIZE_BODY: */
+ /*case LFT_REPLY_SIZE_BODY_NO_TE: */
case LFT_CLIENT_IO_SIZE_TOTAL:
outint = al->http.clientRequestSz.messageTotal() + al->http.clientReplySz.messageTotal();
doint = 1;
break;
- /*case LFT_SERVER_IO_SIZE_TOTAL: */
+ /*case LFT_SERVER_IO_SIZE_TOTAL: */
case LFT_TAG:
if (al->request)
out = "%";
break;
- // XXX: external_acl_type format tokens which are not output by logformat.
- // They are listed here because the switch requires
- // every ByteCode_t to be explicitly enumerated.
- // But do not output due to lack of access to the values.
+ // XXX: external_acl_type format tokens which are not output by logformat.
+ // They are listed here because the switch requires
+ // every ByteCode_t to be explicitly enumerated.
+ // But do not output due to lack of access to the values.
case LFT_EXT_ACL_USER_CERT_RAW:
case LFT_EXT_ACL_USER_CERTCHAIN_RAW:
case LFT_EXT_ACL_USER_CERT:
safe_free(out);
}
}
+
} // namespace Format
#endif /* _SQUID_FORMAT_FORMAT_H */
+
*buf_cursor = '\0';
return buf;
}
+
}; // namespace Format
#endif /* _SQUID_FORMAT_QUOTING_H */
+
{"%", LFT_PERCENT},
- {NULL, LFT_NONE} /* this must be last */
+ {NULL, LFT_NONE} /* this must be last */
};
/// 2-char tokens
{">rv", LFT_CLIENT_REQ_VERSION},
{"rm", LFT_REQUEST_METHOD},
- {"ru", LFT_REQUEST_URI}, /* doesn't include the query-string */
+ {"ru", LFT_REQUEST_URI}, /* doesn't include the query-string */
{"rp", LFT_REQUEST_URLPATH_OLD_31},
/* { "rq", LFT_REQUEST_QUERY }, * / / * the query-string, INCLUDING the leading ? */
{"rv", LFT_REQUEST_VERSION},
{"ea", LFT_EXT_LOG},
{"sn", LFT_SEQUENCE_NUMBER},
- {NULL, LFT_NONE} /* this must be last */
+ {NULL, LFT_NONE} /* this must be last */
};
/// Miscellaneous >2 byte tokens
{"err_detail", LFT_SQUID_ERROR_DETAIL },
{"note", LFT_NOTE },
{"credentials", LFT_CREDENTIALS},
- {NULL, LFT_NONE} /* this must be last */
+ {NULL, LFT_NONE} /* this must be last */
};
#if USE_ADAPTATION
}
Format::Token::Token() : type(LFT_NONE),
- label(NULL),
- widthMin(-1),
- widthMax(-1),
- quote(LOG_QUOTE_NONE),
- left(false),
- space(false),
- zero(false),
- divisor(1),
- next(NULL)
+ label(NULL),
+ widthMin(-1),
+ widthMax(-1),
+ quote(LOG_QUOTE_NONE),
+ left(false),
+ space(false),
+ zero(false),
+ divisor(1),
+ next(NULL)
{
data.string = NULL;
data.header.header = NULL;
bool space;
bool zero;
int divisor; // class invariant: MUST NOT be zero.
- Token *next; /* todo: move from linked list to array */
+ Token *next; /* todo: move from linked list to array */
private:
const char *scanForToken(TokenTableEntry const table[], const char *cur);
} // namespace Format
#endif /* _SQUID_FORMAT_TOKEN_H */
+
} // namespace Format
#endif /* _SQUID_FORMAT_TOKENTABLEENTRY_H */
+
class fqdncache_entry
{
public:
- hash_link hash; /* must be first */
+ hash_link hash; /* must be first */
time_t lastref;
time_t expires;
unsigned char name_count;
/**
\ingroup FQDNCacheInternal
- \param name FQDN hash string.
+ \param name FQDN hash string.
\retval Match for given name
*/
static fqdncache_entry *
fqdncache_entry *t;
while (m) {
- if (i != NULL) { /* need to delay deletion */
- fqdncacheRelease(i); /* we just override locks */
+ if (i != NULL) { /* need to delay deletion */
+ fqdncacheRelease(i); /* we just override locks */
i = NULL;
}
/**
\ingroup FQDNCacheAPI
*
- \param addr IP address of domain to resolve.
- \param handler A pointer to the function to be called when
- * the reply from the FQDN cache
- * (or the DNS if the FQDN cache misses)
- \param handlerData Information that is passed to the handler
- * and does not affect the FQDN cache.
+ \param addr IP address of domain to resolve.
+ \param handler A pointer to the function to be called when
+ * the reply from the FQDN cache
+ * (or the DNS if the FQDN cache misses)
+ \param handlerData Information that is passed to the handler
+ * and does not affect the FQDN cache.
*/
void
fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH * handler, void *handlerData)
* DNS, unless this is requested, by setting the flags
* to FQDN_LOOKUP_IF_MISS.
*
- \param addr address of the FQDN being resolved
- \param flags values are NULL or FQDN_LOOKUP_IF_MISS. default is NULL.
+ \param addr address of the FQDN being resolved
+ \param flags values are NULL or FQDN_LOOKUP_IF_MISS. default is NULL.
*
*/
const char *
* The worldist is to be managed by the caller,
* including pointed-to strings
*
- \param addr FQDN name to be added.
- \param hostnames ??
+ \param addr FQDN name to be added.
+ \param hostnames ??
*/
void
fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames)
}
fce->name_count = j;
- fce->names[j] = NULL; /* it's safe */
+ fce->names[j] = NULL; /* it's safe */
fce->flags.fromhosts = true;
fqdncacheAddEntry(fce);
fqdncacheLockEntry(fce);
}
#endif /*SQUID_SNMP */
+
void fqdncache_nbgethostbyaddr(const Ip::Address &, FQDNH *, void *);
#endif /* SQUID_FQDNCACHE_H_ */
+
} // namespace Fs
#endif /* SQUID_FS_MODULE_H */
+
*/
/* Unused variable: */
+
/* Unused variable: */
Fs::Ufs::StoreFSufs<Fs::Ufs::UFSSwapDir> *DiskdInstance_foo = NULL;
+
{
memset(this, 0, sizeof(*this));
}
+
} // namespace Rock
#endif /* SQUID_FS_ROCK_DB_CELL_H */
+
}
#endif /* SQUID_FS_ROCK_FORWARD_H */
+
Rock::ReadRequest::ReadRequest(const ::ReadRequest &base,
const IoState::Pointer &anSio):
- ::ReadRequest(base),
- sio(anSio)
+ ::ReadRequest(base),
+ sio(anSio)
{
}
Rock::WriteRequest::WriteRequest(const ::WriteRequest &base,
const IoState::Pointer &anSio):
- ::WriteRequest(base),
- sio(anSio),
- sidCurrent(-1),
- sidNext(-1),
- eof(false)
+ ::WriteRequest(base),
+ sio(anSio),
+ sidCurrent(-1),
+ sidNext(-1),
+ eof(false)
{
}
+
} // namespace Rock
#endif /* SQUID_FS_ROCK_IO_REQUESTS_H */
+
StoreIOState::STFNCB *cbFile,
StoreIOState::STIOCB *cbIo,
void *data):
- readableAnchor_(NULL),
- writeableAnchor_(NULL),
- sidCurrent(-1),
- dir(aDir),
- slotSize(dir->slotSize),
- objOffset(0),
- theBuf(dir->slotSize)
+ readableAnchor_(NULL),
+ writeableAnchor_(NULL),
+ sidCurrent(-1),
+ dir(aDir),
+ slotSize(dir->slotSize),
+ objOffset(0),
+ theBuf(dir->slotSize)
{
e = anEntry;
e->lock("rock I/O");
{
public:
StoreIOStateCb(StoreIOState::STIOCB *cb, void *data, int err, const Rock::IoState::Pointer &anSio):
- callback(NULL),
- callback_data(NULL),
- errflag(err),
- sio(anSio) {
+ callback(NULL),
+ callback_data(NULL),
+ errflag(err),
+ sio(anSio) {
callback = cb;
callback_data = cbdataReference(data);
}
StoreIOStateCb(const StoreIOStateCb &cb):
- callback(NULL),
- callback_data(NULL),
- errflag(cb.errflag),
- sio(cb.sio) {
+ callback(NULL),
+ callback_data(NULL),
+ errflag(cb.errflag),
+ sio(cb.sio) {
callback = cb.callback;
callback_data = cbdataReference(cb.callback_data);
} // namespace Rock
#endif /* SQUID_FS_ROCK_IO_STATE_H */
+
{
public:
LoadingEntry(): size(0), version(0), state(leEmpty), anchored(0),
- mapped(0), freed(0), more(-1) {}
+ mapped(0), freed(0), more(-1) {}
/* store entry-level information indexed by sfileno */
uint64_t size; ///< payload seen so far
} /* namespace Rock */
Rock::Rebuild::Rebuild(SwapDir *dir): AsyncJob("Rock::Rebuild"),
- sd(dir),
- entries(NULL),
- dbSize(0),
- dbSlotSize(0),
- dbSlotLimit(0),
- dbEntryLimit(0),
- fd(-1),
- dbOffset(0),
- loadingPos(0),
- validationPos(0)
+ sd(dir),
+ entries(NULL),
+ dbSize(0),
+ dbSlotSize(0),
+ dbSlotLimit(0),
+ dbEntryLimit(0),
+ fd(-1),
+ dbOffset(0),
+ loadingPos(0),
+ validationPos(0)
{
assert(sd);
memset(&counts, 0, sizeof(counts));
}
}
}
+
} // namespace Rock
#endif /* SQUID_FS_ROCK_REBUILD_H */
+
{
assert(false); // XXX: implement
}
+
} // namespace Rock
#endif /* SQUID_FS_ROCK_FS_H */
+
const int64_t Rock::SwapDir::HeaderSize = 16*1024;
Rock::SwapDir::SwapDir(): ::SwapDir("rock"),
- slotSize(HeaderSize), filePath(NULL), map(NULL), io(NULL),
- waitingForPage(NULL)
+ slotSize(HeaderSize), filePath(NULL), map(NULL), io(NULL),
+ waitingForPage(NULL)
{
}
sfileno filen;
const Ipc::StoreMapAnchor *const slot = map->openForReading(
- reinterpret_cast<cache_key*>(collapsed.key), filen);
+ reinterpret_cast<cache_key*>(collapsed.key), filen);
if (!slot)
return false;
delete freeSlotsOwners[i];
}
}
+
} // namespace Rock
#endif /* SQUID_FS_ROCK_SWAP_DIR_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Fs::Ufs,RebuildState);
Fs::Ufs::RebuildState::RebuildState(RefCount<UFSSwapDir> aSwapDir) :
- sd (aSwapDir), LogParser(NULL), e(NULL), fromLog(true), _done (false)
+ sd (aSwapDir), LogParser(NULL), e(NULL), fromLog(true), _done (false)
{
/*
* If the swap.state file exists in the cache_dir, then
{
return currentEntry();
}
+
} /* namespace Fs */
#endif /* SQUID_FS_UFS_REBUILDSTATE_H */
+
/* Unused variable: */
Fs::Ufs::StoreFSufs<Fs::Ufs::UFSSwapDir> *UfsInstance_foo = NULL;
+
#define SQUID_STOREFSUFS_H
/**
- \defgroup UFS UFS Storage Filesystem
+ \defgroup UFS UFS Storage Filesystem
\ingroup FileSystems
*/
} /* namespace Fs */
#endif /* SQUID_STOREFSUFS_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Fs::Ufs,StoreSearchUFS);
Fs::Ufs::StoreSearchUFS::StoreSearchUFS(RefCount<UFSSwapDir> aSwapDir) :
- sd(aSwapDir), walker (sd->repl->WalkInit(sd->repl)),
- current (NULL), _done (false)
+ sd(aSwapDir), walker (sd->repl->WalkInit(sd->repl)),
+ current (NULL), _done (false)
{}
Fs::Ufs::StoreSearchUFS::~StoreSearchUFS()
{
return current;
}
+
} //namespace Ufs
} //namespace Fs
#endif /* SQUID_FS_UFS_STORESEARCHUFS_H */
+
* us that the file has been closed. This must be the last line,
* as theFile may be the only object holding us in memory.
*/
- theFile = NULL; // refcounted
+ theFile = NULL; // refcounted
}
/* ============= THE REAL UFS CODE ================ */
/*
* DPW 2006-05-24
- * This blows. DiskThreadsDiskFile::close() won't actually do the close
+ * This blows. DiskThreadsDiskFile::close() won't actually do the close
* if ioInProgress() is true. So we have to check it here. Maybe someday
* DiskThreadsDiskFile::close() will be modified to have a return value,
* or will remember to do the close for us.
} //namespace Fs
#endif /* SQUID_FS_UFS_UFSSTORESTATE_H */
+
{
io->statfs(sentry);
}
+
} //namespace Fs
#endif /* SQUID_FS_UFS_UFSSTRATEGY_H */
+
};
UFSCleanLog::UFSCleanLog(SwapDir *aSwapDir) :
- cur(NULL), newLog(NULL), cln(NULL), outbuf(NULL),
- outbuf_offset(0), fd(-1),walker(NULL), sd(aSwapDir)
+ cur(NULL), newLog(NULL), cln(NULL), outbuf(NULL),
+ outbuf_offset(0), fd(-1),walker(NULL), sd(aSwapDir)
{}
const StoreEntry *
}
Fs::Ufs::UFSSwapDir::UFSSwapDir(char const *aType, const char *anIOType) :
- SwapDir(aType),
- IO(NULL),
- fsdata(NULL),
- map(new FileMap()),
- suggest(0),
- l1(16),
- l2(256),
- swaplog_fd(-1),
- currentIOOptions(new ConfigOptionVector()),
- ioType(xstrdup(anIOType)),
- cur_size(0),
- n_disk_objects(0)
+ SwapDir(aType),
+ IO(NULL),
+ fsdata(NULL),
+ map(new FileMap()),
+ suggest(0),
+ l1(16),
+ l2(256),
+ swaplog_fd(-1),
+ currentIOOptions(new ConfigOptionVector()),
+ ioType(xstrdup(anIOType)),
+ cur_size(0),
+ n_disk_objects(0)
{
/* modulename is only set to disk modules that are built, by configure,
* so the Find call should never return NULL here.
debugs(36, 3, HERE << "Cleaned " << k << " unused files from " << p1);
return k;
}
+
} //namespace Ufs
} //namespace Fs
#endif /* SQUID_FS_UFS_UFSSWAPDIR_H */
+
} //namespace Ufs
} //namespace Fs
#endif /* SQUID_FS_UFS_UFSSWAPLOGPARSER_H */
+
static const SBuf cmd("USER");
return cmd;
}
+
} // namespace Ftp
#endif /* SQUID_FTP_ELEMENTS_H */
+
}
return path.content();
}
+
} // namespace Ftp
#endif /* SQUID_FTP_PARSING_H */
+
#include "rfc2181.h"
#include "SBuf.h"
-extern char *ConfigFile; /* NULL */
+extern char *ConfigFile; /* NULL */
extern char *IcpOpcodeStr[];
extern char tmp_error_buf[ERROR_BUF_SZ];
extern char ThisCache[RFC2181_MAXHOSTNAMELEN << 1];
extern char config_input_line[BUFSIZ];
/// During parsing, the name of the current squid.conf directive being parsed.
extern const char *cfg_directive; /* NULL */
-extern const char *DefaultConfigFile; /* DEFAULT_CONFIG_FILE */
-extern const char *cfg_filename; /* NULL */
-extern const char *dash_str; /* "-" */
-extern const char *null_string; /* "" */
-extern const char *version_string; /* VERSION */
-extern const char *appname_string; /* PACKAGE */
+extern const char *DefaultConfigFile; /* DEFAULT_CONFIG_FILE */
+extern const char *cfg_filename; /* NULL */
+extern const char *dash_str; /* "-" */
+extern const char *null_string; /* "" */
+extern const char *version_string; /* VERSION */
+extern const char *appname_string; /* PACKAGE */
extern char const *visible_appname_string; /* NULL */
extern const char *fdTypeStr[];
extern const char *hier_strings[];
extern const char *pingStatusStr[];
extern const char *storeStatusStr[];
extern const char *swapStatusStr[];
-extern int Biggest_FD; /* -1 */
-extern int Number_FD; /* 0 */
-extern int Opening_FD; /* 0 */
-extern int NDnsServersAlloc; /* 0 */
+extern int Biggest_FD; /* -1 */
+extern int Number_FD; /* 0 */
+extern int Opening_FD; /* 0 */
+extern int NDnsServersAlloc; /* 0 */
extern int RESERVED_FD;
-extern int Squid_MaxFD; /* SQUID_MAXFD */
-extern int config_lineno; /* 0 */
-extern int opt_reuseaddr; /* 1 */
-extern int neighbors_do_private_keys; /* 1 */
-extern int opt_catch_signals; /* 1 */
-extern int opt_foreground_rebuild; /* 0 */
-extern char *opt_forwarded_for; /* NULL */
-extern int opt_reload_hit_only; /* 0 */
+extern int Squid_MaxFD; /* SQUID_MAXFD */
+extern int config_lineno; /* 0 */
+extern int opt_reuseaddr; /* 1 */
+extern int neighbors_do_private_keys; /* 1 */
+extern int opt_catch_signals; /* 1 */
+extern int opt_foreground_rebuild; /* 0 */
+extern char *opt_forwarded_for; /* NULL */
+extern int opt_reload_hit_only; /* 0 */
-extern int opt_udp_hit_obj; /* 0 */
-extern int opt_create_swap_dirs; /* 0 */
-extern int opt_store_doublecheck; /* 0 */
-extern int syslog_enable; /* 0 */
-extern int DnsSocketA; /* -1 */
-extern int DnsSocketB; /* -1 */
-extern int n_disk_objects; /* 0 */
+extern int opt_udp_hit_obj; /* 0 */
+extern int opt_create_swap_dirs; /* 0 */
+extern int opt_store_doublecheck; /* 0 */
+extern int syslog_enable; /* 0 */
+extern int DnsSocketA; /* -1 */
+extern int DnsSocketB; /* -1 */
+extern int n_disk_objects; /* 0 */
extern IoStats IOStats;
-extern AclDenyInfoList *DenyInfoList; /* NULL */
+extern AclDenyInfoList *DenyInfoList; /* NULL */
extern struct timeval squid_start;
-extern int starting_up; /* 1 */
-extern int shutting_down; /* 0 */
-extern int reconfiguring; /* 0 */
-extern time_t hit_only_mode_until; /* 0 */
-extern double request_failure_ratio; /* 0.0 */
-extern int store_hash_buckets; /* 0 */
-extern hash_table *store_table; /* NULL */
-extern int hot_obj_count; /* 0 */
-extern int CacheDigestHashFuncCount; /* 4 */
-extern CacheDigest *store_digest; /* NULL */
-extern const char *StoreDigestFileName; /* "store_digest" */
-extern const char *StoreDigestMimeStr; /* "application/cache-digest" */
+extern int starting_up; /* 1 */
+extern int shutting_down; /* 0 */
+extern int reconfiguring; /* 0 */
+extern time_t hit_only_mode_until; /* 0 */
+extern double request_failure_ratio; /* 0.0 */
+extern int store_hash_buckets; /* 0 */
+extern hash_table *store_table; /* NULL */
+extern int hot_obj_count; /* 0 */
+extern int CacheDigestHashFuncCount; /* 4 */
+extern CacheDigest *store_digest; /* NULL */
+extern const char *StoreDigestFileName; /* "store_digest" */
+extern const char *StoreDigestMimeStr; /* "application/cache-digest" */
-extern const char *MultipartMsgBoundaryStr; /* "Unique-Squid-Separator" */
+extern const char *MultipartMsgBoundaryStr; /* "Unique-Squid-Separator" */
#if USE_HTTP_VIOLATIONS
-extern int refresh_nocache_hack; /* 0 */
+extern int refresh_nocache_hack; /* 0 */
#endif
-extern int store_open_disk_fd; /* 0 */
+extern int store_open_disk_fd; /* 0 */
extern const char *SwapDirType[];
-extern int store_swap_low; /* 0 */
-extern int store_swap_high; /* 0 */
-extern size_t store_pages_max; /* 0 */
-extern int64_t store_maxobjsize; /* 0 */
-extern hash_table *proxy_auth_username_cache; /* NULL */
+extern int store_swap_low; /* 0 */
+extern int store_swap_high; /* 0 */
+extern size_t store_pages_max; /* 0 */
+extern int64_t store_maxobjsize; /* 0 */
+extern hash_table *proxy_auth_username_cache; /* NULL */
extern int incoming_sockets_accepted;
#if _SQUID_WINDOWS_
-extern unsigned int WIN32_Socks_initialized; /* 0 */
+extern unsigned int WIN32_Socks_initialized; /* 0 */
#endif
#if _SQUID_WINDOWS_
-extern unsigned int WIN32_OS_version; /* 0 */
+extern unsigned int WIN32_OS_version; /* 0 */
extern char *WIN32_OS_string; /* NULL */
extern char *WIN32_Command_Line; /* NULL */
extern char *WIN32_Service_Command_Line; /* NULL */
extern unsigned int WIN32_run_mode; /* _WIN_SQUID_RUN_MODE_INTERACTIVE */
#endif
-extern int ssl_ex_index_server; /* -1 */
+extern int ssl_ex_index_server; /* -1 */
extern int ssl_ctx_ex_index_dont_verify_domain; /* -1 */
-extern int ssl_ex_index_cert_error_check; /* -1 */
+extern int ssl_ex_index_cert_error_check; /* -1 */
extern int ssl_ex_index_ssl_error_detail; /* -1 */
extern int ssl_ex_index_ssl_peeked_cert; /* -1 */
extern int ssl_ex_index_ssl_errors; /* -1 */
extern int ssl_ex_index_ssl_validation_counter; /* -1 */
extern const char *external_acl_message; /* NULL */
-extern int opt_send_signal; /* -1 */
+extern int opt_send_signal; /* -1 */
extern int opt_no_daemon; /* 0 */
extern int opt_parse_cfg_only; /* 0 */
extern int KidIdentifier; /* 0 */
#endif /* SQUID_GLOBALS_H */
+
char request[MAX_URL];
int cso_recno;
int len;
- char *buf; /* pts to a 4k page */
+ char *buf; /* pts to a 4k page */
Comm::ConnectionPointer serverConn;
FwdState::Pointer fwd;
char replybuf[BUFSIZ];
/**
* Parse the request to determine whether it is cachable.
*
- * \param req Request data.
- * \retval 0 Not cachable.
- * \retval 1 Cachable.
+ * \param req Request data.
+ * \retval 0 Not cachable.
+ * \retval 1 Cachable.
*/
int
gopherCachable(const HttpRequest * req)
junk = strchr(host, TAB);
if (junk)
- *junk++ = 0; /* Chop port */
+ *junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\r');
if (junk)
- *junk++ = 0; /* Chop port */
+ *junk++ = 0; /* Chop port */
else {
junk = strchr(host, '\n');
if (junk)
- *junk++ = 0; /* Chop port */
+ *junk++ = 0; /* Chop port */
}
}
if ((port[1] == '0') && (!port[2]))
- port[0] = 0; /* 0 means none */
+ port[0] = 0; /* 0 means none */
}
/* escape a selector here */
}
break;
- } /* HTML_DIR, HTML_INDEX_RESULT */
+ } /* HTML_DIR, HTML_INDEX_RESULT */
case GopherStateData::HTML_CSO_RESULT: {
if (line[0] == '-') {
break;
}
- case 102: /* Number of matches */
+ case 102: /* Number of matches */
- case 501: /* No Match */
+ case 501: /* No Match */
- case 502: { /* Too Many Matches */
+ case 502: { /* Too Many Matches */
/* Print the message the server returns */
snprintf(tmpbuf, TEMP_BUF_SIZE, "</PRE><HR noshade size=\"1px\"><H2>%s</H2>\n<PRE>", html_quote(result));
outbuf.append(tmpbuf);
}
}
- } /* HTML_CSO_RESULT */
+ } /* HTML_CSO_RESULT */
default:
- break; /* do nothing */
+ break; /* do nothing */
- } /* switch */
+ } /* switch */
- } /* while loop */
+ } /* while loop */
if (outbuf.size() > 0) {
entry->append(outbuf.rawBuf(), outbuf.size());
gopherState->serverConn->close();
if (buf)
- memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
+ memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
return;
}
entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);
if (buf)
- memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
+ memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
}
/**
const char *t = strchr(gopherState->request, '?');
if (t != NULL)
- ++t; /* skip the ? */
+ ++t; /* skip the ? */
else
t = "";
CommTimeoutCbPtrFun(gopherTimeout, gopherState));
commSetConnTimeout(fwd->serverConnection(), Config.Timeout.read, timeoutCall);
}
+
int gopherCachable(const HttpRequest *);
#endif /* SQUID_GOPHER_H_ */
+
AsyncCall::Pointer closeCall = asyncCall(5,4, "helperServerFree", cbdataDialer(helperServerFree, srv));
comm_add_close_handler(rfd, closeCall);
- if (hlp->timeout && hlp->childs.concurrency){
+ if (hlp->timeout && hlp->childs.concurrency) {
AsyncCall::Pointer timeoutCall = commCbCall(84, 4, "helper_server::requestTimeout",
- CommTimeoutCbPtrFun(helper_server::requestTimeout, srv));
+ CommTimeoutCbPtrFun(helper_server::requestTimeout, srv));
commSetConnTimeout(srv->readPipe, hlp->timeout, timeoutCall);
}
-
AsyncCall::Pointer call = commCbCall(5,4, "helperHandleRead",
CommIoCbPtrFun(helperHandleRead, srv));
comm_read(srv->readPipe, srv->rbuf, srv->rbuf_sz - 1, call);
srv->flags.reserved ? 'R' : ' ',
srv->flags.shutdown ? 'S' : ' ',
srv->request ? (srv->request->placeholder ? 'P' : ' ') : ' ',
- tt < 0.0 ? 0.0 : tt,
- (int) srv->roffset,
- srv->request ? Format::QuoteMimeBlob(srv->request->buf) : "(none)");
+ tt < 0.0 ? 0.0 : tt,
+ (int) srv->roffset,
+ srv->request ? Format::QuoteMimeBlob(srv->request->buf) : "(none)");
}
storeAppendPrintf(sentry, "\nFlags key:\n\n");
assert(hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- srv->flags.shutdown = true; /* request it to shut itself down */
+ srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->flags.closing) {
debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index << " is CLOSING.");
assert(hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- srv->flags.shutdown = true; /* request it to shut itself down */
+ srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->stats.pending) {
debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " is BUSY.");
hlp->submitRequest(r);
} else
delete r;
- } else if (srv->stats.timedout){
+ } else if (srv->stats.timedout) {
debugs(84, 3, "Timedout reply received for request-ID: " << request_number << " , ignore");
} else {
debugs(84, DBG_IMPORTANT, "helperHandleRead: unexpected reply on channel " <<
} else if (cbdataReferenceValidDone(r->data, &cbdata)) {
if (!parent->onTimedOutResponse.isEmpty()) {
// Helper::Reply needs a non const buffer
- char *replyMsg = xstrdup(parent->onTimedOutResponse.c_str());
+ char *replyMsg = xstrdup(parent->onTimedOutResponse.c_str());
r->callback(cbdata, Helper::Reply(replyMsg, strlen(replyMsg)));
xfree(replyMsg);
} else
debugs(84, 3, HERE << io.conn << " establish new helper_server::requestTimeout");
AsyncCall::Pointer timeoutCall = commCbCall(84, 4, "helper_server::requestTimeout",
- CommTimeoutCbPtrFun(helper_server::requestTimeout, srv));
+ CommTimeoutCbPtrFun(helper_server::requestTimeout, srv));
const int timeSpent = srv->requests.empty() ? 0 : (squid_curtime - srv->requests.front()->dispatch_time.tv_sec);
const int timeLeft = max(1, (static_cast<int>(srv->parent->timeout) - timeSpent));
commSetConnTimeout(io.conn, timeLeft, timeoutCall);
}
+
public:
inline helper(const char *name) :
- cmdline(NULL),
- id_name(name),
- ipc_type(0),
- full_time(0),
- last_queue_warn(0),
- last_restart(0),
- timeout(0),
- retryTimedOut(false),
- retryBrokenHelper(false),
- eom('\n') {
+ cmdline(NULL),
+ id_name(name),
+ ipc_type(0),
+ full_time(0),
+ last_queue_warn(0),
+ last_restart(0),
+ timeout(0),
+ retryTimedOut(false),
+ retryBrokenHelper(false),
+ eom('\n') {
memset(&stats, 0, sizeof(stats));
}
~helper();
///< If not full, submit request. Otherwise, either kill Squid or return false.
bool trySubmit(const char *buf, HLPCB * callback, void *data);
- /// Submits a request to the helper or add it to the queue if none of
+ /// Submits a request to the helper or add it to the queue if none of
/// the servers is available.
void submitRequest(Helper::Request *r);
public:
/// or the configured "on timeout response" for timedout requests.
void checkForTimedOutRequests(bool const retry);
- /// Read timeout handler
+ /// Read timeout handler
static void requestTimeout(const CommTimeoutCbParams &io);
};
statefulhelper *parent;
Helper::Request *request;
- void *data; /* State data used by the calling routines */
+ void *data; /* State data used by the calling routines */
};
/* helper.c */
void *helperStatefulServerGetData(helper_stateful_server * srv);
#endif /* SQUID_HELPER_H */
+
#include <cstring>
Helper::ChildConfig::ChildConfig():
- n_max(0),
- n_startup(0),
- n_idle(1),
- concurrency(0),
- n_running(0),
- n_active(0),
- queue_size(0),
- defaultQueueSize(true)
+ n_max(0),
+ n_startup(0),
+ n_idle(1),
+ concurrency(0),
+ n_running(0),
+ n_active(0),
+ queue_size(0),
+ defaultQueueSize(true)
{}
Helper::ChildConfig::ChildConfig(const unsigned int m):
- n_max(m),
- n_startup(0),
- n_idle(1),
- concurrency(0),
- n_running(0),
- n_active(0),
- queue_size(2 * m),
- defaultQueueSize(true)
+ n_max(m),
+ n_startup(0),
+ n_idle(1),
+ concurrency(0),
+ n_running(0),
+ n_active(0),
+ queue_size(2 * m),
+ defaultQueueSize(true)
{}
Helper::ChildConfig &
debugs(0, DBG_CRITICAL, "WARNING OVERIDE: Capping idle=" << n_idle << " to the defined maximum (" << n_max <<")");
n_idle = n_max;
}
-
+
if (defaultQueueSize)
queue_size = 2 * n_max;
}
+
#define free_HelperChildConfig(dummy) // NO.
#endif /* _SQUID_SRC_HELPER_CHILDCONFIG_H */
+
#include "SquidString.h"
Helper::Reply::Reply(char *buf, size_t len) :
- result(Helper::Unknown),
- whichServer(NULL)
+ result(Helper::Unknown),
+ whichServer(NULL)
{
parse(buf,len);
}
return os;
}
+
std::ostream &operator <<(std::ostream &os, const Helper::Reply &r);
#endif /* _SQUID_SRC_HELPER_REPLY_H */
+
public:
Request(HLPCB *c, void *d, const char *b) :
- buf(b ? xstrdup(b) : NULL),
- callback(c),
- data(cbdataReference(d)),
- placeholder(b == NULL),
- Id(0),
- retries(0)
+ buf(b ? xstrdup(b) : NULL),
+ callback(c),
+ data(cbdataReference(d)),
+ placeholder(b == NULL),
+ Id(0),
+ retries(0)
{
memset(&dispatch_time, 0, sizeof(dispatch_time));
}
} // namespace Helper
#endif /* _SQUID_SRC_HELPER_REQUEST_H */
+
} // namespace Helper
#endif /* _SQUID_SRC_HELPER_RESULTCODE_H */
+
typedef void HLPCB(void *, const Helper::Reply &);
#endif /* SQUID_SRC_HELPER_FORWARD_H */
+
inline hier_code operator++(hier_code &i) { return i = (hier_code)(1+(int)i); }
#endif /* SQUID__HIER_CODE_H */
+
public:
htcpSpecifier() :
- method(NULL),
- uri(NULL),
- version(NULL),
- req_hdrs(NULL),
- reqHdrsSz(0),
- request(NULL),
- checkHitRequest(NULL),
- dhdr(NULL)
+ method(NULL),
+ uri(NULL),
+ version(NULL),
+ req_hdrs(NULL),
+ reqHdrsSz(0),
+ request(NULL),
+ checkHitRequest(NULL),
+ dhdr(NULL)
{}
// XXX: destructor?
debugs(31, 3, "htcpBuildTstOpData: RR_RESPONSE");
debugs(31, 3, "htcpBuildTstOpData: F1 = " << stuff->f1);
- if (stuff->f1) /* cache miss */
+ if (stuff->f1) /* cache miss */
return 0;
- else /* cache hit */
+ else /* cache hit */
return htcpBuildDetail(buf, buflen, stuff);
default:
if (buflen < hdr_sz)
return -1;
- off += hdr_sz; /* skip! */
+ off += hdr_sz; /* skip! */
op_data_sz = htcpBuildOpData(buf + off, buflen - off, stuff);
}
HtcpReplyData::HtcpReplyData() :
- hit(0), hdr(hoHtcpReply), msg_id(0), version(0.0)
+ hit(0), hdr(hoHtcpReply), msg_id(0), version(0.0)
{
memset(&cto, 0, sizeof(cto));
}
htcpSpecifier::checkedHit(StoreEntry *e)
{
if (e) {
- htcpTstReply(dhdr, e, this, from); /* hit */
+ htcpTstReply(dhdr, e, this, from); /* hit */
htcpLogHtcp(from, dhdr->opcode, LOG_UDP_HIT, uri);
} else {
- htcpTstReply(dhdr, NULL, NULL, from); /* cache miss */
+ htcpTstReply(dhdr, NULL, NULL, from); /* cache miss */
htcpLogHtcp(from, dhdr->opcode, LOG_UDP_MISS, uri);
}
switch (htcpClrStore(s)) {
case 1:
- htcpClrReply(hdr, 1, from); /* hit */
+ htcpClrReply(hdr, 1, from); /* hit */
htcpLogHtcp(from, hdr->opcode, LOG_UDP_HIT, s->uri);
break;
case 0:
- htcpClrReply(hdr, 0, from); /* miss */
+ htcpClrReply(hdr, 0, from); /* miss */
htcpLogHtcp(from, hdr->opcode, LOG_UDP_MISS, s->uri);
break;
al->cache.trTime.tv_usec = 0;
accessLogLog(al, NULL);
}
+
* \param p
* \retval 1 Successfully sent request.
* \retval 0 Unable to send request at this time. HTCP may be shutting down or starting up.
- * Don't wait for a reply or count in stats as sent.
+ * Don't wait for a reply or count in stats as sent.
* \retval -1 Error sending request.
*/
int htcpQuery(StoreEntry * e, HttpRequest * req, CachePeer * p);
#endif /* USE_HTCP */
#endif /* SQUID_HTCP_H */
+
#define SQUID_ENTER_THROWING_CODE() try {
#define SQUID_EXIT_THROWING_CODE(status) \
- status = true; \
+ status = true; \
} \
catch (const std::exception &e) { \
- debugs (11, 1, "Exception error:" << e.what()); \
- status = false; \
+ debugs (11, 1, "Exception error:" << e.what()); \
+ status = false; \
}
CBDATA_CLASS_INIT(HttpStateData);
void httpHdrAdd(HttpHeader *heads, HttpRequest *request, const AccessLogEntryPointer &al, HeaderWithAclList &headers_add);
HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob("HttpStateData"), Client(theFwdState),
- lastChunk(0), header_bytes_read(0), reply_bytes_read(0),
- body_bytes_truncated(0), httpChunkDecoder(NULL)
+ lastChunk(0), header_bytes_read(0), reply_bytes_read(0),
+ body_bytes_truncated(0), httpChunkDecoder(NULL)
{
debugs(11,5,HERE << "HttpStateData " << this << " created");
ignoreCacheControl = false;
}
switch (rep->sline.status()) {
- /* Responses that are cacheable */
+ /* Responses that are cacheable */
case Http::scOkay:
/* NOTREACHED */
break;
- /* Responses that only are cacheable if the server says so */
+ /* Responses that only are cacheable if the server says so */
case Http::scFound:
case Http::scTemporaryRedirect:
/* NOTREACHED */
break;
- /* Errors can be negatively cached */
+ /* Errors can be negatively cached */
case Http::scNoContent:
/* NOTREACHED */
break;
- /* Some responses can never be cached */
+ /* Some responses can never be cached */
- case Http::scPartialContent: /* Not yet supported */
+ case Http::scPartialContent: /* Not yet supported */
case Http::scSeeOther:
case Http::scProxyAuthenticationRequired:
- case Http::scInvalidHeader: /* Squid header parsing error */
+ case Http::scInvalidHeader: /* Squid header parsing error */
case Http::scHeaderTooLarge:
switch (e->id) {
- /** \par RFC 2616 sect 13.5.1 - Hop-by-Hop headers which Squid should not pass on. */
+ /** \par RFC 2616 sect 13.5.1 - Hop-by-Hop headers which Squid should not pass on. */
case HDR_PROXY_AUTHORIZATION:
/** \par Proxy-Authorization:
}
break;
- /** \par RFC 2616 sect 13.5.1 - Hop-by-Hop headers which Squid does not pass on. */
+ /** \par RFC 2616 sect 13.5.1 - Hop-by-Hop headers which Squid does not pass on. */
case HDR_CONNECTION: /** \par Connection: */
case HDR_TE: /** \par TE: */
case HDR_TRANSFER_ENCODING: /** \par Transfer-Encoding: */
break;
- /** \par OTHER headers I haven't bothered to track down yet. */
+ /** \par OTHER headers I haven't bothered to track down yet. */
case HDR_AUTHORIZATION:
/** \par WWW-Authorization:
fwd->handleUnregisteredServerEnd();
mustStop("HttpStateData::abortTransaction");
}
+
// Determine whether the response is a cacheable representation
int cacheableReply();
- CachePeer *_peer; /* CachePeer request made to */
- int eof; /* reached end-of-object? */
- int lastChunk; /* reached last chunk of a chunk-encoded reply */
+ CachePeer *_peer; /* CachePeer request made to */
+ int eof; /* reached end-of-object? */
+ int lastChunk; /* reached last chunk of a chunk-encoded reply */
HttpStateFlags flags;
size_t read_sz;
- int header_bytes_read; // to find end of response,
- int64_t reply_bytes_read; // without relying on StoreEntry
+ int header_bytes_read; // to find end of response,
+ int64_t reply_bytes_read; // without relying on StoreEntry
int body_bytes_truncated; // positive when we read more than we wanted
MemBuf *readBuf;
bool ignoreCacheControl;
const char *httpMakeVaryMark(HttpRequest * request, HttpReply const * reply);
#endif /* SQUID_HTTP_H */
+
}; // namespace Http
#endif /* SQUID_SRC_HTTP_METHODTYPE_H */
+
inline AnyP::ProtocolVersion
ProtocolVersion()
{
- return AnyP::ProtocolVersion(AnyP::PROTO_HTTP,1,1);
+ return AnyP::ProtocolVersion(AnyP::PROTO_HTTP,1,1);
}
}; // namespace Http
#endif /* SQUID_HTTP_PROTOCOLVERSION_H */
+
} http_hdr_type;
#endif /* SQUID_HTTP_REGISTEREDHEADERS_H */
+
// checking and adding. If only to say it is known to define none.
switch (theMethod) {
- // RFC 2068 - none
+ // RFC 2068 - none
- // RFC 2616 section 9.1.1
+ // RFC 2616 section 9.1.1
case Http::METHOD_GET:
case Http::METHOD_HEAD:
case Http::METHOD_OPTIONS:
- // RFC 3253 section 3.6
+ // RFC 3253 section 3.6
case Http::METHOD_REPORT:
- // RFC 3648 - none
- // RFC 3744 - none
- // RFC 4437 - none
- // RFC 4791 - none
+ // RFC 3648 - none
+ // RFC 3744 - none
+ // RFC 4437 - none
+ // RFC 4791 - none
- // RFC 4918 section 9.1
+ // RFC 4918 section 9.1
case Http::METHOD_PROPFIND:
- // RFC 5323 section 2
+ // RFC 5323 section 2
case Http::METHOD_SEARCH:
// RFC 5789 - none
// checking and adding. If only to say it is known to define none.
switch (theMethod) {
- // RFC 2068 - TODO check LINK/UNLINK definition
+ // RFC 2068 - TODO check LINK/UNLINK definition
- // RFC 2616 section 9.1.2
+ // RFC 2616 section 9.1.2
case Http::METHOD_GET:
case Http::METHOD_HEAD:
case Http::METHOD_PUT:
case Http::METHOD_OPTIONS:
case Http::METHOD_TRACE:
- // RFC 3253 - TODO check
- // RFC 3648 - TODO check
- // RFC 3744 - TODO check
- // RFC 4437 - TODO check
- // RFC 4791 - TODO check
+ // RFC 3253 - TODO check
+ // RFC 3648 - TODO check
+ // RFC 3744 - TODO check
+ // RFC 4437 - TODO check
+ // RFC 4791 - TODO check
- // RFC 4918 section 9
+ // RFC 4918 section 9
case Http::METHOD_PROPFIND:
case Http::METHOD_PROPPATCH:
case Http::METHOD_MKCOL:
// Only a few methods are defined as cacheable.
// All other methods from the below RFC are "MUST NOT cache"
switch (theMethod) {
- // RFC 2616 section 9
+ // RFC 2616 section 9
case Http::METHOD_GET:
case Http::METHOD_HEAD:
return true;
return ??;
#endif
- // Special Squid method tokens are not cacheable.
- // RFC 2616 defines all unregistered or unspecified methods as non-cacheable
- // until such time as an RFC defines them cacheable.
+ // Special Squid method tokens are not cacheable.
+ // RFC 2616 defines all unregistered or unspecified methods as non-cacheable
+ // until such time as an RFC defines them cacheable.
default:
return false;
}
HttpRequestMethod::shouldInvalidate() const
{
switch (theMethod) {
- /* RFC 2616 section 13.10 - "MUST invalidate" */
+ /* RFC 2616 section 13.10 - "MUST invalidate" */
case Http::METHOD_POST:
case Http::METHOD_PUT:
case Http::METHOD_DELETE:
return true;
- /* Squid extension to force invalidation */
+ /* Squid extension to force invalidation */
case Http::METHOD_PURGE:
return true;
- /*
- * RFC 2616 sayeth, in section 13.10, final paragraph:
- * A cache that passes through requests for methods it does not
- * understand SHOULD invalidate any entities referred to by the
- * Request-URI.
- */
+ /*
+ * RFC 2616 sayeth, in section 13.10, final paragraph:
+ * A cache that passes through requests for methods it does not
+ * understand SHOULD invalidate any entities referred to by the
+ * Request-URI.
+ */
case Http::METHOD_OTHER:
return true;
return true;
switch (theMethod) {
- /* common sense suggests purging is not required? */
+ /* common sense suggests purging is not required? */
case Http::METHOD_GET: // XXX: but we do purge HEAD on successful GET
case Http::METHOD_HEAD:
case Http::METHOD_NONE:
return true;
}
}
+
}
#endif /* SQUID_HTTPREQUESTMETHOD_H */
+
{
switch (status) {
- // 000
+ // 000
case Http::scNone:
- return "Init"; /* we init .status with code 0 */
+ return "Init"; /* we init .status with code 0 */
break;
- // 100-199
+ // 100-199
case Http::scContinue:
return "Continue";
break;
return "Processing";
break;
- // 200-299
+ // 200-299
case Http::scOkay:
return "OK";
break;
return "IM Used";
break;
- // 300-399
+ // 300-399
case Http::scMultipleChoices:
return "Multiple Choices";
break;
return "Permanent Redirect";
break;
- // 400-499
+ // 400-499
case Http::scBadRequest:
return "Bad Request";
break;
return "Request Header Fields Too Large";
break;
- // 500-599
+ // 500-599
case Http::scInternalServerError:
return "Internal Server Error";
break;
return "Network Authentication Required";
break;
- // 600+
+ // 600+
case Http::scInvalidHeader:
case Http::scHeaderTooLarge:
- // fall through to default.
+ // fall through to default.
default:
debugs(57, 3, "Unassigned HTTP status code: " << status);
}
return "Unassigned";
}
+
} // namespace Http
#endif /* _SQUID_SRC_HTTP_STATUSCODE_H */
+
bool
Http::StatusLine::parse(const String &protoPrefix, const char *start, const char *end)
{
- status_ = Http::scInvalidHeader; /* Squid header parsing error */
+ status_ = Http::scInvalidHeader; /* Squid header parsing error */
// XXX: HttpMsg::parse() has a similar check but is using
// casesensitive comparison (which is required by HTTP errata?)
/* we ignore 'reason-phrase' */
/* Should assert start < end ? */
- return true; /* success */
+ return true; /* success */
}
+
} // namespace Http
#endif /* SQUID_HTTP_STATUSLINE_H */
+
typedef RefCount<HttpReply> HttpReplyPointer;
#endif /* SQUID_SRC_HTTP_FORWARD_H */
+
}
// arbitrary maximum-length for headers which can be found by Http1Parser::getHeaderField()
-#define GET_HDR_SZ 1024
+#define GET_HDR_SZ 1024
// BUG: returns only the first header line with given name,
// ignores multi-line headers and obs-fold headers
return NULL;
}
+
} // namespace Http
#endif /* _SQUID_SRC_HTTP_ONE_PARSER_H */
+
#include "SquidConfig.h"
Http::One::RequestParser::RequestParser() :
- Parser(),
- request_parse_status(Http::scNone)
+ Parser(),
+ request_parse_status(Http::scNone)
{
req.start = req.end = -1;
req.m_start = req.m_end = -1;
return !needsMoreData();
}
+
} // namespace Http
#endif /* _SQUID_SRC_HTTP_ONE_REQUESTPARSER_H */
+
namespace Http1 = Http::One;
#endif /* SQUID_SRC_HTTP_ONE_FORWARD_H */
+
}
#endif /* USE_ICMP */
+
#include "ip/Address.h"
-#define PINGER_PAYLOAD_SZ 8192
+#define PINGER_PAYLOAD_SZ 8192
#define MAX_PAYLOAD 256 // WAS: SQUIDHOSTNAMELEN
#define MAX_PKT4_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1)
/**
* Translate TTL to a hop distance
*
- \param ttl negative : n > 33
- \param ttl n(0...32) : 32 >= n >= 1
- \param ttl n(33...62) : 32 >= n >= 1
- \param ttl n(63...64) : 2 >= n >= 1
- \param ttl n(65...128) : 64 >= n >= 1
- \param ttl n(129...192) : 64 >= n >= 1
- \param ttl n(193...) : n < 255
+ \param ttl negative : n > 33
+ \param ttl n(0...32) : 32 >= n >= 1
+ \param ttl n(33...62) : 32 >= n >= 1
+ \param ttl n(63...64) : 2 >= n >= 1
+ \param ttl n(65...128) : 64 >= n >= 1
+ \param ttl n(129...192) : 64 >= n >= 1
+ \param ttl n(193...) : n < 255
*
\bug BUG? ttl<0 can produce high hop values
\bug BUG? ttl>255 can produce zero or negative hop values
};
#endif
+
}
#endif /* USE_ICMP */
+
#endif /* USE_ICMP && SQUID_HELPER */
#endif
+
{
// NP: LowPktStr is for codes 0-127
static const char *icmp6LowPktStr[] = {
- "ICMPv6 0", // 0
- "Destination Unreachable", // 1 - RFC2463
- "Packet Too Big", // 2 - RFC2463
- "Time Exceeded", // 3 - RFC2463
- "Parameter Problem", // 4 - RFC2463
+ "ICMPv6 0", // 0
+ "Destination Unreachable", // 1 - RFC2463
+ "Packet Too Big", // 2 - RFC2463
+ "Time Exceeded", // 3 - RFC2463
+ "Parameter Problem", // 4 - RFC2463
};
// low codes 1-4 registered
// NP: HighPktStr is for codes 128-255
static const char *icmp6HighPktStr[] = {
- "Echo Request", // 128 - RFC2463
- "Echo Reply", // 129 - RFC2463
- "Multicast Listener Query", // 130 - RFC2710
- "Multicast Listener Report", // 131 - RFC2710
- "Multicast Listener Done", // 132 - RFC2710
- "Router Solicitation", // 133 - RFC4861
- "Router Advertisement", // 134 - RFC4861
- "Neighbor Solicitation", // 135 - RFC4861
- "Neighbor Advertisement", // 136 - RFC4861
- "Redirect Message", // 137 - RFC4861
- "Router Renumbering", // 138 - Crawford
- "ICMP Node Information Query", // 139 - RFC4620
- "ICMP Node Information Response", // 140 - RFC4620
- "Inverse Neighbor Discovery Solicitation", // 141 - RFC3122
- "Inverse Neighbor Discovery Advertisement", // 142 - RFC3122
- "Version 2 Multicast Listener Report", // 143 - RFC3810
- "Home Agent Address Discovery Request", // 144 - RFC3775
- "Home Agent Address Discovery Reply", // 145 - RFC3775
- "Mobile Prefix Solicitation", // 146 - RFC3775
- "Mobile Prefix Advertisement", // 147 - RFC3775
- "Certification Path Solicitation", // 148 - RFC3971
- "Certification Path Advertisement", // 149 - RFC3971
- "ICMP Experimental (150)", // 150 - RFC4065
- "Multicast Router Advertisement", // 151 - RFC4286
- "Multicast Router Solicitation", // 152 - RFC4286
- "Multicast Router Termination", // 153 - [RFC4286]
+ "Echo Request", // 128 - RFC2463
+ "Echo Reply", // 129 - RFC2463
+ "Multicast Listener Query", // 130 - RFC2710
+ "Multicast Listener Report", // 131 - RFC2710
+ "Multicast Listener Done", // 132 - RFC2710
+ "Router Solicitation", // 133 - RFC4861
+ "Router Advertisement", // 134 - RFC4861
+ "Neighbor Solicitation", // 135 - RFC4861
+ "Neighbor Advertisement", // 136 - RFC4861
+ "Redirect Message", // 137 - RFC4861
+ "Router Renumbering", // 138 - Crawford
+ "ICMP Node Information Query", // 139 - RFC4620
+ "ICMP Node Information Response", // 140 - RFC4620
+ "Inverse Neighbor Discovery Solicitation", // 141 - RFC3122
+ "Inverse Neighbor Discovery Advertisement", // 142 - RFC3122
+ "Version 2 Multicast Listener Report", // 143 - RFC3810
+ "Home Agent Address Discovery Request", // 144 - RFC3775
+ "Home Agent Address Discovery Reply", // 145 - RFC3775
+ "Mobile Prefix Solicitation", // 146 - RFC3775
+ "Mobile Prefix Advertisement", // 147 - RFC3775
+ "Certification Path Solicitation", // 148 - RFC3971
+ "Certification Path Advertisement", // 149 - RFC3971
+ "ICMP Experimental (150)", // 150 - RFC4065
+ "Multicast Router Advertisement", // 151 - RFC4286
+ "Multicast Router Solicitation", // 152 - RFC4286
+ "Multicast Router Termination", // 153 - [RFC4286]
};
// high codes 127-153 registered
// FIXME INET6 : The IPv6 Header (ip6_hdr) is not availble directly >:-(
//
// TTL still has to come from the IP header somewhere.
-// still need to strip and process it properly.
-// probably have to rely on RTT as given by timestamp in data sent and current.
+// still need to strip and process it properly.
+// probably have to rely on RTT as given by timestamp in data sent and current.
/* IPv6 Header Structures (linux)
struct ip6_hdr
// fields (via simple define)
- #define ip6_vfc // N.A
- #define ip6_flow // N/A
- #define ip6_plen // payload length.
- #define ip6_nxt // expect to be type 0x3a - ICMPv6
- #define ip6_hlim // MAX hops (always 64, but no guarantee)
- #define ip6_hops // HOPS!!! (can it be true??)
+ #define ip6_vfc // N.A
+ #define ip6_flow // N/A
+ #define ip6_plen // payload length.
+ #define ip6_nxt // expect to be type 0x3a - ICMPv6
+ #define ip6_hlim // MAX hops (always 64, but no guarantee)
+ #define ip6_hops // HOPS!!! (can it be true??)
ip = (struct ip6_hdr *) pkt;
pkt += sizeof(ip6_hdr);
debugs(42, DBG_CRITICAL, HERE << "ip6_nxt=" << ip->ip6_nxt <<
- ", ip6_plen=" << ip->ip6_plen <<
- ", ip6_hlim=" << ip->ip6_hlim <<
- ", ip6_hops=" << ip->ip6_hops <<
- " ::: 40 == sizef(ip6_hdr) == " << sizeof(ip6_hdr)
+ ", ip6_plen=" << ip->ip6_plen <<
+ ", ip6_hlim=" << ip->ip6_hlim <<
+ ", ip6_hops=" << ip->ip6_hops <<
+ " ::: 40 == sizef(ip6_hdr) == " << sizeof(ip6_hdr)
);
*/
/*
* FIXME INET6: Without access to the IPv6-Hops header we must rely on the total RTT
* and could caculate the hops from that, but it produces some weird value mappings using ipHops
- * for now everything is 1 v6 hop away with variant RTT
+ * for now everything is 1 v6 hop away with variant RTT
* WANT: preply.hops = ip->ip6_hops; // ipHops(ip->ip_hops);
*/
preply.hops = 1;
}
#endif /* USE_ICMP */
+
#endif /* USE_ICMP && SQUID_HELPER */
#endif /* _INCLUDE_ICMPV6_H */
+
};
#endif /* ICMPCONFIG_H */
+
}
#endif /* USE_ICMP */
+
extern IcmpSquid icmpEngine;
#endif /* _INCLUDE_ICMPSQUID_H */
+
#include "ipcache.h"
#include "StoreClient.h"
-#define NETDB_REQBUF_SZ 4096
+#define NETDB_REQBUF_SZ 4096
typedef enum {
STATE_NONE,
if (! (addr = q) )
continue;
- if (netdbLookupAddr(addr) != NULL) /* no dups! */
+ if (netdbLookupAddr(addr) != NULL) /* no dups! */
continue;
if ((q = strtok(NULL, w_space)) == NULL)
netdbHashInsert(n, addr);
while ((q = strtok(NULL, w_space)) != NULL) {
- if (netdbLookupHost(q) != NULL) /* no dups! */
+ if (netdbLookupHost(q) != NULL) /* no dups! */
continue;
netdbHostInsert(n, q);
p->hops = hops;
- p->expires = squid_curtime + 3600; /* XXX ? */
+ p->expires = squid_curtime + 3600; /* XXX ? */
if (n->n_peers < 2)
return;
if (0.0 == n->rtt)
continue;
- if (n->rtt > 60000) /* RTT > 1 MIN probably bogus */
+ if (n->rtt > 60000) /* RTT > 1 MIN probably bogus */
continue;
if (! (addr = n->network) )
tempBuffer.data = ex->buf;
storeClientCopy(ex->sc, ex->e, tempBuffer,
netdbExchangeHandleReply, ex);
- ex->r->flags.loopDetected = true; /* cheat! -- force direct */
+ ex->r->flags.loopDetected = true; /* cheat! -- force direct */
// XXX: send as Proxy-Authenticate instead
if (p->login)
p = peerFindByName(h->peername);
- if (NULL == p) /* not found */
+ if (NULL == p) /* not found */
continue;
if (neighborType(p, request) != PEER_PARENT)
continue;
- if (!peerHTTPOkay(p, request)) /* not allowed */
+ if (!peerHTTPOkay(p, request)) /* not allowed */
continue;
return p;
#endif
return NULL;
}
+
void netdbHostData(const char *host, int *samp, int *rtt, int *hops);
#endif /* ICMP_NET_DB_H */
+
#define PINGER_TIMEOUT 10
/* non-windows use STDOUT for feedback to squid */
-#define LINK_TO_SQUID 1
+#define LINK_TO_SQUID 1
-#endif /* _SQUID_WINDOWS_ */
+#endif /* _SQUID_WINDOWS_ */
// ICMP Engines are declared global here so they can call each other easily.
IcmpPinger control;
}
#endif /* USE_ICMP */
+
}
#endif /* USE_ICMP */
+
extern const char *icp_opcode_str[];
#endif /* _SQUID_ICP_OPCODE_H */
+
/* icp_common_t */
_icp_common_t::_icp_common_t() :
- opcode(ICP_INVALID), version(0), length(0), reqnum(0),
- flags(0), pad(0), shostid(0)
+ opcode(ICP_INVALID), version(0), length(0), reqnum(0),
+ flags(0), pad(0), shostid(0)
{}
_icp_common_t::_icp_common_t(char *buf, unsigned int len) :
- opcode(ICP_INVALID), version(0), reqnum(0), flags(0), pad(0), shostid(0)
+ opcode(ICP_INVALID), version(0), reqnum(0), flags(0), pad(0), shostid(0)
{
if (len < sizeof(_icp_common_t)) {
/* mark as invalid */
/* ICPState */
ICPState::ICPState(icp_common_t &aHeader, HttpRequest *aRequest):
- header(aHeader),
- request(aRequest),
- fd(-1),
- url(NULL)
+ header(aHeader),
+ request(aRequest),
+ fd(-1),
+ url(NULL)
{
HTTPMSGLOCK(request);
}
public:
ICP2State(icp_common_t & aHeader, HttpRequest *aRequest):
- ICPState(aHeader, aRequest),rtt(0),src_rtt(0),flags(0) {}
+ ICPState(aHeader, aRequest),rtt(0),src_rtt(0),flags(0) {}
~ICP2State();
void created(StoreEntry * newEntry);
break;
}
- icp_version = (int) buf[1]; /* cheat! */
+ icp_version = (int) buf[1]; /* cheat! */
if (icpOutgoingConn->local == from)
// ignore ICP packets which loop back (multicast usually)
return storeKeyPublic(url, Http::METHOD_GET);
}
+
public:
ICP3State(icp_common_t &aHeader, HttpRequest *aRequest) :
- ICPState(aHeader, aRequest) {}
+ ICPState(aHeader, aRequest) {}
~ICP3State();
void created (StoreEntry *newEntry);
break;
}
}
+
}
#endif /* USE_IDENT */
+
#endif /* USE_IDENT */
#endif /* SQUID_IDENT_ACLIDENT_H */
+
#endif /* USE_IDENT */
#endif /* SQUID_IDENT_CONFIG_H */
+
class IdentStateData
{
public:
- hash_link hash; /* must be first */
+ hash_link hash; /* must be first */
private:
CBDATA_CLASS(IdentStateData);
}
#endif /* USE_IDENT */
+
#endif /* USE_IDENT */
#endif /* SQUID_IDENT_H */
+
int isPowTen(int); //int.cc
#endif /* SQUID_INT_H_ */
+
int internalHostnameIs(const char *);
#endif /* SQUID_INTERNAL_H_ */
+
/* Debugging only. Dump the address content when a fatal assert is encountered. */
#define IASSERT(a,b) \
- if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
- printf("Ip::Address invalid? with isIPv4()=%c, isIPv6()=%c\n",(isIPv4()?'T':'F'),(isIPv6()?'T':'F')); \
- printf("ADDRESS:"); \
- for(unsigned int i = 0; i < sizeof(mSocketAddr_.sin6_addr); ++i) { \
- printf(" %x", mSocketAddr_.sin6_addr.s6_addr[i]); \
- } printf("\n"); assert(b); \
- }
+ if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
+ printf("Ip::Address invalid? with isIPv4()=%c, isIPv6()=%c\n",(isIPv4()?'T':'F'),(isIPv6()?'T':'F')); \
+ printf("ADDRESS:"); \
+ for(unsigned int i = 0; i < sizeof(mSocketAddr_.sin6_addr); ++i) { \
+ printf(" %x", mSocketAddr_.sin6_addr.s6_addr[i]); \
+ } printf("\n"); assert(b); \
+ }
int
Ip::Address::cidr() const
const struct in6_addr Ip::Address::v4_noaddr = {{{ 0x00000000, 0x00000000, 0x0000ffff, 0xffffffff }}};
const struct in6_addr Ip::Address::v6_noaddr = {{{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }}};
#else
-const struct in6_addr Ip::Address::v4_localhost = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01 }}
+const struct in6_addr Ip::Address::v4_localhost = {{{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01
+ }
+ }
};
-const struct in6_addr Ip::Address::v4_anyaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}
+const struct in6_addr Ip::Address::v4_anyaddr = {{{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
+ }
+ }
};
-const struct in6_addr Ip::Address::v4_noaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}
+const struct in6_addr Ip::Address::v4_noaddr = {{{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ }
+ }
};
-const struct in6_addr Ip::Address::v6_noaddr = {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}
+const struct in6_addr Ip::Address::v6_noaddr = {{{
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ }
+ }
};
#endif
assert(false);
return false;
}
+
/** Require an IPv4-only address for this usage.
* Converts the object to prefer only IPv4 output.
- \retval true Content can be IPv4
- \retval false Content CANNOT be IPv4
+ \retval true Content can be IPv4
+ \retval false Content CANNOT be IPv4
*/
bool setIPv4();
/**
* Lookup a Host by Name. Equivalent to system call gethostbyname(char*)
\param s The textual FQDN of the host being located.
- \retval true lookup was successful and an IPA was located.
- \retval false lookup failed or FQDN has no IP associated.
+ \retval true lookup was successful and an IPA was located.
+ \retval false lookup failed or FQDN has no IP associated.
*/
bool GetHostByName(const char *s);
void parse_IpAddress_list_token(Ip::Address_list **, char *);
#endif /* _SQUID_SRC_IP_ADDRESS_H */
+
#include <linux/netfilter_ipv6/ip6_tables.h>
#endif
#if !defined(IP6T_SO_ORIGINAL_DST)
-#define IP6T_SO_ORIGINAL_DST 80 // stolen with prejudice from the above file.
+#define IP6T_SO_ORIGINAL_DST 80 // stolen with prejudice from the above file.
#endif
#endif /* LINUX_NETFILTER required headers */
leave_suid();
return false;
}
+
bool ProbeForTproxy(Address &test);
/**
- \retval 0 Full transparency is disabled.
+ \retval 0 Full transparency is disabled.
\retval 1 Full transparency is enabled and active.
*/
inline int TransparentActive() { return transparentActive_; };
void StopTransparency(const char *str);
/**
- \retval 0 IP Interception is disabled.
+ \retval 0 IP Interception is disabled.
\retval 1 IP Interception is enabled and active.
*/
inline int InterceptActive() { return interceptActive_; };
} // namespace Ip
#endif /* SQUID_IP_IPINTERCEPT_H */
+
Ip::Qos::Config Ip::Qos::TheConfig;
Ip::Qos::Config::Config() : tosLocalHit(0), tosSiblingHit(0), tosParentHit(0),
- tosMiss(0), tosMissMask(0), preserveMissTos(false),
- preserveMissTosMask(0xFF), markLocalHit(0), markSiblingHit(0),
- markParentHit(0), markMiss(0), markMissMask(0),
- preserveMissMark(false), preserveMissMarkMask(0xFFFFFFFF),
- tosToServer(NULL), tosToClient(NULL), nfmarkToServer(NULL),
- nfmarkToClient(NULL)
+ tosMiss(0), tosMissMask(0), preserveMissTos(false),
+ preserveMissTosMask(0xFF), markLocalHit(0), markSiblingHit(0),
+ markParentHit(0), markMiss(0), markMissMask(0),
+ preserveMissMark(false), preserveMissMarkMask(0xFFFFFFFF),
+ tosToServer(NULL), tosToClient(NULL), nfmarkToServer(NULL),
+ nfmarkToClient(NULL)
{
}
#if !_USE_INLINE_
#include "Qos.cci"
#endif
+
extern Config TheConfig;
/* legacy parser access wrappers */
-#define parse_QosConfig(X) (X)->parseConfigLine()
+#define parse_QosConfig(X) (X)->parseConfigLine()
#define free_QosConfig(X)
#define dump_QosConfig(e,n,X) do { \
- char temp[256]; /* random number. change as needed. max config line length. */ \
- (X).dumpConfigLine(temp,n); \
- storeAppendPrintf(e, "%s", temp); \
- } while(0);
+ char temp[256]; /* random number. change as needed. max config line length. */ \
+ (X).dumpConfigLine(temp,n); \
+ storeAppendPrintf(e, "%s", temp); \
+ } while(0);
} // namespace Qos
#endif
#endif /* SQUID_QOSCONFIG_H */
+
class Address;
}
#endif /* _SQUID_IP_FORWARD_H */
+
#if !_USE_INLINE_
#include "Qos.cci"
#endif
+
CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
}
+
};
#endif /* SQUID_SRC_TEST_IPADDRESS_H */
+
EnableIpv6 = IPV6_OFF;
#endif
}
+
} // namespace Ip
#endif /* _SQUID_SRC_IP_TOOLS_H */
+
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_STREAM,
- 0, /* protocol */
+ 0, /* protocol */
local_addr,
- 0, /* blocking */
+ 0, /* blocking */
name);
IPC_CHECK_FAIL(crfd, "child read", "TCP " << local_addr);
IPC_CHECK_FAIL(prfd, "parent read", "TCP " << local_addr);
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- if (pid > 0) { /* parent */
+ if (pid > 0) { /* parent */
/* close shared socket with child */
comm_close(crfd);
/* child */
TheProcessKind = pkHelper;
- no_suid(); /* give up extra priviliges */
+ no_suid(); /* give up extra priviliges */
/* close shared socket with parent */
close(prfd);
return 0;
}
+
return !UsingSmp();
#endif
}
+
} // namespace Ipc
#endif // SQUID_IPC_ATOMIC_WORD_H
+
Ipc::Coordinator* Ipc::Coordinator::TheInstance = NULL;
Ipc::Coordinator::Coordinator():
- Port(Ipc::Port::CoordinatorAddr())
+ Port(Ipc::Port::CoordinatorAddr())
{
}
{
return strands_;
}
+
} // namespace Ipc
#endif /* SQUID_IPC_COORDINATOR_H */
+
debugs(54, DBG_IMPORTANT, HERE << "salvaged bug: wrong fd_note ID: " << fdNoteId);
return FdNotes[fdnNone];
}
+
} // namespace Ipc;
#endif /* SQUID_IPC_FD_NOTES_H */
+
unsigned int Ipc::Forwarder::LastRequestId = 0;
Ipc::Forwarder::Forwarder(Request::Pointer aRequest, double aTimeout):
- AsyncJob("Ipc::Forwarder"),
- request(aRequest), timeout(aTimeout)
+ AsyncJob("Ipc::Forwarder"),
+ request(aRequest), timeout(aTimeout)
{
debugs(54, 5, HERE);
}
if (call != NULL)
ScheduleCallHere(call);
}
+
} // namespace Ipc
#endif /* SQUID_IPC_FORWARDER_H */
+
Ipc::Inquirer::Inquirer(Request::Pointer aRequest, const StrandCoords& coords,
double aTimeout):
- AsyncJob("Ipc::Inquirer"),
- request(aRequest), strands(coords), pos(strands.begin()), timeout(aTimeout)
+ AsyncJob("Ipc::Inquirer"),
+ request(aRequest), strands(coords), pos(strands.begin()), timeout(aTimeout)
{
debugs(54, 5, HERE);
buf.terminate();
return buf.content();
}
+
} // namespace Ipc
#endif /* SQUID_IPC_INQUIRER_H */
+
int TheProcessKind = pkOther;
Kid::Kid():
- badFailures(0),
- pid(-1),
- startTime(0),
- isRunning(false),
- status(0)
+ badFailures(0),
+ pid(-1),
+ startTime(0),
+ isRunning(false),
+ status(0)
{
}
Kid::Kid(const String& kid_name):
- theName(kid_name),
- badFailures(0),
- pid(-1),
- startTime(0),
- isRunning(false),
- status(0)
+ theName(kid_name),
+ badFailures(0),
+ pid(-1),
+ startTime(0),
+ isRunning(false),
+ status(0)
{
}
{
return theName;
}
+
extern int TheProcessKind;
#endif /* SQUID_IPC_KID_H */
+
{
return storage.size();
}
+
extern KidName TheKidName; ///< current Squid process name
#endif /* SQUID_IPC_KIDS_H */
+
#include "tools.h"
Ipc::MemMap::MemMap(const char *const aPath) :
- cleaner(NULL),
- path(aPath),
- shared(shm_old(Shared)(aPath))
+ cleaner(NULL),
+ path(aPath),
+ shared(shm_old(Shared)(aPath))
{
assert(shared->limit > 0); // we should not be created otherwise
debugs(54, 5, "attached map [" << path << "] created: " <<
/* Ipc::MemMapSlot */
Ipc::MemMapSlot::MemMapSlot() :
- pSize(0),
- expire(0)
+ pSize(0),
+ expire(0)
{
memset(key, 0, sizeof(key));
memset(p, 0, sizeof(p));
/* Ipc::MemMap::Shared */
Ipc::MemMap::Shared::Shared(const int aLimit, const size_t anExtrasSize):
- limit(aLimit), extrasSize(anExtrasSize), count(0), slots(aLimit)
+ limit(aLimit), extrasSize(anExtrasSize), count(0), slots(aLimit)
{
}
{
return sizeof(Shared) + limit * (sizeof(Slot) + extrasSize);
}
+
} // namespace Ipc
#endif /* SQUID_IPC_STORE_MAP_H */
+
} // namespace Ipc;
#endif /* SQUID_IPC_MESSAGES_H */
+
const char Ipc::strandAddrLabel[] = "-kid";
Ipc::Port::Port(const String& aListenAddr):
- UdsOp(aListenAddr)
+ UdsOp(aListenAddr)
{
setOptions(COMM_NONBLOCKING | COMM_DOBIND);
}
doListen();
}
+
} // namespace Ipc
#endif /* SQUID_IPC_PORT_H */
+
InstanceIdDefinitions(Ipc::QueueReader, "ipcQR");
Ipc::QueueReader::QueueReader(): popBlocked(1), popSignal(0),
- rateLimit(0), balance(0)
+ rateLimit(0), balance(0)
{
debugs(54, 7, HERE << "constructed " << id);
}
/* QueueReaders */
Ipc::QueueReaders::QueueReaders(const int aCapacity): theCapacity(aCapacity),
- theReaders(theCapacity)
+ theReaders(theCapacity)
{
Must(theCapacity > 0);
}
// OneToOneUniQueue
Ipc::OneToOneUniQueue::OneToOneUniQueue(const unsigned int aMaxItemSize, const int aCapacity):
- theIn(0), theOut(0), theSize(0), theMaxItemSize(aMaxItemSize),
- theCapacity(aCapacity)
+ theIn(0), theOut(0), theSize(0), theMaxItemSize(aMaxItemSize),
+ theCapacity(aCapacity)
{
Must(theMaxItemSize > 0);
Must(theCapacity > 0);
// BaseMultiQueue
Ipc::BaseMultiQueue::BaseMultiQueue(const int aLocalProcessId):
- theLocalProcessId(aLocalProcessId),
- theLastPopProcessId(std::numeric_limits<int>::max() - 1)
+ theLocalProcessId(aLocalProcessId),
+ theLastPopProcessId(std::numeric_limits<int>::max() - 1)
{
}
}
Ipc::FewToFewBiQueue::FewToFewBiQueue(const String &id, const Group aLocalGroup, const int aLocalProcessId):
- BaseMultiQueue(aLocalProcessId),
- metadata(shm_old(Metadata)(MetadataId(id).termedBuf())),
- queues(shm_old(OneToOneUniQueues)(QueuesId(id).termedBuf())),
- readers(shm_old(QueueReaders)(ReadersId(id).termedBuf())),
- theLocalGroup(aLocalGroup)
+ BaseMultiQueue(aLocalProcessId),
+ metadata(shm_old(Metadata)(MetadataId(id).termedBuf())),
+ queues(shm_old(OneToOneUniQueues)(QueuesId(id).termedBuf())),
+ readers(shm_old(QueueReaders)(ReadersId(id).termedBuf())),
+ theLocalGroup(aLocalGroup)
{
Must(queues->theCapacity == metadata->theGroupASize * metadata->theGroupBSize * 2);
Must(readers->theCapacity == metadata->theGroupASize + metadata->theGroupBSize);
}
Ipc::FewToFewBiQueue::Metadata::Metadata(const int aGroupASize, const int aGroupAIdOffset, const int aGroupBSize, const int aGroupBIdOffset):
- theGroupASize(aGroupASize), theGroupAIdOffset(aGroupAIdOffset),
- theGroupBSize(aGroupBSize), theGroupBIdOffset(aGroupBIdOffset)
+ theGroupASize(aGroupASize), theGroupAIdOffset(aGroupAIdOffset),
+ theGroupBSize(aGroupBSize), theGroupBIdOffset(aGroupBIdOffset)
{
Must(theGroupASize > 0);
Must(theGroupBSize > 0);
}
Ipc::FewToFewBiQueue::Owner::Owner(const String &id, const int groupASize, const int groupAIdOffset, const int groupBSize, const int groupBIdOffset, const unsigned int maxItemSize, const int capacity):
- metadataOwner(shm_new(Metadata)(MetadataId(id).termedBuf(), groupASize, groupAIdOffset, groupBSize, groupBIdOffset)),
- queuesOwner(shm_new(OneToOneUniQueues)(QueuesId(id).termedBuf(), groupASize*groupBSize*2, maxItemSize, capacity)),
- readersOwner(shm_new(QueueReaders)(ReadersId(id).termedBuf(), groupASize+groupBSize))
+ metadataOwner(shm_new(Metadata)(MetadataId(id).termedBuf(), groupASize, groupAIdOffset, groupBSize, groupBIdOffset)),
+ queuesOwner(shm_new(OneToOneUniQueues)(QueuesId(id).termedBuf(), groupASize*groupBSize*2, maxItemSize, capacity)),
+ readersOwner(shm_new(QueueReaders)(ReadersId(id).termedBuf(), groupASize+groupBSize))
{
}
}
Ipc::MultiQueue::MultiQueue(const String &id, const int localProcessId):
- BaseMultiQueue(localProcessId),
- metadata(shm_old(Metadata)(MetadataId(id).termedBuf())),
- queues(shm_old(OneToOneUniQueues)(QueuesId(id).termedBuf())),
- readers(shm_old(QueueReaders)(ReadersId(id).termedBuf()))
+ BaseMultiQueue(localProcessId),
+ metadata(shm_old(Metadata)(MetadataId(id).termedBuf())),
+ queues(shm_old(OneToOneUniQueues)(QueuesId(id).termedBuf())),
+ readers(shm_old(QueueReaders)(ReadersId(id).termedBuf()))
{
Must(queues->theCapacity == metadata->theProcessCount * metadata->theProcessCount);
Must(readers->theCapacity == metadata->theProcessCount);
}
Ipc::MultiQueue::Metadata::Metadata(const int aProcessCount, const int aProcessIdOffset):
- theProcessCount(aProcessCount), theProcessIdOffset(aProcessIdOffset)
+ theProcessCount(aProcessCount), theProcessIdOffset(aProcessIdOffset)
{
Must(theProcessCount > 0);
}
Ipc::MultiQueue::Owner::Owner(const String &id, const int processCount, const int processIdOffset, const unsigned int maxItemSize, const int capacity):
- metadataOwner(shm_new(Metadata)(MetadataId(id).termedBuf(), processCount, processIdOffset)),
- queuesOwner(shm_new(OneToOneUniQueues)(QueuesId(id).termedBuf(), processCount*processCount, maxItemSize, capacity)),
- readersOwner(shm_new(QueueReaders)(ReadersId(id).termedBuf(), processCount))
+ metadataOwner(shm_new(Metadata)(MetadataId(id).termedBuf(), processCount, processIdOffset)),
+ queuesOwner(shm_new(OneToOneUniQueues)(QueuesId(id).termedBuf(), processCount*processCount, maxItemSize, capacity)),
+ readersOwner(shm_new(QueueReaders)(ReadersId(id).termedBuf(), processCount))
{
}
delete queuesOwner;
delete readersOwner;
}
+
} // namespace Ipc
#endif // SQUID_IPC_QUEUE_H
+
appenders, appPerc);
}
}
+
} // namespace Ipc
#endif /* SQUID_IPC_READ_WRITE_LOCK_H */
+
public:
Request(int aRequestorId, unsigned int aRequestId):
- requestorId(aRequestorId), requestId(aRequestId) {}
+ requestorId(aRequestorId), requestId(aRequestId) {}
virtual void pack(TypedMsgHdr& msg) const = 0; ///< prepare for sendmsg()
virtual Pointer clone() const = 0; ///< returns a copy of this
} // namespace Ipc
#endif /* SQUID_IPC_REQUEST_H */
+
public:
explicit Response(unsigned int aRequestId):
- requestId(aRequestId) {}
+ requestId(aRequestId) {}
virtual void pack(TypedMsgHdr& msg) const = 0; ///< prepare for sendmsg()
virtual Pointer clone() const = 0; ///< returns a copy of this
} // namespace Ipc
#endif /* SQUID_IPC_RESPONSE_H */
+
}
Ipc::SharedListenResponse::SharedListenResponse(int aFd, int anErrNo, int aMapId):
- fd(aFd), errNo(anErrNo), mapId(aMapId)
+ fd(aFd), errNo(anErrNo), mapId(aMapId)
{
}
Ipc::SharedListenResponse::SharedListenResponse(const TypedMsgHdr &hdrMsg):
- fd(-1), errNo(0), mapId(-1)
+ fd(-1), errNo(0), mapId(-1)
{
hdrMsg.checkType(mtSharedListenResponse);
hdrMsg.getPod(*this);
cbd->handlerSubscription = por.params.handlerSubscription;
ScheduleCallHere(por.callback);
}
+
} // namespace Ipc;
#endif /* SQUID_IPC_SHARED_LISTEN_H */
+
debugs(54, 3, HERE << "opened listen " << cbd->conn);
ScheduleCallHere(callback);
}
+
} // namespace Ipc;
#endif /* SQUID_IPC_START_LISTENING_H */
+
}
Ipc::StoreMap::StoreMap(const SBuf &aPath): cleaner(NULL), path(aPath),
- anchors(shm_old(Anchors)(StoreMapAnchorsId(path).c_str())),
- slices(shm_old(Slices)(StoreMapSlicesId(path).c_str()))
+ anchors(shm_old(Anchors)(StoreMapAnchorsId(path).c_str())),
+ slices(shm_old(Slices)(StoreMapSlicesId(path).c_str()))
{
debugs(54, 5, "attached " << path << " with " <<
anchors->capacity << '+' << slices->capacity);
/* Ipc::StoreMapAnchors */
Ipc::StoreMapAnchors::StoreMapAnchors(const int aCapacity):
- count(0),
- victim(0),
- capacity(aCapacity),
- items(aCapacity)
+ count(0),
+ victim(0),
+ capacity(aCapacity),
+ items(aCapacity)
{
}
// resulting in sfilenos that are pointing beyond the database.
#endif /* SQUID_IPC_STORE_MAP_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand);
Ipc::Strand::Strand():
- Port(MakeAddr(strandAddrLabel, KidIdentifier)),
- isRegistered(false)
+ Port(MakeAddr(strandAddrLabel, KidIdentifier)),
+ isRegistered(false)
{
}
if (!isRegistered)
fatalf("kid%d registration timed out", KidIdentifier);
}
+
}
#endif /* SQUID_IPC_STRAND_H */
+
}
Ipc::HereIamMessage::HereIamMessage(const StrandCoord &aStrand):
- strand(aStrand)
+ strand(aStrand)
{
}
hdrMsg.setType(mtRegistration);
strand.pack(hdrMsg);
}
+
} // namespace Ipc;
#endif /* SQUID_IPC_STRAND_COORD_H */
+
} // namespace Ipc
#endif /* SQUID_IPC_STRAND_COORDS_H */
+
}
Ipc::StrandSearchRequest::StrandSearchRequest(const TypedMsgHdr &hdrMsg):
- requestorId(-1)
+ requestorId(-1)
{
hdrMsg.checkType(mtStrandSearchRequest);
hdrMsg.getPod(requestorId);
/* StrandSearchResponse */
Ipc::StrandSearchResponse::StrandSearchResponse(const Ipc::StrandCoord &aStrand):
- strand(aStrand)
+ strand(aStrand)
{
}
hdrMsg.setType(mtStrandSearchResponse);
strand.pack(hdrMsg);
}
+
} // namespace Ipc;
#endif /* SQUID_IPC_STRAND_SEARCH_H */
+
msg_control = &ctrl;
msg_controllen = sizeof(ctrl);
}
+
} // namespace Ipc
#endif /* SQUID_IPC_TYPED_MSG_HDR_H */
+
#include "ipc/UdsOp.h"
Ipc::UdsOp::UdsOp(const String& pathAddr):
- AsyncJob("Ipc::UdsOp"),
- address(PathToAddress(pathAddr)),
- options(COMM_NONBLOCKING)
+ AsyncJob("Ipc::UdsOp"),
+ address(PathToAddress(pathAddr)),
+ options(COMM_NONBLOCKING)
{
debugs(54, 5, HERE << '[' << this << "] pathAddr=" << pathAddr);
}
CBDATA_NAMESPACED_CLASS_INIT(Ipc, UdsSender);
Ipc::UdsSender::UdsSender(const String& pathAddr, const TypedMsgHdr& aMessage):
- UdsOp(pathAddr),
- message(aMessage),
- retries(10), // TODO: make configurable?
- timeout(10), // TODO: make configurable?
- sleeping(false),
- writing(false)
+ UdsOp(pathAddr),
+ message(aMessage),
+ retries(10), // TODO: make configurable?
+ timeout(10), // TODO: make configurable?
+ sleeping(false),
+ writing(false)
{
message.address(address);
}
}
return conn;
}
+
}
#endif /* SQUID_IPC_ASYNCUDSOP_H */
+
} // namespace Ipc
#endif /* SQUID_IPC_FORWARD_H */
+
} // namespace Ipc
#endif /* SQUID_IPC_MEM_FLEXIBLE_ARRAY_H */
+
{
return os << "sh_page" << page.pool << '.' << page.number;
}
+
} // namespace Ipc
#endif // SQUID_IPC_MEM_PAGE_H
+
}
Ipc::Mem::PagePool::PagePool(const char *const id):
- pageIndex(shm_old(PageStack)(id)),
- theLevels(reinterpret_cast<Atomic::Word *>(
- reinterpret_cast<char *>(pageIndex.getRaw()) +
- pageIndex->stackSize())),
- theBuf(reinterpret_cast<char *>(theLevels + PageId::maxPurpose))
+ pageIndex(shm_old(PageStack)(id)),
+ theLevels(reinterpret_cast<Atomic::Word *>(
+ reinterpret_cast<char *>(pageIndex.getRaw()) +
+ pageIndex->stackSize())),
+ theBuf(reinterpret_cast<char *>(theLevels + PageId::maxPurpose))
{
}
Must(pageIndex->pageIdIsValid(page));
return theBuf + pageSize() * (page.number - 1);
}
+
} // namespace Ipc
#endif // SQUID_IPC_MEM_PAGE_POOL_H
+
const Ipc::Mem::PageStack::Value Writable = 0;
Ipc::Mem::PageStack::PageStack(const uint32_t aPoolId, const unsigned int aCapacity, const size_t aPageSize):
- thePoolId(aPoolId), theCapacity(aCapacity), thePageSize(aPageSize),
- theSize(theCapacity),
- theLastReadable(prev(theSize)), theFirstWritable(next(theLastReadable)),
- theItems(aCapacity)
+ thePoolId(aPoolId), theCapacity(aCapacity), thePageSize(aPageSize),
+ theSize(theCapacity),
+ theLastReadable(prev(theSize)), theFirstWritable(next(theLastReadable)),
+ theItems(aCapacity)
{
// initially, all pages are free
for (Offset i = 0; i < theSize; ++i)
{
return StackSize(theCapacity);
}
+
} // namespace Ipc
#endif // SQUID_IPC_MEM_PAGE_STACK_H
+
ThePagePool = NULL;
delete owner;
}
+
} // namespace Ipc
#endif // SQUID_IPC_MEM_PAGES_H
+
template <class Class>
Owner<Class>::Owner(const char *const id, const off_t sharedSize):
- theSegment(id), theObject(NULL)
+ theSegment(id), theObject(NULL)
{
theSegment.create(sharedSize);
Must(theSegment.mem());
} // namespace Ipc
#endif /* SQUID_IPC_MEM_POINTER_H */
+
#if HAVE_SHM
Ipc::Mem::Segment::Segment(const char *const id):
- theFD(-1), theName(GenerateName(id)), theMem(NULL),
- theSize(0), theReserved(0), doUnlink(false)
+ theFD(-1), theName(GenerateName(id)), theMem(NULL),
+ theSize(0), theReserved(0), doUnlink(false)
{
}
static SegmentMap Segments;
Ipc::Mem::Segment::Segment(const char *const id):
- theName(id), theMem(NULL), theSize(0), theReserved(0), doUnlink(false)
+ theName(id), theMem(NULL), theSize(0), theReserved(0), doUnlink(false)
{
}
if (!InDaemonMode() || !IamMasterProcess())
open();
}
+
} // namespace Ipc
#endif /* SQUID_IPC_MEM_SEGMENT_H */
+
COMM_NOCLOEXEC,
name);
prfd = pwfd = comm_open(SOCK_STREAM,
- IPPROTO_TCP, /* protocol */
+ IPPROTO_TCP, /* protocol */
local_addr,
- 0, /* blocking */
+ 0, /* blocking */
name);
} else if (type == IPC_UDP_SOCKET) {
crfd = cwfd = comm_open(SOCK_DGRAM,
ipcSend(cwfd, err_string, strlen(err_string));
goto cleanup;
}
- } /* IPC_UDP_SOCKET */
+ } /* IPC_UDP_SOCKET */
t1 = dup(0);
x = recv(prfd_ipc, (void *)(buf1 + 200), bufSz -1 - 200, 0);
assert((size_t) x == strlen(ok_string)
&& !strncmp(ok_string, buf1 + 200, strlen(ok_string)));
- } /* IPC_UDP_SOCKET */
+ } /* IPC_UDP_SOCKET */
snprintf(buf1, bufSz-1, "%s(%ld) CHILD socket", prog, (long int) pid);
xfree(buf2);
return 0;
}
+
\defgroup IPCacheInternal IP Cache Internals
\ingroup IPCacheAPI
\todo when IP cache is provided as a class. These sub-groups will be obsolete
- * for now they are used to seperate the public and private functions.
- * with the private ones all being in IPCachInternal and public in IPCacheAPI
+ * for now they are used to seperate the public and private functions.
+ * with the private ones all being in IPCachInternal and public in IPCacheAPI
*
\section InternalOperation Internal Operation
*
class ipcache_entry
{
public:
- hash_link hash; /* must be first */
+ hash_link hash; /* must be first */
time_t lastref;
time_t expires;
ipcache_addrs addrs;
ipcache_entry *i = NULL, *t;
while (m) {
- if (i != NULL) { /* need to delay deletion */
- ipcacheRelease(i); /* we just override locks */
+ if (i != NULL) { /* need to delay deletion */
+ ipcacheRelease(i); /* we just override locks */
i = NULL;
}
/**
\ingroup IPCacheAPI
*
- \param name Host to resolve.
- \param handler Pointer to the function to be called when the reply
- * from the IP cache (or the DNS if the IP cache misses)
- \param handlerData Information that is passed to the handler and does not affect the IP cache.
+ \param name Host to resolve.
+ \param handler Pointer to the function to be called when the reply
+ * from the IP cache (or the DNS if the IP cache misses)
+ \param handlerData Information that is passed to the handler and does not affect the IP cache.
*
* XXX: on hits and some errors, the handler is called immediately instead
* of scheduling an async call. This reentrant behavior means that the
* if an entry exists in the cache and does not by default contact the DNS,
* unless this is requested, by setting the flags.
*
- \param name Host name to resolve.
- \param flags Default is NULL, set to IP_LOOKUP_IF_MISS
- * to explicitly perform DNS lookups.
+ \param name Host name to resolve.
+ \param flags Default is NULL, set to IP_LOOKUP_IF_MISS
+ * to explicitly perform DNS lookups.
*
- \retval NULL An error occured during lookup
- \retval NULL No results available in cache and no lookup specified
- \retval * Pointer to the ipcahce_addrs structure containing the lookup results
+ \retval NULL An error occured during lookup
+ \retval NULL No results available in cache and no lookup specified
+ \retval * Pointer to the ipcahce_addrs structure containing the lookup results
*/
const ipcache_addrs *
ipcache_gethostbyname(const char *name, int flags)
/**
\ingroup IPCacheAPI
*
- \param name domain name to have an IP marked bad
- \param addr specific addres to be marked bad
+ \param name domain name to have an IP marked bad
+ \param addr specific addres to be marked bad
*/
void
ipcacheMarkBadAddr(const char *name, const Ip::Address &addr)
break;
}
- if (k == (int) ia->count) /* not found */
+ if (k == (int) ia->count) /* not found */
return;
- if (!ia->bad_mask[k]) /* already OK */
+ if (!ia->bad_mask[k]) /* already OK */
return;
ia->bad_mask[k] = FALSE;
*
* Adds a "static" entry from /etc/hosts
*
- \param name Hostname to be linked with IP
- \param ipaddr IP Address to be cached.
+ \param name Hostname to be linked with IP
+ \param ipaddr IP Address to be cached.
*
- \retval 0 Success.
- \retval 1 IP address is invalid or other error.
+ \retval 0 Success.
+ \retval 1 IP address is invalid or other error.
*/
int
ipcacheAddEntryFromHosts(const char *name, const char *ipaddr)
}
#endif /*SQUID_SNMP */
+
int ipcacheAddEntryFromHosts(const char *name, const char *ipaddr);
#endif /* _SQUID_IPCACHE_H */
+
nlf->next = logformats;
logformats = nlf;
}
+
#define dump_logformat(E,N,D) (D).dumpFormats((E),(N))
#endif
+
};
#endif /* SQUID_CUSTOMLOG_H_ */
+
void logfileLineEnd(Logfile * lf);
#endif /* SQUID_SRC_LOG_FILE_H */
+
logfilePrintf(log->logfile, "%s\n", mb.buf);
}
+
safe_free(user);
}
#endif
+
referer,
al->url ? al->url : "-");
}
+
Time::FormatHttpd(squid_curtime),
agent);
}
+
}; // namespace Log
#endif /* _SQUID_LOG_FORMATS_H */
+
#include <cerrno>
/* How many buffers to keep before we say we've buffered too much */
-#define LOGFILE_MAXBUFS 128
+#define LOGFILE_MAXBUFS 128
/* Size of the logfile buffer */
/*
* For optimal performance this should match LOGFILE_BUFSIZ in logfile-daemon.c
*/
-#define LOGFILE_BUFSZ 32768
+#define LOGFILE_BUFSZ 32768
/* How many seconds between warnings */
-#define LOGFILE_WARN_TIME 30
+#define LOGFILE_WARN_TIME 30
static LOGWRITE logfile_mod_daemon_writeline;
static LOGLINESTART logfile_mod_daemon_linestart;
return;
}
}
+
int logfile_mod_daemon_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag);
#endif /* _SQUID_SRC_LOG_MODDAEMON_H */
+
/* Rotate the current log to .0 */
logfileFlush(lf);
- file_close(ll->fd); /* always close */
+ file_close(ll->fd); /* always close */
if (Config.Log.rotateNumber > 0) {
snprintf(to, MAXPATHLEN, "%s.%d", realpath, 0);
}
return 1;
}
+
int logfile_mod_stdio_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag);
#endif /* _SQUID_SRC_LOG_MODSTDIO_H */
+
int logfile_mod_syslog_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag);
#endif /* _SQUID_SRC_LOG_MODSYSLOG_H */
+
int logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag);
#endif /* _SQUID_SRC_LOG_MODUDP_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Log, TcpLogger);
Log::TcpLogger::TcpLogger(size_t bufCap, bool dieOnErr, Ip::Address them):
- AsyncJob("TcpLogger"),
- dieOnError(dieOnErr),
- bufferCapacity(bufCap),
- bufferedSize(0),
- flushDebt(0),
- quitOnEmpty(false),
- reconnectScheduled(false),
- writeScheduled(false),
- conn(NULL),
- remote(them),
- connectFailures(0),
- drops(0)
+ AsyncJob("TcpLogger"),
+ dieOnError(dieOnErr),
+ bufferCapacity(bufCap),
+ bufferedSize(0),
+ flushDebt(0),
+ quitOnEmpty(false),
+ reconnectScheduled(false),
+ writeScheduled(false),
+ conn(NULL),
+ remote(them),
+ connectFailures(0),
+ drops(0)
{
if (bufferCapacity < BufferCapacityMin) {
debugs(MY_DEBUG_SECTION, DBG_IMPORTANT,
return 1;
}
+
} // namespace Log
#endif /* _SQUID_SRC_LOG_TCPLOGGER_H */
+
}
HierarchyLogEntry::HierarchyLogEntry() :
- code(HIER_NONE),
- cd_lookup(LOOKUP_NONE),
- n_choices(0),
- n_ichoices(0),
- peer_reply_status(Http::scNone),
- tcpServer(NULL),
- bodyBytesRead(-1)
+ code(HIER_NONE),
+ cd_lookup(LOOKUP_NONE),
+ n_choices(0),
+ n_ichoices(0),
+ peer_reply_status(Http::scNone),
+ tcpServer(NULL),
+ bodyBytesRead(-1)
{
memset(host, '\0', SQUIDHOSTNAMELEN);
memset(cd_host, '\0', SQUIDHOSTNAMELEN);
}
#endif
+
#endif
#endif /* SQUID_LOG_ACCESS_LOG_H_ */
+
extern const char *lookup_t_str[];
#endif /* _SQUID_LOOKUP_T_H */
+
static int opt_signal_service = FALSE;
static char *opt_syslog_facility = NULL;
-static int icpPortNumOverride = 1; /* Want to detect "-u 0" */
+static int icpPortNumOverride = 1; /* Want to detect "-u 0" */
static int configured_once = 0;
#if MALLOC_DBG
static int malloc_debug_level = 0;
// short options
const char *shortOpStr =
#if USE_WIN32_SERVICE
- "O:Vir"
+ "O:Vir"
#endif
- "CDFNRSYXa:d:f:hk:m::n:sl:u:vz?";
+ "CDFNRSYXa:d:f:hk:m::n:sl:u:vz?";
// long options
static struct option squidOptions[] = {
else if (!strncmp(optarg, "check", strlen(optarg)))
/** \li On check send 0 / SIGNULL. */
- opt_send_signal = 0; /* SIGNULL */
+ opt_send_signal = 0; /* SIGNULL */
else if (!strncmp(optarg, "parse", strlen(optarg)))
/** \li On parse set global flag to re-parse the config file only. */
opt_parse_cfg_only = 1;
exit(0);
- /* NOTREACHED */
+ /* NOTREACHED */
case 'z':
/** \par z
debugs(1, 3, "finishing reconfiguring");
errorClean();
- enter_suid(); /* root to read config file */
+ enter_suid(); /* root to read config file */
// we may have disabled the need for PURGE
if (Config2.onoff.enable_purge)
Mem::Report();
setEffectiveUser();
_db_init(Debug::cache_log, Debug::debugOptions);
- ipcache_restart(); /* clear stuck entries */
- fqdncache_restart(); /* sigh, fqdncache too */
+ ipcache_restart(); /* clear stuck entries */
+ fqdncache_restart(); /* sigh, fqdncache too */
parseEtcHosts();
- errorInitialize(); /* reload error pages */
+ errorInitialize(); /* reload error pages */
accessLogInit();
#if USE_LOADABLE_MODULES
eventDelete(start_announce, NULL);
}
- writePidFile(); /* write PID file */
+ writePidFile(); /* write PID file */
reconfiguring = 0;
}
#endif
externalAclShutdown();
- _db_rotate_log(); /* cache.log */
+ _db_rotate_log(); /* cache.log */
storeDirWriteCleanLogs(1);
- storeLogRotate(); /* store.log */
- accessLogRotate(); /* access.log */
+ storeLogRotate(); /* store.log */
+ accessLogRotate(); /* access.log */
#if ICAP_CLIENT
icapLogRotate(); /*icap.log*/
#endif
setEffectiveUser(void)
{
keepCapabilities();
- leave_suid(); /* Run as non privilegied user */
+ leave_suid(); /* Run as non privilegied user */
#if _SQUID_OS2_
return;
#endif
if (!configured_once)
- disk_init(); /* disk_init must go before ipcache_init() */
+ disk_init(); /* disk_init must go before ipcache_init() */
ipcache_init();
#endif
externalAclInit();
- httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
+ httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
- httpReplyInitModule(); /* must go before accepting replies */
+ httpReplyInitModule(); /* must go before accepting replies */
errorInitialize();
no_suid();
if (!configured_once)
- writePidFile(); /* write PID file */
+ writePidFile(); /* write PID file */
#if defined(_SQUID_LINUX_THREADS_)
Mem::Init();
- storeFsInit(); /* required for config parsing */
+ storeFsInit(); /* required for config parsing */
/* TODO: call the FS::Clean() in shutdown to do Fs cleanups */
Fs::Init();
Store::Root().sync(); /* Flush pending object writes/unlinks */
- unlinkdClose(); /* after sync/flush. NOP if !USE_UNLINKD */
+ unlinkdClose(); /* after sync/flush. NOP if !USE_UNLINKD */
storeDirWriteCleanLogs(0);
PrintRusage();
dumpMallocStats();
- Store::Root().sync(); /* Flush log writes */
+ Store::Root().sync(); /* Flush log writes */
storeLogClose();
accessLogClose();
- Store::Root().sync(); /* Flush log close */
+ Store::Root().sync(); /* Flush log close */
StoreFileSystem::FreeAllFs();
DiskIOModule::FreeAllModules();
#if LEAK_CHECK_MODE && 0 /* doesn't work at the moment */
{
return getAllocator()->getStats(stats);
}
+
MemPoolMeter const &getMeter() const;
/**
- * \param stats Object to be filled with statistical data about pool.
- * \retval Number of objects in use, ie. allocated.
+ * \param stats Object to be filled with statistical data about pool.
+ * \retval Number of objects in use, ie. allocated.
*/
int getStats(MemPoolStats * stats);
} // namespace Mem
#endif /* _SQUID_SRC_MEM_ALLOCATORPROXY_H */
+
#include <cassert>
#include <cstring>
-#define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */
+#define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */
extern time_t squid_curtime;
* MemPools::GetInstance().setDefaultPoolChunking() can be called.
*/
MemPools::MemPools() : pools(NULL), mem_idle_limit(2 << 20 /* 2 MB */),
- poolCount(0), defaultIsChunked(USE_CHUNKEDMEMPOOLS && !RUNNING_ON_VALGRIND)
+ poolCount(0), defaultIsChunked(USE_CHUNKEDMEMPOOLS && !RUNNING_ON_VALGRIND)
{
char *cfg = getenv("MEMPOOLS");
if (cfg)
}
MemImplementingAllocator::MemImplementingAllocator(char const *aLabel, size_t aSize) : MemAllocator(aLabel),
- next(NULL),
- alloc_calls(0),
- free_calls(0),
- saved_calls(0),
- obj_size(RoundedSize(aSize))
+ next(NULL),
+ alloc_calls(0),
+ free_calls(0),
+ saved_calls(0),
+ obj_size(RoundedSize(aSize))
{
memPID = ++Pool_id_counter;
{
return obj_size;
}
+
/// \ingroup MemPoolsAPI
#define MEM_MIN_FREE 32
/// \ingroup MemPoolsAPI
-#define MEM_MAX_FREE 65535 /* unsigned short is max number of items per chunk */
+#define MEM_MAX_FREE 65535 /* unsigned short is max number of items per chunk */
class MemImplementingAllocator;
class MemPoolStats;
void flushMeters();
/**
- \param label Name for the pool. Displayed in stats.
- \param obj_size Size of elements in MemPool.
+ \param label Name for the pool. Displayed in stats.
+ \param obj_size Size of elements in MemPool.
*/
MemImplementingAllocator * create(const char *label, size_t obj_size);
virtual ~MemAllocator() {}
/**
- \param stats Object to be filled with statistical data about pool.
- \retval Number of objects in use, ie. allocated.
+ \param stats Object to be filled with statistical data about pool.
+ \retval Number of objects in use, ie. allocated.
*/
virtual int getStats(MemPoolStats * stats, int accumulate = 0) = 0;
virtual void setChunkSize(size_t chunksize) {}
/**
- \param minSize Minimum size needed to be allocated.
+ \param minSize Minimum size needed to be allocated.
\retval n Smallest size divisible by sizeof(void*)
*/
static size_t RoundedSize(size_t minSize);
extern int memPoolsTotalAllocated(void);
#endif /* _MEM_POOL_H_ */
+
newChunk = new MemChunk(this);
chunk = Chunks;
- if (chunk == NULL) { /* first chunk in pool */
+ if (chunk == NULL) { /* first chunk in pool */
Chunks = newChunk;
return;
}
int cap;
size_t csize = chunksize;
- if (Chunks) /* unsafe to tamper */
+ if (Chunks) /* unsafe to tamper */
return;
- csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE; /* round up to page size */
+ csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE; /* round up to page size */
cap = csize / obj_size;
if (cap < MEM_MIN_FREE)
cap = 1;
csize = cap * obj_size;
- csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE; /* round up to page size */
+ csize = ((csize + MEM_PAGE_SIZE - 1) / MEM_PAGE_SIZE) * MEM_PAGE_SIZE; /* round up to page size */
cap = csize / obj_size;
chunk_capacity = cap;
assert(chunk->inuse_count > 0);
-- chunk->inuse_count;
(void) VALGRIND_MAKE_MEM_DEFINED(Free, sizeof(void *));
- freeCache = *(void **)Free; /* remove from global cache */
- *(void **)Free = chunk->freeList; /* stuff into chunks freelist */
+ freeCache = *(void **)Free; /* remove from global cache */
+ *(void **)Free = chunk->freeList; /* stuff into chunks freelist */
(void) VALGRIND_MAKE_MEM_NOACCESS(Free, sizeof(void *));
chunk->freeList = Free;
chunk->lastref = squid_curtime;
int chunks_free = 0;
int chunks_partial = 0;
- if (!accumulate) /* need skip memset for GlobalStats accumulation */
+ if (!accumulate) /* need skip memset for GlobalStats accumulation */
memset(stats, 0, sizeof(MemPoolStats));
- clean((time_t) 555555); /* don't want to get chunks released before reporting */
+ clean((time_t) 555555); /* don't want to get chunks released before reporting */
stats->pool = this;
stats->label = objectType();
return meter.inuse.level;
}
+
#include "mem/Pool.h"
#define MEM_CHUNK_SIZE 4 * 4096 /* 16KB ... 4 * VM_PAGE_SZ */
-#define MEM_CHUNK_MAX_SIZE 256 * 1024 /* 2MB */
+#define MEM_CHUNK_MAX_SIZE 256 * 1024 /* 2MB */
class MemChunk;
virtual void clean(time_t maxage);
/**
- \param stats Object to be filled with statistical data about pool.
- \retval Number of objects in use, ie. allocated.
+ \param stats Object to be filled with statistical data about pool.
+ \retval Number of objects in use, ie. allocated.
*/
virtual int getStats(MemPoolStats * stats, int accumulate);
};
#endif /* _MEM_POOL_CHUNKED_H_ */
+
int
MemPoolMalloc::getStats(MemPoolStats * stats, int accumulate)
{
- if (!accumulate) /* need skip memset for GlobalStats accumulation */
+ if (!accumulate) /* need skip memset for GlobalStats accumulation */
memset(stats, 0, sizeof(MemPoolStats));
stats->pool = this;
virtual void clean(time_t maxage);
/**
- \param stats Object to be filled with statistical data about pool.
- \retval Number of objects in use, ie. allocated.
+ \param stats Object to be filled with statistical data about pool.
+ \retval Number of objects in use, ie. allocated.
*/
virtual int getStats(MemPoolStats * stats, int accumulate);
};
#endif /* _MEM_POOL_MALLOC_H_ */
+
namespace Mem
{
- void Init();
- void Report();
- void Stats(StoreEntry *);
- void CleanIdlePools(void *unused);
- void Report(std::ostream &);
- void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &);
+void Init();
+void Report();
+void Stats(StoreEntry *);
+void CleanIdlePools(void *unused);
+void Report(std::ostream &);
+void PoolReport(const MemPoolStats * mp_st, const MemPoolMeter * AllMeter, std::ostream &);
};
extern const size_t squidSystemPageSize;
void memCheckInit(void);
#endif /* _SQUID_SRC_MEM_FORWARD_H */
+
{
"Short Strings", MemAllocator::RoundedSize(36),
- }, /* to fit rfc1123 and similar */
+ }, /* to fit rfc1123 and similar */
{
"Medium Strings", MemAllocator::RoundedSize(128),
- }, /* to fit most urls */
+ }, /* to fit most urls */
{
"Long Strings", MemAllocator::RoundedSize(512),
},
memBufStats(std::ostream & stream)
{
stream << "Large buffers: " <<
- HugeBufCountMeter.level << " (" <<
- HugeBufVolumeMeter.level / 1024 << " KB)\n";
+ HugeBufCountMeter.level << " (" <<
+ HugeBufVolumeMeter.level / 1024 << " KB)\n";
}
void
}
}
-static double clean_interval = 15.0; /* time to live of idle chunk before release */
+static double clean_interval = 15.0; /* time to live of idle chunk before release */
void
Mem::CleanIdlePools(void *unused)
stream << "Current memory usage:\n";
/* heading */
stream << "Pool\t Obj Size\t"
- "Chunks\t\t\t\t\t\t\t"
- "Allocated\t\t\t\t\t"
- "In Use\t\t\t\t\t"
- "Idle\t\t\t"
- "Allocations Saved\t\t\t"
- "Rate\t"
- "\n"
- " \t (bytes)\t"
- "KB/ch\t obj/ch\t"
- "(#)\t used\t free\t part\t %Frag\t "
- "(#)\t (KB)\t high (KB)\t high (hrs)\t %Tot\t"
- "(#)\t (KB)\t high (KB)\t high (hrs)\t %alloc\t"
- "(#)\t (KB)\t high (KB)\t"
- "(#)\t %cnt\t %vol\t"
- "(#)/sec\t"
- "\n";
+ "Chunks\t\t\t\t\t\t\t"
+ "Allocated\t\t\t\t\t"
+ "In Use\t\t\t\t\t"
+ "Idle\t\t\t"
+ "Allocations Saved\t\t\t"
+ "Rate\t"
+ "\n"
+ " \t (bytes)\t"
+ "KB/ch\t obj/ch\t"
+ "(#)\t used\t free\t part\t %Frag\t "
+ "(#)\t (KB)\t high (KB)\t high (hrs)\t %Tot\t"
+ "(#)\t (KB)\t high (KB)\t high (hrs)\t %alloc\t"
+ "(#)\t (KB)\t high (KB)\t"
+ "(#)\t %cnt\t %vol\t"
+ "(#)/sec\t"
+ "\n";
xm_deltat = current_dtime - xm_time;
xm_time = current_dtime;
while ((pool = memPoolIterateNext(iter))) {
pool->getStats(&mp_stats);
- if (!mp_stats.pool) /* pool destroyed */
+ if (!mp_stats.pool) /* pool destroyed */
continue;
if (mp_stats.pool->getMeter().gb_allocated.count > 0) {
stream << "Cumulative allocated volume: "<< double_to_str(buf, 64, mp_total.TheMeter->gb_allocated.bytes) << "\n";
/* overhead */
stream << "Current overhead: " << mp_total.tot_overhead << " bytes (" <<
- std::setprecision(3) << xpercent(mp_total.tot_overhead, mp_total.TheMeter->inuse.level) << "%)\n";
+ std::setprecision(3) << xpercent(mp_total.tot_overhead, mp_total.TheMeter->inuse.level) << "%)\n";
/* limits */
if (mp_total.mem_idle_limit >= 0)
stream << "Idle pool limit: " << std::setprecision(2) << toMB(mp_total.mem_idle_limit) << " MB\n";
stream << "Pools ever used: " << mp_total.tot_pools_alloc - not_used << " (shown above)\n";
stream << "Currently in use: " << mp_total.tot_pools_inuse << "\n";
}
+
}
mem_node::mem_node(int64_t offset) :
- nodeBuffer(0,offset,data),
- write_pending(false)
+ nodeBuffer(0,offset,data),
+ write_pending(false)
{
*data = 0;
}
{
return start() < rhs.start();
}
+
void memNodeWriteComplete(void *);
#endif /* SQUID_MEM_NODE_H */
+
if (atomic())
entry->complete();
}
+
} // namespace Mgr
#endif /* SQUID_MGR_ACTION_H */
+
} // namespace Mgr
#endif /* SQUID_MGR_ACTION_CREATOR_H */
+
msg.putString(password);
queryParams.pack(msg);
}
+
std::ostream &operator <<(std::ostream &os, const Mgr::ActionParams ¶ms);
#endif /* SQUID_MGR_ACTION_PARAMS_H */
+
wordlistDestroy(&actions);
delete next;
}
+
} //namespace Mgr
#endif /* SQUID_MGR_CACHEMGRPASSWD_H_ */
+
public:
ActionProfile(const char* aName, const char* aDesc, bool aPwReq,
bool anAtomic, const ActionCreatorPointer &aCreator):
- name(aName), desc(aDesc), isPwReq(aPwReq), isAtomic(anAtomic),
- creator(aCreator) {
+ name(aName), desc(aDesc), isPwReq(aPwReq), isAtomic(anAtomic),
+ creator(aCreator) {
}
public:
}
#endif /* SQUID_MGR_ACTION_PROFILE_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Mgr, ActionWriter);
Mgr::ActionWriter::ActionWriter(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn):
- StoreToCommWriter(conn, anAction->createStoreEntry()),
- action(anAction)
+ StoreToCommWriter(conn, anAction->createStoreEntry()),
+ action(anAction)
{
debugs(16, 5, HERE << conn << " action: " << action);
}
StoreToCommWriter::start();
action->fillEntry(entry, false);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_ACTION_WRITER_H */
+
}
Mgr::ReconfigureAction::ReconfigureAction(const Command::Pointer &aCmd):
- Action(aCmd)
+ Action(aCmd)
{
debugs(16, 5, HERE);
}
}
Mgr::OfflineToggleAction::OfflineToggleAction(const Command::Pointer &aCmd):
- Action(aCmd)
+ Action(aCmd)
{
debugs(16, 5, HERE);
}
RegisterAction("reconfigure", "Reconfigure Squid", &Mgr::ReconfigureAction::Create, 1, 1);
RegisterAction("rotate", "Rotate Squid Logs", &Mgr::RotateAction::Create, 1, 1);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_BASIC_ACTIONS_H */
+
return os << *cmd.profile;
return os << "undef";
}
+
std::ostream &operator <<(std::ostream &os, const Mgr::Command &cmd);
#endif /* SQUID_MGR_COMMAND_H */
+
}
Mgr::CountersAction::CountersAction(const CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_COUNTERS_ACTION_H */
+
Mgr::Filler::Filler(const Action::Pointer &anAction, const Comm::ConnectionPointer &conn,
unsigned int aRequestId):
- StoreToCommWriter(conn, anAction->createStoreEntry()),
- action(anAction),
- requestId(aRequestId)
+ StoreToCommWriter(conn, anAction->createStoreEntry()),
+ action(anAction),
+ requestId(aRequestId)
{
debugs(16, 5, HERE << conn << " action: " << action);
}
action->sendResponse(requestId);
StoreToCommWriter::swanSong();
}
+
} // namespace Mgr
#endif /* SQUID_MGR_FILLER_H */
+
Mgr::Forwarder::Forwarder(const Comm::ConnectionPointer &aConn, const ActionParams &aParams,
HttpRequest* aRequest, StoreEntry* anEntry):
- Ipc::Forwarder(new Request(KidIdentifier, 0, aConn, aParams), 10),
- httpRequest(aRequest), entry(anEntry), conn(aConn)
+ Ipc::Forwarder(new Request(KidIdentifier, 0, aConn, aParams), 10),
+ httpRequest(aRequest), entry(anEntry), conn(aConn)
{
debugs(16, 5, HERE << conn);
Must(Comm::IsConnOpen(conn));
entry->flush();
entry->complete();
}
+
} // namespace Mgr
#endif /* SQUID_MGR_FORWARDER_H */
+
}
Mgr::FunAction::FunAction(const Command::Pointer &aCmd, OBJH* aHandler):
- Action(aCmd), handler(aHandler)
+ Action(aCmd), handler(aHandler)
{
Must(handler != NULL);
debugs(16, 5, HERE);
if (atomic() && UsingSmp())
storeAppendPrintf(entry, "} by kid%d\n\n", KidIdentifier);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_FUN_ACTION_H */
+
}
Mgr::InfoAction::InfoAction(const CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_INFO_ACTION_H */
+
Mgr::Inquirer::Inquirer(Action::Pointer anAction,
const Request &aCause, const Ipc::StrandCoords &coords):
- Ipc::Inquirer(aCause.clone(), applyQueryParams(coords, aCause.params.queryParams), anAction->atomic() ? 10 : 100),
- aggrAction(anAction)
+ Ipc::Inquirer(aCause.clone(), applyQueryParams(coords, aCause.params.queryParams), anAction->atomic() ? 10 : 100),
+ aggrAction(anAction)
{
conn = aCause.conn;
Ipc::ImportFdIntoComm(conn, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket);
return sc;
}
+
} // namespace Mgr
#endif /* SQUID_MGR_INQUIRER_H */
+
#include "mgr/IntParam.h"
Mgr::IntParam::IntParam():
- QueryParam(QueryParam::ptInt), array()
+ QueryParam(QueryParam::ptInt), array()
{
}
Mgr::IntParam::IntParam(const std::vector<int>& anArray):
- QueryParam(QueryParam::ptInt), array(anArray)
+ QueryParam(QueryParam::ptInt), array(anArray)
{
}
{
return array;
}
+
} // namespace Mgr
#endif /* SQUID_MGR_INT_PARAM_H */
+
}
Mgr::IntervalAction::IntervalAction(const CommandPointer &aCmd, int aMinutes, int aHours):
- Action(aCmd), minutes(aMinutes), hours(aHours), data()
+ Action(aCmd), minutes(aMinutes), hours(aHours), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_INTERVAL_ACTION_H */
+
}
Mgr::IoAction::IoAction(const CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_IO_ACTION_H */
+
} // namespace Mgr
#endif /* SQUID_MGR_QUERY_PARAM_H */
+
} // namespace Mgr
#endif /* SQUID_MGR_QUERY_PARAMS_H */
+
CacheManager::GetInstance()->registerProfile(action, desc, handler,
pw_req_flag, atomic);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_REGISTRATION_H */
+
Mgr::Request::Request(int aRequestorId, unsigned int aRequestId, const Comm::ConnectionPointer &aConn,
const ActionParams &aParams):
- Ipc::Request(aRequestorId, aRequestId),
- conn(aConn),
- params(aParams)
+ Ipc::Request(aRequestorId, aRequestId),
+ conn(aConn),
+ params(aParams)
{
Must(requestorId > 0);
}
Mgr::Request::Request(const Request& request):
- Ipc::Request(request.requestorId, request.requestId),
- conn(request.conn), params(request.params)
+ Ipc::Request(request.requestorId, request.requestId),
+ conn(request.conn), params(request.params)
{
}
Mgr::Request::Request(const Ipc::TypedMsgHdr& msg):
- Ipc::Request(0, 0)
+ Ipc::Request(0, 0)
{
msg.checkType(Ipc::mtCacheMgrRequest);
msg.getPod(requestorId);
{
return new Request(*this);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_REQUEST_H */
+
#include "mgr/Response.h"
Mgr::Response::Response(unsigned int aRequestId, Action::Pointer anAction):
- Ipc::Response(aRequestId), action(anAction)
+ Ipc::Response(aRequestId), action(anAction)
{
Must(!action || action->name()); // if there is an action, it must be named
}
Mgr::Response::Response(const Response& response):
- Ipc::Response(response.requestId), action(response.action)
+ Ipc::Response(response.requestId), action(response.action)
{
}
Mgr::Response::Response(const Ipc::TypedMsgHdr& msg):
- Ipc::Response(0)
+ Ipc::Response(0)
{
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(requestId);
Must(hasAction());
return *action;
}
+
} // namespace Mgr
#endif /* SQUID_MGR_RESPONSE_H */
+
}
Mgr::ServiceTimesAction::ServiceTimesAction(const CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_SERVICE_TIMES_ACTION_H */
+
}
Mgr::StoreIoAction::StoreIoAction(const CommandPointer &aCmd):
- Action(aCmd), data()
+ Action(aCmd), data()
{
debugs(16, 5, HERE);
}
msg.checkType(Ipc::mtCacheMgrResponse);
msg.getPod(data);
}
+
} // namespace Mgr
#endif /* SQUID_MGR_STORE_IO_ACTION_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Mgr, StoreToCommWriter);
Mgr::StoreToCommWriter::StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry* anEntry):
- AsyncJob("Mgr::StoreToCommWriter"),
- clientConnection(conn), entry(anEntry), sc(NULL), writeOffset(0), closer(NULL)
+ AsyncJob("Mgr::StoreToCommWriter"),
+ clientConnection(conn), entry(anEntry), sc(NULL), writeOffset(0), closer(NULL)
{
debugs(16, 6, HERE << clientConnection);
closer = asyncCall(16, 5, "Mgr::StoreToCommWriter::noteCommClosed",
if (Comm::IsConnOpen(mgrWriter->clientConnection))
mgrWriter->clientConnection->close();
}
+
} // namespace Mgr
#endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */
+
#include "mgr/StringParam.h"
Mgr::StringParam::StringParam():
- QueryParam(QueryParam::ptString), str()
+ QueryParam(QueryParam::ptString), str()
{
}
Mgr::StringParam::StringParam(const String& aString):
- QueryParam(QueryParam::ptString), str(aString)
+ QueryParam(QueryParam::ptString), str(aString)
{
}
{
return str;
}
+
} // namespace Mgr
#endif /* SQUID_MGR_STRING_PARAM_H */
+
} // namespace Mgr
#endif /* SQUID_MGR_FORWARD_H */
+
}
MimeIcon::MimeIcon(const char *aName) :
- icon_(xstrdup(aName))
+ icon_(xstrdup(aName))
{
url_ = xstrdup(internalLocalUri("/squid-internal-static/icons/", icon_));
}
const char *aContentType, const char *aContentEncoding,
const char *aTransferMode, bool optionViewEnable,
bool optionDownloadEnable, const char *anIconName) :
- pattern(xstrdup(aPattern)),
- compiled_pattern(compiledPattern),
- content_type(xstrdup(aContentType)),
- content_encoding(xstrdup(aContentEncoding)),
- view_option(optionViewEnable),
- download_option(optionViewEnable),
- theIcon(anIconName), next(NULL)
+ pattern(xstrdup(aPattern)),
+ compiled_pattern(compiledPattern),
+ content_type(xstrdup(aContentType)),
+ content_encoding(xstrdup(aContentEncoding)),
+ view_option(optionViewEnable),
+ download_option(optionViewEnable),
+ theIcon(anIconName), next(NULL)
{
if (!strcasecmp(aTransferMode, "ascii"))
transfer_mode = 'A';
else
transfer_mode = 'I';
}
+
bool mimeGetViewOption(const char *fn);
#endif /* SQUID_MIME_H_ */
+
size_t headersEnd(const char *, size_t);
#endif /* SQUID_MIME_HEADER_H_ */
+
extern IPH mcastJoinGroups;
#endif /* SQUID_MULTICAST_H_ */
+
* period. The larger the number of requests between cycled resets the
* more balanced the operations.
*
- \param data unused.
+ \param data unused.
\todo Make the reset timing a selectable parameter in squid.conf
*/
static void
debugs(15, 5, "neighborsUdpPing: Peer " << p->host);
if (!peerWouldBePinged(p, request))
- continue; /* next CachePeer */
+ continue; /* next CachePeer */
++peers_pinged;
else
*timeout = 2 * sibling_timeout / sibling_exprep;
} else
- *timeout = 2000; /* 2 seconds */
+ *timeout = 2000; /* 2 seconds */
if (Config.Timeout.icp_query_max)
if (*timeout > Config.Timeout.icp_query_max)
best_p = p;
best_rtt = p_rtt;
- if (p_rtt) /* informative choice (aka educated guess) */
+ if (p_rtt) /* informative choice (aka educated guess) */
++ichoice_count;
debugs(15, 4, "neighborsDigestSelect: peer " << p->host << " leads with rtt " << best_rtt);
}
#endif
+
CachePeer *whichPeer(const Ip::Address &from);
#endif /* SQUID_NEIGHBORS_H_ */
+
result = acc;
return success(s - buf_.rawContent() - 1);
}
+
} /* namespace Parser */
#endif /* SQUID_PARSER_TOKENIZER_H_ */
+
};
#endif /* SQUID_TESTTOKENIZER_H_ */
+
#include "SquidConfig.h"
#include "Store.h"
-#define PCONN_FDS_SZ 8 /* pconn set size, increase for better memcache hit rate */
+#define PCONN_FDS_SZ 8 /* pconn set size, increase for better memcache hit rate */
//TODO: re-attach to MemPools. WAS: static MemAllocator *pconn_fds_pool = NULL;
PconnModule * PconnModule::instance = NULL;
/* ========== IdleConnList ============================================ */
IdleConnList::IdleConnList(const char *key, PconnPool *thePool) :
- capacity_(PCONN_FDS_SZ),
- size_(0),
- parent_(thePool)
+ capacity_(PCONN_FDS_SZ),
+ size_(0),
+ parent_(thePool)
{
hash.key = xstrdup(key);
theList_ = new Comm::ConnectionPointer[capacity_];
/* ========== PconnPool PUBLIC FUNCTIONS ============================================ */
PconnPool::PconnPool(const char *aDescr, const CbcPointer<PeerPoolMgr> &aMgr):
- table(NULL), descr(aDescr),
- mgr(aMgr),
- theCount(0)
+ table(NULL), descr(aDescr),
+ mgr(aMgr),
+ theCount(0)
{
int i;
table = hash_create((HASHCMP *) strcmp, 229, hash_string);
{
PconnModule::GetInstance()->dump(e);
}
+
};
#endif /* SQUID_PCONN_H */
+
#define StoreDigestCBlockSize sizeof(StoreDigestCBlock)
/* min interval for requesting digests from a given peer */
-static const time_t PeerDigestReqMinGap = 5 * 60; /* seconds */
+static const time_t PeerDigestReqMinGap = 5 * 60; /* seconds */
/* min interval for requesting digests (cumulative request stream) */
-static const time_t GlobDigestReqMinGap = 1 * 60; /* seconds */
+static const time_t GlobDigestReqMinGap = 1 * 60; /* seconds */
/* local vars */
-static time_t pd_last_req_time = 0; /* last call to Check */
+static time_t pd_last_req_time = 0; /* last call to Check */
/* initialize peer digest */
static void
pd->flags.needed = true;
pd->times.needed = squid_curtime;
- peerDigestSetCheck(pd, 0); /* check asap */
+ peerDigestSetCheck(pd, 0); /* check asap */
}
/* currently we do not have a reason to disable without destroying */
{
debugs(72, 2, "peerDigestDisable: peer " << pd->host.buf() << " disabled for good");
pd->times.disabled = squid_curtime;
- pd->times.next_check = -1; /* never */
+ pd->times.next_check = -1; /* never */
pd->flags.usable = 0;
if (pd->cd) {
{
assert(pd);
return pd->times.retry_delay > 0 ?
- 2 * pd->times.retry_delay : /* exponential backoff */
- PeerDigestReqMinGap; /* minimal delay */
+ 2 * pd->times.retry_delay : /* exponential backoff */
+ PeerDigestReqMinGap; /* minimal delay */
}
/* artificially increases Expires: setting to avoid race conditions
assert(!pd->flags.requested);
- pd->times.next_check = 0; /* unknown */
+ pd->times.next_check = 0; /* unknown */
if (!cbdataReferenceValid(pd->peer)) {
peerDigestNotePeerGone(pd);
}
if (req_time <= squid_curtime)
- peerDigestRequest(pd); /* will set pd->flags.requested */
+ peerDigestRequest(pd); /* will set pd->flags.requested */
else
peerDigestSetCheck(pd, req_time - squid_curtime);
}
} else {
/* some kind of a bug */
peerDigestFetchAbort(fetch, buf, reply->sline.reason());
- return -1; /* XXX -1 will abort stuff in ReadReply! */
+ return -1; /* XXX -1 will abort stuff in ReadReply! */
}
/* must have a ready-to-use store entry if we got here */
}
fetch->state = DIGEST_READ_CBLOCK;
- return hdr_size; /* Say how much data we read */
+ return hdr_size; /* Say how much data we read */
} else {
/* need more data, do we have space? */
peerDigestFetchAbort(fetch, buf, "stored header too big");
return -1;
} else {
- return 0; /* We need to read more to parse .. */
+ return 0; /* We need to read more to parse .. */
}
}
peerDigestFetchAbort(fetch, buf, "digest cblock too big");
return -1;
} else {
- return 0; /* We need more data */
+ return 0; /* We need more data */
}
}
fetch->mask_offset << ", expected " << pd->cd->mask_size);
assert(fetch->mask_offset == pd->cd->mask_size);
assert(peerDigestFetchedEnough(fetch, NULL, 0, "peerDigestSwapInMask"));
- return -1; /* XXX! */
+ return -1; /* XXX! */
} else {
/* We always read everything, so return so */
return size;
peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const char *step_name)
{
PeerDigest *pd = NULL;
- const char *host = "<unknown>"; /* peer host */
- const char *reason = NULL; /* reason for completion */
- const char *no_bug = NULL; /* successful completion if set */
+ const char *host = "<unknown>"; /* peer host */
+ const char *reason = NULL; /* reason for completion */
+ const char *no_bug = NULL; /* successful completion if set */
const int pdcb_valid = cbdataReferenceValid(fetch->pd);
const int pcb_valid = cbdataReferenceValid(fetch->pd->peer);
if (!(pd = fetch->pd))
reason = "peer digest disappeared?!";
-#if DONT /* WHY NOT? /HNO */
+#if DONT /* WHY NOT? /HNO */
else if (!cbdataReferenceValid(pd))
reason = "invalidated peer digest?!";
}
#endif
+
#if HAVE_PROFILE_H
#include <profile.h>
-#endif /* HAVE_PROFILE_H */
+#endif /* HAVE_PROFILE_H */
#if HAVE_KRB5_H
#if HAVE_BROKEN_SOLARIS_KRB5_H
#if defined(__cplusplus)
#define KRB5INT_BEGIN_DECLS extern "C" {
#define KRB5INT_END_DECLS
- KRB5INT_BEGIN_DECLS
+KRB5INT_BEGIN_DECLS
#endif
#endif
#include <krb5.h>
#endif /* HAVE_COM_ERR_H */
#if HAVE_COM_ERR_H
#include <com_err.h>
-#endif /* HAVE_COM_ERR_H */
+#endif /* HAVE_COM_ERR_H */
#if HAVE_GSSAPI_GSSAPI_H
#include <gssapi/gssapi.h>
#elif HAVE_GSSAPI_H
#include <gssapi.h>
-#endif /* HAVE_GSSAPI_H */
+#endif /* HAVE_GSSAPI_H */
#if !USE_HEIMDAL_KRB5
#if HAVE_GSSAPI_GSSAPI_EXT_H
#include <gssapi/gssapi_ext.h>
-#endif /* HAVE_GSSAPI_GSSAPI_EXT_H */
+#endif /* HAVE_GSSAPI_GSSAPI_EXT_H */
#if HAVE_GSSAPI_GSSAPI_KRB5_H
#include <gssapi/gssapi_krb5.h>
-#endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */
+#endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */
#if HAVE_GSSAPI_GSSAPI_GENERIC_H
#include <gssapi/gssapi_generic.h>
-#endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */
-#endif /* !USE_HEIMDAL_KRB5 */
+#endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */
+#endif /* !USE_HEIMDAL_KRB5 */
#ifndef gss_nt_service_name
#define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE
#elif !HAVE_ERROR_MESSAGE && HAVE_KRB5_GET_ERR_TEXT
#define error_message(code) krb5_get_err_text(kparam.context,code)
#elif !HAVE_ERROR_MESSAGE
- static char err_code[17];
- const char *KRB5_CALLCONV
- error_message(long code) {
- snprintf(err_code,16,"%ld",code);
- return err_code;
- }
+static char err_code[17];
+const char *KRB5_CALLCONV
+error_message(long code) {
+ snprintf(err_code,16,"%ld",code);
+ return err_code;
+}
#endif
#ifndef gss_mech_spnego
- static gss_OID_desc _gss_mech_spnego =
- { 6, (void *) "\x2b\x06\x01\x05\x05\x02" };
- gss_OID gss_mech_spnego = &_gss_mech_spnego;
+static gss_OID_desc _gss_mech_spnego =
+{ 6, (void *) "\x2b\x06\x01\x05\x05\x02" };
+gss_OID gss_mech_spnego = &_gss_mech_spnego;
#endif
#if USE_IBM_KERBEROS
#include <ibm_svc/krb5_svc.h>
- const char *KRB5_CALLCONV error_message(long code) {
- char *msg = NULL;
- krb5_svc_get_msg(code, &msg);
- return msg;
- }
+const char *KRB5_CALLCONV error_message(long code) {
+ char *msg = NULL;
+ krb5_svc_get_msg(code, &msg);
+ return msg;
+}
#endif
- /*
- * Kerberos context and cache structure
- * Caches authentication details to reduce
- * number of authentication requests to kdc
- */
- static struct kstruct {
- krb5_context context;
- krb5_ccache cc;
- } kparam = {
- NULL, NULL};
+/*
+ * Kerberos context and cache structure
+ * Caches authentication details to reduce
+ * number of authentication requests to kdc
+ */
+static struct kstruct {
+ krb5_context context;
+ krb5_ccache cc;
+} kparam = {
+ NULL, NULL
+};
- /*
- * krb5_create_cache creates a Kerberos file credential cache or a memory
- * credential cache if supported. The initial key for the principal
- * principal_name is extracted from the keytab keytab_filename.
- *
- * If keytab_filename is NULL the default will be used.
- * If principal_name is NULL the first working entry of the keytab will be used.
- */
- int krb5_create_cache(char *keytab_filename, char *principal_name);
+/*
+ * krb5_create_cache creates a Kerberos file credential cache or a memory
+ * credential cache if supported. The initial key for the principal
+ * principal_name is extracted from the keytab keytab_filename.
+ *
+ * If keytab_filename is NULL the default will be used.
+ * If principal_name is NULL the first working entry of the keytab will be used.
+ */
+int krb5_create_cache(char *keytab_filename, char *principal_name);
- /*
- * krb5_cleanup clears used Keberos memory
- */
- void krb5_cleanup(void);
+/*
+ * krb5_cleanup clears used Keberos memory
+ */
+void krb5_cleanup(void);
- /*
- * check_gss_err checks for gssapi error codes, extracts the error message
- * and prints it.
- */
- int check_gss_err(OM_uint32 major_status, OM_uint32 minor_status,
- const char *function);
-
- int check_gss_err(OM_uint32 major_status, OM_uint32 minor_status,
- const char *function) {
- if (GSS_ERROR(major_status)) {
- OM_uint32 maj_stat, min_stat;
- OM_uint32 msg_ctx = 0;
- gss_buffer_desc status_string;
- char buf[1024];
- size_t len;
-
- len = 0;
- msg_ctx = 0;
- while (!msg_ctx) {
- /* convert major status code (GSS-API error) to text */
- maj_stat = gss_display_status(&min_stat, major_status,
- GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
- if (maj_stat == GSS_S_COMPLETE) {
- if (sizeof(buf) > len + status_string.length + 1) {
- memcpy(buf + len, status_string.value,
- status_string.length);
- len += status_string.length;
- }
- gss_release_buffer(&min_stat, &status_string);
- break;
+/*
+ * check_gss_err checks for gssapi error codes, extracts the error message
+ * and prints it.
+ */
+int check_gss_err(OM_uint32 major_status, OM_uint32 minor_status,
+ const char *function);
+
+int check_gss_err(OM_uint32 major_status, OM_uint32 minor_status,
+ const char *function) {
+ if (GSS_ERROR(major_status)) {
+ OM_uint32 maj_stat, min_stat;
+ OM_uint32 msg_ctx = 0;
+ gss_buffer_desc status_string;
+ char buf[1024];
+ size_t len;
+
+ len = 0;
+ msg_ctx = 0;
+ while (!msg_ctx) {
+ /* convert major status code (GSS-API error) to text */
+ maj_stat = gss_display_status(&min_stat, major_status,
+ GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
+ if (maj_stat == GSS_S_COMPLETE) {
+ if (sizeof(buf) > len + status_string.length + 1) {
+ memcpy(buf + len, status_string.value,
+ status_string.length);
+ len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
+ break;
}
- if (sizeof(buf) > len + 2) {
- strcpy(buf + len, ". ");
- len += 2;
- }
- msg_ctx = 0;
- while (!msg_ctx) {
- /* convert minor status code (underlying routine error) to text */
- maj_stat = gss_display_status(&min_stat, minor_status,
- GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
- if (maj_stat == GSS_S_COMPLETE) {
- if (sizeof(buf) > len + status_string.length) {
- memcpy(buf + len, status_string.value,
- status_string.length);
- len += status_string.length;
- }
- gss_release_buffer(&min_stat, &status_string);
- break;
+ gss_release_buffer(&min_stat, &status_string);
+ }
+ if (sizeof(buf) > len + 2) {
+ strcpy(buf + len, ". ");
+ len += 2;
+ }
+ msg_ctx = 0;
+ while (!msg_ctx) {
+ /* convert minor status code (underlying routine error) to text */
+ maj_stat = gss_display_status(&min_stat, minor_status,
+ GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
+ if (maj_stat == GSS_S_COMPLETE) {
+ if (sizeof(buf) > len + status_string.length) {
+ memcpy(buf + len, status_string.value,
+ status_string.length);
+ len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
+ break;
}
- debugs(11, 5, HERE << function << "failed: " << buf);
- return (1);
+ gss_release_buffer(&min_stat, &status_string);
}
- return (0);
+ debugs(11, 5, HERE << function << "failed: " << buf);
+ return (1);
}
+ return (0);
+}
- void krb5_cleanup() {
- debugs(11, 5, HERE << "Cleanup kerberos context");
- if (kparam.context) {
- if (kparam.cc)
- krb5_cc_destroy(kparam.context, kparam.cc);
- kparam.cc = NULL;
- krb5_free_context(kparam.context);
- kparam.context = NULL;
- }
+void krb5_cleanup() {
+ debugs(11, 5, HERE << "Cleanup kerberos context");
+ if (kparam.context) {
+ if (kparam.cc)
+ krb5_cc_destroy(kparam.context, kparam.cc);
+ kparam.cc = NULL;
+ krb5_free_context(kparam.context);
+ kparam.context = NULL;
}
+}
- int krb5_create_cache(char *kf, char *pn) {
+int krb5_create_cache(char *kf, char *pn) {
#define KT_PATH_MAX 256
#define MAX_RENEW_TIME "365d"
#define DEFAULT_SKEW (krb5_deltat) 600
- static char *keytab_filename = NULL, *principal_name = NULL;
- static krb5_keytab keytab = 0;
- static krb5_keytab_entry entry;
- static krb5_kt_cursor cursor;
- static krb5_creds *creds = NULL;
+ static char *keytab_filename = NULL, *principal_name = NULL;
+ static krb5_keytab keytab = 0;
+ static krb5_keytab_entry entry;
+ static krb5_kt_cursor cursor;
+ static krb5_creds *creds = NULL;
#if USE_HEIMDAL_KRB5 && !HAVE_KRB5_GET_RENEWED_CREDS
- static krb5_creds creds2;
+ static krb5_creds creds2;
#endif
- static krb5_principal principal = NULL;
- static krb5_deltat skew;
+ static krb5_principal principal = NULL;
+ static krb5_deltat skew;
#if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
- krb5_get_init_creds_opt *options;
+ krb5_get_init_creds_opt *options;
#else
- krb5_get_init_creds_opt options;
+ krb5_get_init_creds_opt options;
#endif
- krb5_error_code code = 0;
- krb5_deltat rlife;
+ krb5_error_code code = 0;
+ krb5_deltat rlife;
#if HAVE_PROFILE_H && HAVE_KRB5_GET_PROFILE && HAVE_PROFILE_GET_INTEGER && HAVE_PROFILE_RELEASE
- profile_t profile;
+ profile_t profile;
#endif
#if USE_HEIMDAL_KRB5 && !HAVE_KRB5_GET_RENEWED_CREDS
- krb5_kdc_flags flags;
+ krb5_kdc_flags flags;
#if HAVE_KRB5_PRINCIPAL_GET_REALM
- const char *client_realm;
+ const char *client_realm;
#else
- krb5_realm client_realm;
+ krb5_realm client_realm;
#endif
#endif
- char *mem_cache;
+ char *mem_cache;
restart:
- /*
- * Check if credentials need to be renewed
- */
- if (creds &&
- (creds->times.endtime - time(0) > skew) &&
- (creds->times.renew_till - time(0) > 2 * skew)) {
- if (creds->times.endtime - time(0) < 2 * skew) {
+ /*
+ * Check if credentials need to be renewed
+ */
+ if (creds &&
+ (creds->times.endtime - time(0) > skew) &&
+ (creds->times.renew_till - time(0) > 2 * skew)) {
+ if (creds->times.endtime - time(0) < 2 * skew) {
#if HAVE_KRB5_GET_RENEWED_CREDS
- /* renew ticket */
- code =
- krb5_get_renewed_creds(kparam.context, creds, principal,
- kparam.cc, NULL);
+ /* renew ticket */
+ code =
+ krb5_get_renewed_creds(kparam.context, creds, principal,
+ kparam.cc, NULL);
#else
- /* renew ticket */
- flags.i = 0;
- flags.b.renewable = flags.b.renew = 1;
-
- code =
- krb5_cc_get_principal(kparam.context, kparam.cc,
- &creds2.client);
- if (code) {
- debugs(11, 5,
- HERE <<
- "Error while getting principal from credential cache : "
- << error_message(code));
- return (1);
- }
+ /* renew ticket */
+ flags.i = 0;
+ flags.b.renewable = flags.b.renew = 1;
+
+ code =
+ krb5_cc_get_principal(kparam.context, kparam.cc,
+ &creds2.client);
+ if (code) {
+ debugs(11, 5,
+ HERE <<
+ "Error while getting principal from credential cache : "
+ << error_message(code));
+ return (1);
+ }
#if HAVE_KRB5_PRINCIPAL_GET_REALM
- client_realm = krb5_principal_get_realm(kparam.context, principal);
+ client_realm = krb5_principal_get_realm(kparam.context, principal);
#else
- client_realm = krb5_princ_realm(kparam.context, creds2.client);
-#endif
- code =
- krb5_make_principal(kparam.context, &creds2.server,
- (krb5_const_realm)&client_realm, KRB5_TGS_NAME,
- (krb5_const_realm)&client_realm, NULL);
- if (code) {
- debugs(11, 5,
- HERE << "Error while getting krbtgt principal : " <<
- error_message(code));
- return (1);
- }
- code =
- krb5_get_kdc_cred(kparam.context, kparam.cc, flags, NULL,
- NULL, &creds2, &creds);
- krb5_free_creds(kparam.context, &creds2);
+ client_realm = krb5_princ_realm(kparam.context, creds2.client);
#endif
- if (code) {
- if (code == KRB5KRB_AP_ERR_TKT_EXPIRED) {
- krb5_free_creds(kparam.context, creds);
- creds = NULL;
- /* this can happen because of clock skew */
- goto restart;
- }
- debugs(11, 5,
- HERE << "Error while get credentials : " <<
- error_message(code));
- return (1);
- }
- }
- } else {
- /* reinit */
- if (!kparam.context) {
- code = krb5_init_context(&kparam.context);
- if (code) {
- debugs(11, 5,
- HERE << "Error while initialising Kerberos library : "
- << error_message(code));
- return (1);
- }
- }
-#if HAVE_PROFILE_H && HAVE_KRB5_GET_PROFILE && HAVE_PROFILE_GET_INTEGER && HAVE_PROFILE_RELEASE
- code = krb5_get_profile(kparam.context, &profile);
+ code =
+ krb5_make_principal(kparam.context, &creds2.server,
+ (krb5_const_realm)&client_realm, KRB5_TGS_NAME,
+ (krb5_const_realm)&client_realm, NULL);
if (code) {
- if (profile)
- profile_release(profile);
debugs(11, 5,
- HERE << "Error while getting profile : " <<
+ HERE << "Error while getting krbtgt principal : " <<
error_message(code));
return (1);
}
code =
- profile_get_integer(profile, "libdefaults", "clockskew", 0,
- 5 * 60, &skew);
- if (profile)
- profile_release(profile);
+ krb5_get_kdc_cred(kparam.context, kparam.cc, flags, NULL,
+ NULL, &creds2, &creds);
+ krb5_free_creds(kparam.context, &creds2);
+#endif
if (code) {
+ if (code == KRB5KRB_AP_ERR_TKT_EXPIRED) {
+ krb5_free_creds(kparam.context, creds);
+ creds = NULL;
+ /* this can happen because of clock skew */
+ goto restart;
+ }
debugs(11, 5,
- HERE << "Error while getting clockskew : " <<
+ HERE << "Error while get credentials : " <<
error_message(code));
return (1);
}
-#elif USE_HEIMDAL_KRB5 && HAVE_KRB5_GET_MAX_TIME_SKEW
- skew = krb5_get_max_time_skew(kparam.context);
-#elif USE_HEIMDAL_KRB5 && HAVE_MAX_SKEW_IN_KRB5_CONTEXT
- skew = kparam.context->max_skew;
-#else
- skew = DEFAULT_SKEW;
-#endif
-
- if (!kf) {
- char buf[KT_PATH_MAX], *p;
-
- krb5_kt_default_name(kparam.context, buf, KT_PATH_MAX);
- p = strchr(buf, ':');
- if (p)
- ++p;
- xfree(keytab_filename);
- keytab_filename = xstrdup(p ? p : buf);
- } else {
- keytab_filename = xstrdup(kf);
- }
-
- code = krb5_kt_resolve(kparam.context, keytab_filename, &keytab);
+ }
+ } else {
+ /* reinit */
+ if (!kparam.context) {
+ code = krb5_init_context(&kparam.context);
if (code) {
debugs(11, 5,
- HERE << "Error while resolving keytab filename " <<
- keytab_filename << " : " << error_message(code));
+ HERE << "Error while initialising Kerberos library : "
+ << error_message(code));
return (1);
}
-
- if (!pn) {
- code = krb5_kt_start_seq_get(kparam.context, keytab, &cursor);
- if (code) {
- debugs(11, 5,
- HERE << "Error while starting keytab scan : " <<
- error_message(code));
- return (1);
- }
- code =
- krb5_kt_next_entry(kparam.context, keytab, &entry, &cursor);
- krb5_copy_principal(kparam.context, entry.principal,
- &principal);
- if (code && code != KRB5_KT_END) {
- debugs(11, 5,
- HERE << "Error while scanning keytab : " <<
- error_message(code));
- return (1);
- }
-
- code = krb5_kt_end_seq_get(kparam.context, keytab, &cursor);
- if (code) {
- debugs(11, 5,
- HERE << "Error while ending keytab scan : " <<
- error_message(code));
- return (1);
- }
-#if USE_HEIMDAL_KRB5 || ( HAVE_KRB5_KT_FREE_ENTRY && HAVE_DECL_KRB5_KT_FREE_ENTRY)
- code = krb5_kt_free_entry(kparam.context, &entry);
+ }
+#if HAVE_PROFILE_H && HAVE_KRB5_GET_PROFILE && HAVE_PROFILE_GET_INTEGER && HAVE_PROFILE_RELEASE
+ code = krb5_get_profile(kparam.context, &profile);
+ if (code) {
+ if (profile)
+ profile_release(profile);
+ debugs(11, 5,
+ HERE << "Error while getting profile : " <<
+ error_message(code));
+ return (1);
+ }
+ code =
+ profile_get_integer(profile, "libdefaults", "clockskew", 0,
+ 5 * 60, &skew);
+ if (profile)
+ profile_release(profile);
+ if (code) {
+ debugs(11, 5,
+ HERE << "Error while getting clockskew : " <<
+ error_message(code));
+ return (1);
+ }
+#elif USE_HEIMDAL_KRB5 && HAVE_KRB5_GET_MAX_TIME_SKEW
+ skew = krb5_get_max_time_skew(kparam.context);
+#elif USE_HEIMDAL_KRB5 && HAVE_MAX_SKEW_IN_KRB5_CONTEXT
+ skew = kparam.context->max_skew;
#else
- code = krb5_free_keytab_entry_contents(kparam.context, &entry);
+ skew = DEFAULT_SKEW;
#endif
- if (code) {
- debugs(11, 5,
- HERE << "Error while freeing keytab entry : " <<
- error_message(code));
- return (1);
- }
- } else {
- principal_name = xstrdup(pn);
- }
+ if (!kf) {
+ char buf[KT_PATH_MAX], *p;
- if (!principal) {
- code =
- krb5_parse_name(kparam.context, principal_name, &principal);
- if (code) {
- debugs(11, 5,
- HERE << "Error while parsing principal name " <<
- principal_name << " : " << error_message(code));
- return (1);
- }
- }
+ krb5_kt_default_name(kparam.context, buf, KT_PATH_MAX);
+ p = strchr(buf, ':');
+ if (p)
+ ++p;
+ xfree(keytab_filename);
+ keytab_filename = xstrdup(p ? p : buf);
+ } else {
+ keytab_filename = xstrdup(kf);
+ }
- creds = (krb5_creds *) xmalloc(sizeof(*creds));
- memset(creds, 0, sizeof(*creds));
-#if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
- krb5_get_init_creds_opt_alloc(kparam.context, &options);
-#else
- krb5_get_init_creds_opt_init(&options);
-#endif
- code = krb5_string_to_deltat((char *) MAX_RENEW_TIME, &rlife);
- if (code != 0 || rlife == 0) {
+ code = krb5_kt_resolve(kparam.context, keytab_filename, &keytab);
+ if (code) {
+ debugs(11, 5,
+ HERE << "Error while resolving keytab filename " <<
+ keytab_filename << " : " << error_message(code));
+ return (1);
+ }
+
+ if (!pn) {
+ code = krb5_kt_start_seq_get(kparam.context, keytab, &cursor);
+ if (code) {
debugs(11, 5,
- HERE << "Error bad lifetime value " << MAX_RENEW_TIME <<
- " : " << error_message(code));
+ HERE << "Error while starting keytab scan : " <<
+ error_message(code));
return (1);
}
-#if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
- krb5_get_init_creds_opt_set_renew_life(options, rlife);
- code =
- krb5_get_init_creds_keytab(kparam.context, creds, principal,
- keytab, 0, NULL, options);
-#if HAVE_KRB5_GET_INIT_CREDS_FREE_CONTEXT
- krb5_get_init_creds_opt_free(kparam.context, options);
-#else
- krb5_get_init_creds_opt_free(options);
-#endif
-#else
- krb5_get_init_creds_opt_set_renew_life(&options, rlife);
code =
- krb5_get_init_creds_keytab(kparam.context, creds, principal,
- keytab, 0, NULL, &options);
-#endif
- if (code) {
+ krb5_kt_next_entry(kparam.context, keytab, &entry, &cursor);
+ krb5_copy_principal(kparam.context, entry.principal,
+ &principal);
+ if (code && code != KRB5_KT_END) {
debugs(11, 5,
- HERE <<
- "Error while initializing credentials from keytab : " <<
+ HERE << "Error while scanning keytab : " <<
error_message(code));
return (1);
}
-#if !HAVE_KRB5_MEMORY_CACHE
- mem_cache =
- (char *) xmalloc(strlen("FILE:/tmp/peer_proxy_negotiate_auth_")
- + 16);
- if (!mem_cache) {
- debugs(11, 5, "Error while allocating memory");
- return(1);
- }
- snprintf(mem_cache,
- strlen("FILE:/tmp/peer_proxy_negotiate_auth_") + 16,
- "FILE:/tmp/peer_proxy_negotiate_auth_%d", (int) getpid());
-#else
- mem_cache =
- (char *) xmalloc(strlen("MEMORY:peer_proxy_negotiate_auth_") +
- 16);
- if (!mem_cache) {
- debugs(11, 5, "Error while allocating memory");
- return(1);
- }
- snprintf(mem_cache,
- strlen("MEMORY:peer_proxy_negotiate_auth_") + 16,
- "MEMORY:peer_proxy_negotiate_auth_%d", (int) getpid());
-#endif
- setenv("KRB5CCNAME", mem_cache, 1);
- code = krb5_cc_resolve(kparam.context, mem_cache, &kparam.cc);
- xfree(mem_cache);
+ code = krb5_kt_end_seq_get(kparam.context, keytab, &cursor);
if (code) {
debugs(11, 5,
- HERE << "Error while resolving memory credential cache : "
- << error_message(code));
+ HERE << "Error while ending keytab scan : " <<
+ error_message(code));
return (1);
}
- code = krb5_cc_initialize(kparam.context, kparam.cc, principal);
+#if USE_HEIMDAL_KRB5 || ( HAVE_KRB5_KT_FREE_ENTRY && HAVE_DECL_KRB5_KT_FREE_ENTRY)
+ code = krb5_kt_free_entry(kparam.context, &entry);
+#else
+ code = krb5_free_keytab_entry_contents(kparam.context, &entry);
+#endif
if (code) {
debugs(11, 5,
- HERE <<
- "Error while initializing memory credential cache : " <<
+ HERE << "Error while freeing keytab entry : " <<
error_message(code));
return (1);
}
- code = krb5_cc_store_cred(kparam.context, kparam.cc, creds);
+
+ } else {
+ principal_name = xstrdup(pn);
+ }
+
+ if (!principal) {
+ code =
+ krb5_parse_name(kparam.context, principal_name, &principal);
if (code) {
debugs(11, 5,
- HERE << "Error while storing credentials : " <<
- error_message(code));
+ HERE << "Error while parsing principal name " <<
+ principal_name << " : " << error_message(code));
return (1);
}
-
- if (!creds->times.starttime)
- creds->times.starttime = creds->times.authtime;
}
- return (0);
- }
- /*
- * peer_proxy_negotiate_auth gets a GSSAPI token for principal_name
- * and base64 encodes it.
- */
- char *peer_proxy_negotiate_auth(char *principal_name, char *proxy) {
- int rc = 0;
- OM_uint32 major_status, minor_status;
- gss_ctx_id_t gss_context = GSS_C_NO_CONTEXT;
- gss_name_t server_name = GSS_C_NO_NAME;
- gss_buffer_desc service = GSS_C_EMPTY_BUFFER;
- gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
- gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
- char *token = NULL;
-
- setbuf(stdout, NULL);
- setbuf(stdin, NULL);
-
- if (!proxy) {
- debugs(11, 5, HERE << "Error : No proxy server name");
- return NULL;
+ creds = (krb5_creds *) xmalloc(sizeof(*creds));
+ memset(creds, 0, sizeof(*creds));
+#if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
+ krb5_get_init_creds_opt_alloc(kparam.context, &options);
+#else
+ krb5_get_init_creds_opt_init(&options);
+#endif
+ code = krb5_string_to_deltat((char *) MAX_RENEW_TIME, &rlife);
+ if (code != 0 || rlife == 0) {
+ debugs(11, 5,
+ HERE << "Error bad lifetime value " << MAX_RENEW_TIME <<
+ " : " << error_message(code));
+ return (1);
}
-
- if (principal_name)
+#if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
+ krb5_get_init_creds_opt_set_renew_life(options, rlife);
+ code =
+ krb5_get_init_creds_keytab(kparam.context, creds, principal,
+ keytab, 0, NULL, options);
+#if HAVE_KRB5_GET_INIT_CREDS_FREE_CONTEXT
+ krb5_get_init_creds_opt_free(kparam.context, options);
+#else
+ krb5_get_init_creds_opt_free(options);
+#endif
+#else
+ krb5_get_init_creds_opt_set_renew_life(&options, rlife);
+ code =
+ krb5_get_init_creds_keytab(kparam.context, creds, principal,
+ keytab, 0, NULL, &options);
+#endif
+ if (code) {
debugs(11, 5,
- HERE << "Creating credential cache for " << principal_name);
- else
- debugs(11, 5, HERE << "Creating credential cache");
- rc = krb5_create_cache(NULL, principal_name);
- if (rc) {
- debugs(11, 5, HERE << "Error : Failed to create Kerberos cache");
- krb5_cleanup();
- return NULL;
+ HERE <<
+ "Error while initializing credentials from keytab : " <<
+ error_message(code));
+ return (1);
+ }
+#if !HAVE_KRB5_MEMORY_CACHE
+ mem_cache =
+ (char *) xmalloc(strlen("FILE:/tmp/peer_proxy_negotiate_auth_")
+ + 16);
+ if (!mem_cache) {
+ debugs(11, 5, "Error while allocating memory");
+ return(1);
}
+ snprintf(mem_cache,
+ strlen("FILE:/tmp/peer_proxy_negotiate_auth_") + 16,
+ "FILE:/tmp/peer_proxy_negotiate_auth_%d", (int) getpid());
+#else
+ mem_cache =
+ (char *) xmalloc(strlen("MEMORY:peer_proxy_negotiate_auth_") +
+ 16);
+ if (!mem_cache) {
+ debugs(11, 5, "Error while allocating memory");
+ return(1);
+ }
+ snprintf(mem_cache,
+ strlen("MEMORY:peer_proxy_negotiate_auth_") + 16,
+ "MEMORY:peer_proxy_negotiate_auth_%d", (int) getpid());
+#endif
- service.value = (void *) xmalloc(strlen("HTTP") + strlen(proxy) + 2);
- snprintf((char *) service.value, strlen("HTTP") + strlen(proxy) + 2,
- "%s@%s", "HTTP", proxy);
- service.length = strlen((char *) service.value);
-
- debugs(11, 5, HERE << "Import gss name");
- major_status = gss_import_name(&minor_status, &service,
- gss_nt_service_name, &server_name);
-
- if (check_gss_err(major_status, minor_status, "gss_import_name()"))
- goto cleanup;
-
- debugs(11, 5, HERE << "Initialize gss security context");
- major_status = gss_init_sec_context(&minor_status,
- GSS_C_NO_CREDENTIAL,
- &gss_context,
- server_name,
- gss_mech_spnego,
- 0,
- 0,
- GSS_C_NO_CHANNEL_BINDINGS,
- &input_token, NULL, &output_token, NULL, NULL);
-
- if (check_gss_err(major_status, minor_status, "gss_init_sec_context()"))
- goto cleanup;
-
- debugs(11, 5, HERE << "Got token with length " << output_token.length);
- if (output_token.length) {
-
- token =
- (char *) base64_encode_bin((const char *) output_token.value,
- output_token.length);
+ setenv("KRB5CCNAME", mem_cache, 1);
+ code = krb5_cc_resolve(kparam.context, mem_cache, &kparam.cc);
+ xfree(mem_cache);
+ if (code) {
+ debugs(11, 5,
+ HERE << "Error while resolving memory credential cache : "
+ << error_message(code));
+ return (1);
+ }
+ code = krb5_cc_initialize(kparam.context, kparam.cc, principal);
+ if (code) {
+ debugs(11, 5,
+ HERE <<
+ "Error while initializing memory credential cache : " <<
+ error_message(code));
+ return (1);
+ }
+ code = krb5_cc_store_cred(kparam.context, kparam.cc, creds);
+ if (code) {
+ debugs(11, 5,
+ HERE << "Error while storing credentials : " <<
+ error_message(code));
+ return (1);
}
-cleanup:
- gss_delete_sec_context(&minor_status, &gss_context, NULL);
- gss_release_buffer(&minor_status, &service);
- gss_release_buffer(&minor_status, &input_token);
- gss_release_buffer(&minor_status, &output_token);
- gss_release_name(&minor_status, &server_name);
+ if (!creds->times.starttime)
+ creds->times.starttime = creds->times.authtime;
+ }
+ return (0);
+}
+
+/*
+ * peer_proxy_negotiate_auth gets a GSSAPI token for principal_name
+ * and base64 encodes it.
+ */
+char *peer_proxy_negotiate_auth(char *principal_name, char *proxy) {
+ int rc = 0;
+ OM_uint32 major_status, minor_status;
+ gss_ctx_id_t gss_context = GSS_C_NO_CONTEXT;
+ gss_name_t server_name = GSS_C_NO_NAME;
+ gss_buffer_desc service = GSS_C_EMPTY_BUFFER;
+ gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
+ gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
+ char *token = NULL;
+
+ setbuf(stdout, NULL);
+ setbuf(stdin, NULL);
+
+ if (!proxy) {
+ debugs(11, 5, HERE << "Error : No proxy server name");
+ return NULL;
+ }
+
+ if (principal_name)
+ debugs(11, 5,
+ HERE << "Creating credential cache for " << principal_name);
+ else
+ debugs(11, 5, HERE << "Creating credential cache");
+ rc = krb5_create_cache(NULL, principal_name);
+ if (rc) {
+ debugs(11, 5, HERE << "Error : Failed to create Kerberos cache");
+ krb5_cleanup();
+ return NULL;
+ }
- return token;
+ service.value = (void *) xmalloc(strlen("HTTP") + strlen(proxy) + 2);
+ snprintf((char *) service.value, strlen("HTTP") + strlen(proxy) + 2,
+ "%s@%s", "HTTP", proxy);
+ service.length = strlen((char *) service.value);
+
+ debugs(11, 5, HERE << "Import gss name");
+ major_status = gss_import_name(&minor_status, &service,
+ gss_nt_service_name, &server_name);
+
+ if (check_gss_err(major_status, minor_status, "gss_import_name()"))
+ goto cleanup;
+
+ debugs(11, 5, HERE << "Initialize gss security context");
+ major_status = gss_init_sec_context(&minor_status,
+ GSS_C_NO_CREDENTIAL,
+ &gss_context,
+ server_name,
+ gss_mech_spnego,
+ 0,
+ 0,
+ GSS_C_NO_CHANNEL_BINDINGS,
+ &input_token, NULL, &output_token, NULL, NULL);
+
+ if (check_gss_err(major_status, minor_status, "gss_init_sec_context()"))
+ goto cleanup;
+
+ debugs(11, 5, HERE << "Got token with length " << output_token.length);
+ if (output_token.length) {
+
+ token =
+ (char *) base64_encode_bin((const char *) output_token.value,
+ output_token.length);
}
+cleanup:
+ gss_delete_sec_context(&minor_status, &gss_context, NULL);
+ gss_release_buffer(&minor_status, &service);
+ gss_release_buffer(&minor_status, &input_token);
+ gss_release_buffer(&minor_status, &output_token);
+ gss_release_name(&minor_status, &server_name);
+
+ return token;
+}
+
#ifdef __cplusplus
}
#endif
#endif /* HAVE_KRB5 && HAVE_GSSAPI */
+
#endif
#endif /* SQUID_PEER_PROXY_NEGOTIATE_AUTH_H_ */
+
}
ps_state::ps_state() : request (NULL),
- entry (NULL),
- always_direct(Config.accessList.AlwaysDirect?ACCESS_DUNNO:ACCESS_DENIED),
- never_direct(Config.accessList.NeverDirect?ACCESS_DUNNO:ACCESS_DENIED),
- direct(DIRECT_UNKNOWN),
- callback (NULL),
- callback_data (NULL),
- lastError(NULL),
- servers (NULL),
- first_parent_miss(),
- closest_parent_miss(),
- hit(NULL),
- hit_type(PEER_NONE),
- acl_checklist (NULL)
+ entry (NULL),
+ always_direct(Config.accessList.AlwaysDirect?ACCESS_DUNNO:ACCESS_DENIED),
+ never_direct(Config.accessList.NeverDirect?ACCESS_DUNNO:ACCESS_DENIED),
+ direct(DIRECT_UNKNOWN),
+ callback (NULL),
+ callback_data (NULL),
+ lastError(NULL),
+ servers (NULL),
+ first_parent_miss(),
+ closest_parent_miss(),
+ hit(NULL),
+ hit_type(PEER_NONE),
+ acl_checklist (NULL)
{
; // no local defaults.
}
}
ping_data::ping_data() :
- n_sent(0),
- n_recv(0),
- n_replies_expected(0),
- timeout(0),
- timedout(0),
- w_rtt(0),
- p_rtt(0)
+ n_sent(0),
+ n_recv(0),
+ n_replies_expected(0),
+ timeout(0),
+ timedout(0),
+ w_rtt(0),
+ p_rtt(0)
{
start.tv_sec = 0;
start.tv_usec = 0;
stop.tv_sec = 0;
stop.tv_usec = 0;
}
+
*/
K = n_sourcehash_peers;
- P_last = 0.0; /* Empty P_0 */
+ P_last = 0.0; /* Empty P_0 */
- Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
+ Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
- X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
+ X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
for (k = 1; k <= K; ++k) {
double Kk1 = (double) (K - k + 1);
sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);
}
}
+
CachePeer * peerSourceHashSelectParent(HttpRequest * request);
#endif /* SQUID_PEER_SOURCEHASH_H_ */
+
*/
K = n_userhash_peers;
- P_last = 0.0; /* Empty P_0 */
+ P_last = 0.0; /* Empty P_0 */
- Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
+ Xn = 1.0; /* Empty starting point of X_1 * X_2 * ... * X_{x-1} */
- X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
+ X_last = 0.0; /* Empty X_0, nullifies the first pow statement */
for (k = 1; k <= K; ++k) {
double Kk1 = (double) (K - k + 1);
}
#endif /* USE_AUTH */
+
CachePeer * peerUserHashSelectParent(HttpRequest * request);
#endif /* SQUID_PEER_USERHASH_H_ */
+
void reconfigure(int);
#endif /* SQUID_PROTOS_H */
+
CBDATA_CLASS_INIT(RedirectStateData);
RedirectStateData::RedirectStateData(const char *url) :
- data(NULL),
- orig_url(url),
- handler(NULL)
+ data(NULL),
+ orig_url(url),
+ handler(NULL)
{
}
delete storeIdExtrasFmt;
storeIdExtrasFmt = NULL;
}
+
void storeIdStart(ClientHttpRequest *, HLPCB *, void *);
#endif /* SQUID_REDIRECT_H_ */
+
/* DEBUG: section 22 Refresh Calculation */
#ifndef USE_POSIX_REGEX
-#define USE_POSIX_REGEX /* put before includes; always use POSIX */
+#define USE_POSIX_REGEX /* put before includes; always use POSIX */
#endif
#include "squid.h"
* PCT 20%
* MAX 3 days
*/
-#define REFRESH_DEFAULT_MIN (time_t)0
-#define REFRESH_DEFAULT_PCT 0.20
-#define REFRESH_DEFAULT_MAX (time_t)259200
+#define REFRESH_DEFAULT_MIN (time_t)0
+#define REFRESH_DEFAULT_PCT 0.20
+#define REFRESH_DEFAULT_MAX (time_t)259200
static const RefreshPattern *refreshUncompiledPattern(const char *);
static OBJH refreshStats;
refreshRegisterWithCacheManager();
}
+
const RefreshPattern *refreshLimits(const char *url);
#endif /* SQUID_REFRESH_H_ */
+
return (heap_key) e->lastref;
}
+
heap_key HeapKeyGen_StoreEntry_LRU(void *entry, double age);
#endif /* _SQUIDINC_STORE_HEAP_REPLACEMENT_H */
+
assert(!node->data);
if (EBIT_TEST(entry->flags, ENTRY_SPECIAL))
- return; /* We won't manage these.. they messes things up */
+ return; /* We won't manage these.. they messes things up */
node->data = heap_insert(h->theHeap, entry);
StoreEntry *entry;
if (heap_walk->current >= heap_nodes(h->theHeap))
- return NULL; /* done */
+ return NULL; /* done */
entry = (StoreEntry *) heap_peep(h->theHeap, heap_walk->current++);
try_again:
if (heap_empty(h->theHeap))
- return NULL; /* done */
+ return NULL; /* done */
age = heap_peepminkey(h->theHeap);
return policy;
}
+
void storeReplSetup(void);
#endif /* SQUID_REPL_MODULES_H_ */
+
if (comm_udp_sendto(icpOutgoingConn->fd, S, sndbuf, strlen(sndbuf) + 1) < 0)
debugs(27, DBG_IMPORTANT, "ERROR: Failed to announce to " << S << " from " << icpOutgoingConn->local << ": " << xstrerror());
}
+
void start_announce(void *unused);
#endif /* SQUID_SEND_ANNOUNCE_H_ */
+
};
Ftp::Server::Server(const MasterXaction::Pointer &xact):
- AsyncJob("Ftp::Server"),
- ConnStateData(xact),
- master(new MasterState),
- uri(),
- host(),
- gotEpsvAll(false),
- onDataAcceptCall(),
- dataListenConn(),
- dataConn(),
- uploadAvailSize(0),
- listener(),
- connector(),
- reader()
+ AsyncJob("Ftp::Server"),
+ ConnStateData(xact),
+ master(new MasterState),
+ uri(),
+ host(),
+ gotEpsvAll(false),
+ onDataAcceptCall(),
+ dataListenConn(),
+ dataConn(),
+ uploadAvailSize(0),
+ listener(),
+ connector(),
+ reader()
{
flags.readMore = false; // we need to announce ourselves first
*uploadBuf = 0;
typedef CommCbFunPtrCallT<CommAcceptCbPtrFun> AcceptCall;
RefCount<AcceptCall> subCall = commCbCall(5, 5, "Ftp::Server::AcceptCtrlConnection",
CommAcceptCbPtrFun(Ftp::Server::AcceptCtrlConnection,
- CommAcceptCbParams(NULL)));
+ CommAcceptCbParams(NULL)));
clientStartListeningOn(s, subCall, Ipc::fdnFtpSocket);
}
}
} // namespace Ftp
#endif /* SQUID_SERVERS_FTP_SERVER_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Http, Server);
Http::Server::Server(const MasterXaction::Pointer &xact, bool beHttpsServer):
- AsyncJob("Http::Server"),
- ConnStateData(xact),
- isHttpsServer(beHttpsServer)
+ AsyncJob("Http::Server"),
+ ConnStateData(xact),
+ isHttpsServer(beHttpsServer)
{
}
err_type errPage = ERR_INVALID_REQ;
switch (parser_->request_parse_status) {
case Http::scRequestHeaderFieldsTooLarge:
- // fall through to next case
+ // fall through to next case
case Http::scUriTooLong:
errPage = ERR_TOO_BIG;
break;
/* We currently only support 0.9, 1.0, 1.1 properly */
/* TODO: move HTTP-specific processing into servers/HttpServer and such */
if ( (parser_->messageProtocol().major == 0 && parser_->messageProtocol().minor != 9) ||
- (parser_->messageProtocol().major > 1) ) {
+ (parser_->messageProtocol().major > 1) ) {
clientStreamNode *node = context->getClientReplyContext();
debugs(33, 5, "Unsupported HTTP version discovered. :\n" << parser_->messageProtocol());
{
return new Http::Server(xact, true);
}
+
} // namespace Ftp
#endif /* SQUID_SERVERS_FORWARD_H */
+
Snmp::Forwarder::Forwarder(const Pdu& aPdu, const Session& aSession, int aFd,
const Ip::Address& anAddress):
- Ipc::Forwarder(new Request(KidIdentifier, 0, aPdu, aSession, aFd, anAddress), 2),
- fd(aFd)
+ Ipc::Forwarder(new Request(KidIdentifier, 0, aPdu, aSession, aFd, anAddress), 2),
+ fd(aFd)
{
debugs(49, 5, HERE << "FD " << aFd);
Must(fd >= 0);
response.pack(message);
Ipc::SendMessage(Ipc::Port::CoordinatorAddr(), message);
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_FORWARDER_H */
+
CBDATA_NAMESPACED_CLASS_INIT(Snmp, Inquirer);
Snmp::Inquirer::Inquirer(const Request& aRequest, const Ipc::StrandCoords& coords):
- Ipc::Inquirer(aRequest.clone(), coords, 2),
- aggrPdu(aRequest.pdu)
+ Ipc::Inquirer(aRequest.clone(), coords, 2),
+ aggrPdu(aRequest.pdu)
{
conn = new Comm::Connection;
conn->fd = aRequest.fd;
snmp_build(&req.session, &aggrPdu, buffer, &len);
comm_udp_sendto(conn->fd, req.address, buffer, len);
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_INQUIRER_H */
+
} // namespace Snmp
#endif /* SQUID_SNMPX_PDU_H */
+
Snmp::Request::Request(int aRequestorId, unsigned int aRequestId,
const Pdu& aPdu, const Session& aSession,
int aFd, const Ip::Address& anAddress):
- Ipc::Request(aRequestorId, aRequestId),
- pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
+ Ipc::Request(aRequestorId, aRequestId),
+ pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
{
}
Snmp::Request::Request(const Request& request):
- Ipc::Request(request.requestorId, request.requestId),
- pdu(request.pdu), session(request.session),
- fd(request.fd), address(request.address)
+ Ipc::Request(request.requestorId, request.requestId),
+ pdu(request.pdu), session(request.session),
+ fd(request.fd), address(request.address)
{
}
Snmp::Request::Request(const Ipc::TypedMsgHdr& msg):
- Ipc::Request(0, 0)
+ Ipc::Request(0, 0)
{
msg.checkType(Ipc::mtSnmpRequest);
msg.getPod(requestorId);
{
return new Request(*this);
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_REQUEST_H */
+
}
Snmp::Response::Response(unsigned int aRequestId):
- Ipc::Response(aRequestId), pdu()
+ Ipc::Response(aRequestId), pdu()
{
}
Snmp::Response::Response(const Response& response):
- Ipc::Response(response.requestId), pdu(response.pdu)
+ Ipc::Response(response.requestId), pdu(response.pdu)
{
}
Snmp::Response::Response(const Ipc::TypedMsgHdr& msg):
- Ipc::Response(0)
+ Ipc::Response(0)
{
msg.checkType(Ipc::mtSnmpResponse);
msg.getPod(requestId);
{
return new Response(*this);
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_RESPONSE_H */
+
msg.getPod(remote_port);
msg.getPod(local_port);
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_SESSION_H */
+
msg.getFixed(val.string, val_len);
}
}
+
} // namespace Snmp
#endif /* SQUID_SNMPX_VAR_H */
+
} // namespace Snmp
#endif /* SQUID_SNMPX_FORWARD_H */
+
switch (Var->name[LEN_SQ_PRF + 1]) {
- case PERF_PROTOSTAT_AGGR: /* cacheProtoAggregateStats */
+ case PERF_PROTOSTAT_AGGR: /* cacheProtoAggregateStats */
switch (Var->name[LEN_SQ_PRF + 2]) {
*ErrP = SNMP_ERR_NOSUCHNAME;
return NULL;
}
+
#endif /* SQUID_SNMP */
#endif /* SQUID_SNMP_AGENT_H_ */
+
}
ACLSNMPCommunityStrategy ACLSNMPCommunityStrategy::Instance_;
+
void oid2addr(oid *Dest, Ip::Address &addr, u_int code);
#endif /* SQUID_SNMP_CORE_H */
+
Ssl::Config::Config():
#if USE_SSL_CRTD
- ssl_crtd(NULL),
+ ssl_crtd(NULL),
#endif
- ssl_crt_validator(NULL)
+ ssl_crt_validator(NULL)
{
ssl_crt_validator_Children.concurrency = 1;
}
#endif
xfree(ssl_crt_validator);
}
+
} // namespace Ssl
#endif
+
SslErrors TheSslErrors;
static SslErrorEntry TheSslErrorArray[] = {
- {SQUID_X509_V_ERR_INFINITE_VALIDATION,
- "SQUID_X509_V_ERR_INFINITE_VALIDATION"},
- {SQUID_X509_V_ERR_CERT_CHANGE,
- "SQUID_X509_V_ERR_CERT_CHANGE"},
- {SQUID_ERR_SSL_HANDSHAKE,
- "SQUID_ERR_SSL_HANDSHAKE"},
- {SQUID_X509_V_ERR_DOMAIN_MISMATCH,
- "SQUID_X509_V_ERR_DOMAIN_MISMATCH"},
- {X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT,
- "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT"},
- {X509_V_ERR_UNABLE_TO_GET_CRL,
- "X509_V_ERR_UNABLE_TO_GET_CRL"},
- {X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE,
- "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE"},
- {X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE,
- "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE"},
- {X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY,
- "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY"},
- {X509_V_ERR_CERT_SIGNATURE_FAILURE,
- "X509_V_ERR_CERT_SIGNATURE_FAILURE"},
- {X509_V_ERR_CRL_SIGNATURE_FAILURE,
- "X509_V_ERR_CRL_SIGNATURE_FAILURE"},
- {X509_V_ERR_CERT_NOT_YET_VALID,
- "X509_V_ERR_CERT_NOT_YET_VALID"},
- {X509_V_ERR_CERT_HAS_EXPIRED,
- "X509_V_ERR_CERT_HAS_EXPIRED"},
- {X509_V_ERR_CRL_NOT_YET_VALID,
- "X509_V_ERR_CRL_NOT_YET_VALID"},
- {X509_V_ERR_CRL_HAS_EXPIRED,
- "X509_V_ERR_CRL_HAS_EXPIRED"},
- {X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD,
- "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD"},
- {X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD,
- "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD"},
- {X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD,
- "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD"},
- {X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD,
- "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD"},
- {X509_V_ERR_OUT_OF_MEM,
- "X509_V_ERR_OUT_OF_MEM"},
- {X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
- "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT"},
- {X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
- "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN"},
- {X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
- "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY"},
- {X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
- "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE"},
- {X509_V_ERR_CERT_CHAIN_TOO_LONG,
- "X509_V_ERR_CERT_CHAIN_TOO_LONG"},
- {X509_V_ERR_CERT_REVOKED,
- "X509_V_ERR_CERT_REVOKED"},
- {X509_V_ERR_INVALID_CA,
- "X509_V_ERR_INVALID_CA"},
- {X509_V_ERR_PATH_LENGTH_EXCEEDED,
- "X509_V_ERR_PATH_LENGTH_EXCEEDED"},
- {X509_V_ERR_INVALID_PURPOSE,
- "X509_V_ERR_INVALID_PURPOSE"},
- {X509_V_ERR_CERT_UNTRUSTED,
- "X509_V_ERR_CERT_UNTRUSTED"},
- {X509_V_ERR_CERT_REJECTED,
- "X509_V_ERR_CERT_REJECTED"},
- {X509_V_ERR_SUBJECT_ISSUER_MISMATCH,
- "X509_V_ERR_SUBJECT_ISSUER_MISMATCH"},
- {X509_V_ERR_AKID_SKID_MISMATCH,
- "X509_V_ERR_AKID_SKID_MISMATCH"},
- {X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH,
- "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH"},
- {X509_V_ERR_KEYUSAGE_NO_CERTSIGN,
- "X509_V_ERR_KEYUSAGE_NO_CERTSIGN"},
+ { SQUID_X509_V_ERR_INFINITE_VALIDATION,
+ "SQUID_X509_V_ERR_INFINITE_VALIDATION"
+ },
+ { SQUID_X509_V_ERR_CERT_CHANGE,
+ "SQUID_X509_V_ERR_CERT_CHANGE"
+ },
+ { SQUID_ERR_SSL_HANDSHAKE,
+ "SQUID_ERR_SSL_HANDSHAKE"
+ },
+ { SQUID_X509_V_ERR_DOMAIN_MISMATCH,
+ "SQUID_X509_V_ERR_DOMAIN_MISMATCH"
+ },
+ { X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT,
+ "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT"
+ },
+ { X509_V_ERR_UNABLE_TO_GET_CRL,
+ "X509_V_ERR_UNABLE_TO_GET_CRL"
+ },
+ { X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE,
+ "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE"
+ },
+ { X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE,
+ "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE"
+ },
+ { X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY,
+ "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY"
+ },
+ { X509_V_ERR_CERT_SIGNATURE_FAILURE,
+ "X509_V_ERR_CERT_SIGNATURE_FAILURE"
+ },
+ { X509_V_ERR_CRL_SIGNATURE_FAILURE,
+ "X509_V_ERR_CRL_SIGNATURE_FAILURE"
+ },
+ { X509_V_ERR_CERT_NOT_YET_VALID,
+ "X509_V_ERR_CERT_NOT_YET_VALID"
+ },
+ { X509_V_ERR_CERT_HAS_EXPIRED,
+ "X509_V_ERR_CERT_HAS_EXPIRED"
+ },
+ { X509_V_ERR_CRL_NOT_YET_VALID,
+ "X509_V_ERR_CRL_NOT_YET_VALID"
+ },
+ { X509_V_ERR_CRL_HAS_EXPIRED,
+ "X509_V_ERR_CRL_HAS_EXPIRED"
+ },
+ { X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD,
+ "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD"
+ },
+ { X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD,
+ "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD"
+ },
+ { X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD,
+ "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD"
+ },
+ { X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD,
+ "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD"
+ },
+ { X509_V_ERR_OUT_OF_MEM,
+ "X509_V_ERR_OUT_OF_MEM"
+ },
+ { X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
+ "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT"
+ },
+ { X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
+ "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN"
+ },
+ { X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
+ "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY"
+ },
+ { X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
+ "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE"
+ },
+ { X509_V_ERR_CERT_CHAIN_TOO_LONG,
+ "X509_V_ERR_CERT_CHAIN_TOO_LONG"
+ },
+ { X509_V_ERR_CERT_REVOKED,
+ "X509_V_ERR_CERT_REVOKED"
+ },
+ { X509_V_ERR_INVALID_CA,
+ "X509_V_ERR_INVALID_CA"
+ },
+ { X509_V_ERR_PATH_LENGTH_EXCEEDED,
+ "X509_V_ERR_PATH_LENGTH_EXCEEDED"
+ },
+ { X509_V_ERR_INVALID_PURPOSE,
+ "X509_V_ERR_INVALID_PURPOSE"
+ },
+ { X509_V_ERR_CERT_UNTRUSTED,
+ "X509_V_ERR_CERT_UNTRUSTED"
+ },
+ { X509_V_ERR_CERT_REJECTED,
+ "X509_V_ERR_CERT_REJECTED"
+ },
+ { X509_V_ERR_SUBJECT_ISSUER_MISMATCH,
+ "X509_V_ERR_SUBJECT_ISSUER_MISMATCH"
+ },
+ { X509_V_ERR_AKID_SKID_MISMATCH,
+ "X509_V_ERR_AKID_SKID_MISMATCH"
+ },
+ { X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH,
+ "X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH"
+ },
+ { X509_V_ERR_KEYUSAGE_NO_CERTSIGN,
+ "X509_V_ERR_KEYUSAGE_NO_CERTSIGN"
+ },
#if defined(X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER)
{
X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER, //33
"X509_V_ERR_CRL_PATH_VALIDATION_ERROR"
},
#endif
- {X509_V_ERR_APPLICATION_VERIFICATION,
- "X509_V_ERR_APPLICATION_VERIFICATION"},
+ { X509_V_ERR_APPLICATION_VERIFICATION,
+ "X509_V_ERR_APPLICATION_VERIFICATION"
+ },
{ SSL_ERROR_NONE, "SSL_ERROR_NONE"},
{SSL_ERROR_NONE, NULL}
};
static const Ssl::ssl_error_t notYetValid[] = {X509_V_ERR_CERT_NOT_YET_VALID, SSL_ERROR_NONE};
static const Ssl::ssl_error_t domainMismatch[] = {SQUID_X509_V_ERR_DOMAIN_MISMATCH, SSL_ERROR_NONE};
static const Ssl::ssl_error_t certUntrusted[] = {X509_V_ERR_INVALID_CA,
- X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
- X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT,
- X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
- X509_V_ERR_CERT_UNTRUSTED, SSL_ERROR_NONE
+ X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
+ X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
+ X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT,
+ X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
+ X509_V_ERR_CERT_UNTRUSTED, SSL_ERROR_NONE
};
static const Ssl::ssl_error_t certSelfSigned[] = {X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, SSL_ERROR_NONE};
lib_error_no = anErrDetail.lib_error_no;
}
+
}//namespace Ssl
#endif
+
debugs(83, 9, HERE << " Remain size: " << buf.contentSize() << " Content: " << buf.content());
return true;
}
+
void errorDetailClean();
} //namespace Ssl
#endif
+
const Comm::ConnectionPointer &aClientConn,
AsyncCall::Pointer &aCallback,
const time_t timeout):
- AsyncJob("Ssl::PeerConnector"),
- request(aRequest),
- serverConn(aServerConn),
- clientConn(aClientConn),
- callback(aCallback),
- negotiationTimeout(timeout),
- startTime(squid_curtime),
- splice(false)
+ AsyncJob("Ssl::PeerConnector"),
+ request(aRequest),
+ serverConn(aServerConn),
+ clientConn(aClientConn),
+ callback(aCallback),
+ negotiationTimeout(timeout),
+ startTime(squid_curtime),
+ splice(false)
{
// if this throws, the caller's cb dialer is not our CbDialer
Must(dynamic_cast<CbDialer*>(callback->getDialer()));
debugs(83,5, "Retry the fwdNegotiateSSL on FD " << serverConn->fd);
} else {
splice = true;
- // Ssl Negotiation stops here. Last SSL checks for valid certificates
+ // Ssl Negotiation stops here. Last SSL checks for valid certificates
// and if done, switch to tunnel mode
if (sslFinalized())
switchToTunnel(request.getRaw(), clientConn, serverConn);
{
return os << answer.conn << ", " << answer.error;
}
+
} // namespace Ssl
#endif /* SQUID_PEER_CONNECTOR_H */
+
#endif
#endif /* SQUID_SSLPROXYCERTS_H_ */
+
CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump);
Ssl::ServerBump::ServerBump(HttpRequest *fakeRequest, StoreEntry *e, Ssl::BumpMode md):
- request(fakeRequest),
- sslErrors(NULL),
- step(bumpStep1)
+ request(fakeRequest),
+ sslErrors(NULL),
+ step(bumpStep1)
{
debugs(33, 4, HERE << "will peek at " << request->GetHost() << ':' << request->port);
act.step1 = md;
} // namespace Ssl
#endif
+
}
return 0;
- /* we may also need to implement these:
- case BIO_CTRL_RESET:
- case BIO_C_FILE_SEEK:
- case BIO_C_FILE_TELL:
- case BIO_CTRL_INFO:
- case BIO_CTRL_GET_CLOSE:
- case BIO_CTRL_SET_CLOSE:
- case BIO_CTRL_PENDING:
- case BIO_CTRL_WPENDING:
- */
+ /* we may also need to implement these:
+ case BIO_CTRL_RESET:
+ case BIO_C_FILE_SEEK:
+ case BIO_C_FILE_TELL:
+ case BIO_CTRL_INFO:
+ case BIO_CTRL_GET_CLOSE:
+ case BIO_CTRL_SET_CLOSE:
+ case BIO_CTRL_PENDING:
+ case BIO_CTRL_WPENDING:
+ */
default:
return 0;
}
#endif /* USE_SSL */
+
} // namespace Ssl
#endif /* SQUID_SSL_BIO_H */
+
const std::string Ssl::CertValidationMsg::param_error_cert("error_cert_");
const std::string Ssl::CertValidationMsg::param_proto_version("proto_version");
const std::string Ssl::CertValidationMsg::param_cipher("cipher");
+
}//namespace Ssl
#endif // SQUID_SSL_CERT_VALIDATE_MESSAGE_H
+
#define HERE "(ssl_crtd) " << __FILE__ << ':' << __LINE__ << ": "
Ssl::Lock::Lock(std::string const &aFilename) :
- filename(aFilename),
+ filename(aFilename),
#if _SQUID_WINDOWS_
- hFile(INVALID_HANDLE_VALUE)
+ hFile(INVALID_HANDLE_VALUE)
#else
- fd(-1)
+ fd(-1)
#endif
{
}
}
Ssl::Locker::Locker(Lock &aLock, const char *aFileName, int aLineNo):
- weLocked(false), lock(aLock), fileName(aFileName), lineNo(aLineNo)
+ weLocked(false), lock(aLock), fileName(aFileName), lineNo(aLineNo)
{
if (!lock.locked()) {
lock.lock();
}
Ssl::CertificateDb::Row::Row()
- : width(cnlNumber)
+ : width(cnlNumber)
{
row = (char **)OPENSSL_malloc(sizeof(char *) * (width + 1));
for (size_t i = 0; i < width + 1; ++i)
Row row(rrow, cnlNumber); // row wrapper used to free the rrow
- const Columns db_indexes[]={cnlSerial, cnlName};
+ const Columns db_indexes[]= {cnlSerial, cnlName};
for (unsigned int i = 0; i < countof(db_indexes); ++i) {
void *data = NULL;
#if SQUID_SSLTXTDB_PSTRINGDATA
const std::string Ssl::CertificateDb::size_file("size");
Ssl::CertificateDb::CertificateDb(std::string const & aDb_path, size_t aMax_db_size, size_t aFs_block_size)
- : db_path(aDb_path),
- db_full(aDb_path + "/" + db_file),
- cert_full(aDb_path + "/" + cert_dir),
- size_full(aDb_path + "/" + size_file),
- db(NULL),
- max_db_size(aMax_db_size),
- fs_block_size((aFs_block_size ? aFs_block_size : 2048)),
- dbLock(db_full),
- enabled_disk_store(true) {
+ : db_path(aDb_path),
+ db_full(aDb_path + "/" + db_file),
+ cert_full(aDb_path + "/" + cert_dir),
+ size_full(aDb_path + "/" + size_file),
+ db(NULL),
+ max_db_size(aMax_db_size),
+ fs_block_size((aFs_block_size ? aFs_block_size : 2048)),
+ dbLock(db_full),
+ enabled_disk_store(true) {
if (db_path.empty() && !max_db_size)
enabled_disk_store = false;
else if ((db_path.empty() && max_db_size) || (!db_path.empty() && !max_db_size))
#endif
const std::string filename(cert_full + "/" + current_row[cnlSerial] + ".pem");
const size_t fSize = getFileSize(filename);
- dbSize += fSize;
+ dbSize += fSize;
}
writeSize(dbSize);
return dbSize;
bool Ssl::CertificateDb::IsEnabledDiskStore() const {
return enabled_disk_store;
}
+
} // namespace Ssl
#endif // SQUID_SSL_CERTIFICATE_DB_H
+
#endif
Ssl::CertificateStorageAction::CertificateStorageAction(const Mgr::Command::Pointer &aCmd)
- : Mgr::Action(aCmd)
+ : Mgr::Action(aCmd)
{}
Ssl::CertificateStorageAction::Pointer
///////////////////////////////////////////////////////
Ssl::GlobalContextStorage::GlobalContextStorage()
- : reconfiguring(true)
+ : reconfiguring(true)
{
RegisterAction("cached_ssl_cert", "Statistic of cached generated ssl certificates", &CertificateStorageAction::Create, 0, 1);
}
}
Ssl::GlobalContextStorage Ssl::TheGlobalContextStorage;
+
#endif // USE_OPENSSL
#endif // SQUID_SSL_CONTEXT_STORAGE_H
+
#include <stdexcept>
Ssl::CrtdMessage::CrtdMessage(MessageKind kind)
- : body_size(0), state(kind == REPLY ? BEFORE_LENGTH: BEFORE_CODE)
+ : body_size(0), state(kind == REPLY ? BEFORE_LENGTH: BEFORE_CODE)
{}
Ssl::CrtdMessage::ParseResult Ssl::CrtdMessage::parse(const char * buffer, size_t len)
const std::string Ssl::CrtdMessage::param_SetCommonName(Ssl::CertAdaptAlgorithmStr[algSetCommonName]);
const std::string Ssl::CrtdMessage::param_Sign("Sign");
const std::string Ssl::CrtdMessage::param_SignHash("SignHash");
+
} //namespace Ssl
#endif // SQUID_SSL_CRTD_MESSAGE_H
+
};
Ssl::CertificateProperties::CertificateProperties():
- setValidAfter(false),
- setValidBefore(false),
- setCommonName(false),
- signAlgorithm(Ssl::algSignEnd),
- signHash(NULL)
+ setValidAfter(false),
+ setValidBefore(false),
+ setCommonName(false),
+ signAlgorithm(Ssl::algSignEnd),
+ signHash(NULL)
{}
std::string & Ssl::CertificateProperties::dbKey() const
assert(method && method->it);
unsigned char *ext_der = NULL;
int ext_len = ASN1_item_i2d((ASN1_VALUE *)keyusage,
- &ext_der,
+ &ext_der,
(const ASN1_ITEM *)ASN1_ITEM_ptr(method->it));
ASN1_OCTET_STRING *ext_oct = M_ASN1_OCTET_STRING_new();
} // namespace Ssl
#endif // SQUID_SSL_GADGETS_H
+
} //namespace Ssl
#endif // SQUID_SSL_HELPER_H
+
void Ssl::Helper::Init() STUB
void Ssl::Helper::Shutdown() STUB
void Ssl::Helper::sslSubmit(Ssl::CrtdMessage const & message, HLPCB * callback, void *data) STUB
+
value = strtol(option + 2, NULL, 16);
} else {
fatalf("Unknown SSL option '%s'", option);
- value = 0; /* Keep GCC happy */
+ value = 0; /* Keep GCC happy */
}
switch (mode) {
}
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_NO_DEFAULT_CA (1<<0)
+#define SSL_FLAG_NO_DEFAULT_CA (1<<0)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_DELAYED_AUTH (1<<1)
+#define SSL_FLAG_DELAYED_AUTH (1<<1)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_DONT_VERIFY_PEER (1<<2)
+#define SSL_FLAG_DONT_VERIFY_PEER (1<<2)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_DONT_VERIFY_DOMAIN (1<<3)
+#define SSL_FLAG_DONT_VERIFY_DOMAIN (1<<3)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_NO_SESSION_REUSE (1<<4)
+#define SSL_FLAG_NO_SESSION_REUSE (1<<4)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_VERIFY_CRL (1<<5)
+#define SSL_FLAG_VERIFY_CRL (1<<5)
/// \ingroup ServerProtocolSSLInternal
-#define SSL_FLAG_VERIFY_CRL_ALL (1<<6)
+#define SSL_FLAG_VERIFY_CRL_ALL (1<<6)
/// \ingroup ServerProtocolSSLInternal
long
}
#endif /* USE_OPENSSL */
+
#endif /* _SQUID_WINDOWS_ */
#endif /* SQUID_SSL_SUPPORT_H */
+
C->comm_udp_incoming.enumInit(INCOMING_UDP_MAX);
C->comm_dns_incoming.enumInit(INCOMING_DNS_MAX);
C->comm_tcp_incoming.enumInit(INCOMING_TCP_MAX);
- C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
+ C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
}
/* add special cases here as they arrive */
#define GRAPH_PER_MIN(Y) \
for (i=0;i<(N_COUNT_HIST-2);++i) { \
- dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \
- if (dt <= 0.0) \
- break; \
- storeAppendPrintf(e, "%lu,%0.2f:", \
- CountHist[i].timestamp.tv_sec, \
- ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \
+ dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \
+ if (dt <= 0.0) \
+ break; \
+ storeAppendPrintf(e, "%lu,%0.2f:", \
+ CountHist[i].timestamp.tv_sec, \
+ ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \
}
#define GRAPH_PER_HOUR(Y) \
for (i=0;i<(N_COUNT_HOUR_HIST-2);++i) { \
- dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \
- if (dt <= 0.0) \
- break; \
- storeAppendPrintf(e, "%lu,%0.2f:", \
- CountHourHist[i].timestamp.tv_sec, \
- ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \
+ dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \
+ if (dt <= 0.0) \
+ break; \
+ storeAppendPrintf(e, "%lu,%0.2f:", \
+ CountHourHist[i].timestamp.tv_sec, \
+ ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \
}
#define GRAPH_TITLE(X,Y) storeAppendPrintf(e,"%s\t%s\t",X,Y);
{
return memPoolsTotalAllocated();
}
+
StatCounters *snmpStatGet(int);
#endif /* SQUID_STAT_H_ */
+
};
#endif /* SQUID_STMEM_H */
+
}
StoreEntry::StoreEntry() :
- mem_obj(NULL),
- timestamp(-1),
- lastref(-1),
- expires(-1),
- lastmod(-1),
- swap_file_sz(0),
- refcount(0),
- flags(0),
- swap_filen(-1),
- swap_dirn(-1),
- mem_status(NOT_IN_MEMORY),
- ping_status(PING_NONE),
- store_status(STORE_PENDING),
- swap_status(SWAPOUT_NONE),
- lock_count(0)
+ mem_obj(NULL),
+ timestamp(-1),
+ lastref(-1),
+ expires(-1),
+ lastmod(-1),
+ swap_file_sz(0),
+ refcount(0),
+ flags(0),
+ swap_filen(-1),
+ swap_dirn(-1),
+ mem_status(NOT_IN_MEMORY),
+ ping_status(PING_NONE),
+ store_status(STORE_PENDING),
+ swap_status(SWAPOUT_NONE),
+ lock_count(0)
{
debugs(20, 5, "StoreEntry constructed, this=" << this);
}
{
return NULL;
}
+
/*
* NOTE: 'Header' refers to the swapfile metadata header.
- * 'OBJHeader' refers to the object header, with cannonical
- * processed object headers (which may derive from FTP/HTTP etc
- * upstream protocols
+ * 'OBJHeader' refers to the object header, with cannonical
+ * processed object headers (which may derive from FTP/HTTP etc
+ * upstream protocols
* 'Body' refers to the swapfile body, which is the full
* HTTP reply (including HTTP headers and body).
*/
store_client::store_client(StoreEntry *e) : entry (e)
#if USE_DELAY_POOLS
- , delayId()
+ , delayId()
#endif
- , type (e->storeClientType())
- , object_ok(true)
+ , type (e->storeClientType())
+ , object_ok(true)
{
cmp_offset = 0;
flags.disk_io_pending = false;
delayId = delay_id;
}
#endif
+
public:
StoreDigestCBlock cblock;
- int rebuild_lock; /* bucket number */
- StoreEntry * rewrite_lock; /* points to store entry with the digest */
+ int rebuild_lock; /* bucket number */
+ StoreEntry * rewrite_lock; /* points to store entry with the digest */
StoreSearchPointer theSearch;
int rewrite_offset;
int rebuild_count;
};
typedef struct {
- int del_count; /* #store entries deleted from store_digest */
- int del_lost_count; /* #store entries not found in store_digest on delete */
- int add_count; /* #store entries accepted to store_digest */
- int add_coll_count; /* #accepted entries that collided with existing ones */
- int rej_count; /* #store entries not accepted to store_digest */
- int rej_coll_count; /* #not accepted entries that collided with existing ones */
+ int del_count; /* #store entries deleted from store_digest */
+ int del_lost_count; /* #store entries not found in store_digest on delete */
+ int add_count; /* #store entries accepted to store_digest */
+ int add_coll_count; /* #accepted entries that collided with existing ones */
+ int rej_count; /* #store entries not accepted to store_digest */
+ int rej_coll_count; /* #not accepted entries that collided with existing ones */
} StoreDigestStats;
/* local vars */
/* resize or clear */
if (!storeDigestResize())
- cacheDigestClear(store_digest); /* not clean()! */
+ cacheDigestClear(store_digest); /* not clean()! */
memset(&sd_stats, 0, sizeof(sd_stats));
}
#endif /* USE_CACHE_DIGESTS */
+
void storeDigestReport(StoreEntry *);
#endif /* SQUID_STORE_DIGEST_H_ */
+
int StoreController::store_dirs_rebuilding = 1;
StoreController::StoreController() : swapDir (new StoreHashIndex())
- , memStore(NULL), transients(NULL)
+ , memStore(NULL), transients(NULL)
{}
StoreController::~StoreController()
CBDATA_CLASS_INIT(StoreSearchHashIndex);
StoreSearchHashIndex::StoreSearchHashIndex(RefCount<StoreHashIndex> aSwapDir) :
- sd(aSwapDir),
- callback(NULL),
- cbdata(NULL),
- _done(false),
- bucket(0)
+ sd(aSwapDir),
+ callback(NULL),
+ cbdata(NULL),
+ _done(false),
+ bucket(0)
{}
/* do not link
++bucket;
debugs(47,3, "got entries: " << entries.size());
}
+
{
sio->write(buf,size,offset,free_func);
}
+
{
memset(null_key, '\0', SQUID_MD5_DIGEST_LENGTH);
}
+
extern HASHCMP storeKeyHashCmp;
#endif /* SQUID_STORE_KEY_MD5_H_ */
+
storeLogTagsCounts[tag]);
}
}
+
void storeLogOpen(void);
#endif /* SQUID_STORE_LOG_H_ */
+
} else {
/* URL already exists, this swapfile not being used */
/* junk old, load new */
- e->release(); /* release old entry */
+ e->release(); /* release old entry */
++stats.dupcount;
}
}
return true;
}
+
bool storeRebuildKeepEntry(const StoreEntry &e, const cache_key *key, StoreRebuildData &counts);
#endif /* SQUID_STORE_REBUILD_H_ */
+
e->swap_filen = sc->swapin_sio->swap_filen;
e->swap_dirn = sc->swapin_sio->swap_dirn;
}
+
void storeSwapInStart(store_client *);
#endif /* SQUID_STORE_SWAPIN_H_ */
+
tlv *
storeSwapMetaBuild(StoreEntry * e)
{
- tlv *TLV = NULL; /* we'll return this */
+ tlv *TLV = NULL; /* we'll return this */
tlv **T = &TLV;
const char *url;
const char *vary;
int j = 0;
char *buf;
assert(length != NULL);
- ++buflen; /* STORE_META_OK */
- buflen += sizeof(int); /* size of header to follow */
+ ++buflen; /* STORE_META_OK */
+ buflen += sizeof(int); /* size of header to follow */
for (t = tlv_list; t; t = t->next)
buflen += sizeof(char) + sizeof(int) + t->length;
*length = buflen;
return buf;
}
+
swapOutDecision(MemObject::SwapOut::swPossible);
return true;
}
+
extern const char *swap_log_op_str[];
#endif /* _SQUID_SWAP_LOG_OP_H */
+
CacheDigest *digest;
Cache *peer;
CacheQueryStats qstats;
- int count; /* #currently cached entries */
- int req_count; /* #requests to this cache */
- int bad_add_count; /* #duplicate adds */
- int bad_del_count; /* #dels with no prior add */
+ int count; /* #currently cached entries */
+ int req_count; /* #requests to this cache */
+ int bad_add_count; /* #duplicate adds */
+ int bad_del_count; /* #dels with no prior add */
};
typedef struct _CacheEntry {
typedef struct {
cache_key key[SQUID_MD5_DIGEST_LENGTH];
time_t timestamp;
- short int use_icp; /* true/false */
+ short int use_icp; /* true/false */
} RawAccessLogEntry;
typedef enum {
struct _FileIterator {
const char *fname;
FILE *file;
- time_t inner_time; /* timestamp of the current entry */
- time_t time_offset; /* to adjust time set by reader */
- int line_count; /* number of lines scanned */
- int bad_line_count; /* number of parsing errors */
- int time_warp_count; /* number of out-of-order entries in the file */
- FI_READER reader; /* reads next entry and updates inner_time */
- void *entry; /* buffer for the current entry, freed with xfree() */
+ time_t inner_time; /* timestamp of the current entry */
+ time_t time_offset; /* to adjust time set by reader */
+ int line_count; /* number of lines scanned */
+ int bad_line_count; /* number of parsing errors */
+ int time_warp_count; /* number of out-of-order entries in the file */
+ FI_READER reader; /* reads next entry and updates inner_time */
+ void *entry; /* buffer for the current entry, freed with xfree() */
};
/* globals */
-static time_t cur_time = -1; /* timestamp of the current log entry */
+static time_t cur_time = -1; /* timestamp of the current log entry */
/* copied from url.c */
static HttpRequestMethod
entry = (RawAccessLogEntry*)fi->entry;
if (!fgets(buf, sizeof(buf), fi->file))
- return frEof; /* eof */
+ return frEof; /* eof */
entry->timestamp = fi->inner_time = (time_t) atoi(buf);
/* digest peer cache content */
cacheResetDigest(them);
- us->digest = cacheDigestClone(them->digest); /* @netw@ */
+ us->digest = cacheDigestClone(them->digest); /* @netw@ */
/* shift the time in access log to match ready_time */
fileIteratorSetCurTime(fis[0], ready_time);
cacheDestroy(us);
return 0;
}
+
*/
SBufFindTest::SBufFindTest():
- caseLimit(std::numeric_limits<int>::max()),
- errorLimit(std::numeric_limits<int>::max()),
- randomSeed(1),
- hushSimilar(true),
- maxHayLength(40),
- thePos(0),
- thePlacement(placeEof),
- theStringPos(0),
- theBareNeedlePos(0),
- theFindString(0),
- theFindSBuf(0),
- theReportFunc(),
- theReportNeedle(),
- theReportPos(),
- theReportQuote('"'),
- caseCount(0),
- errorCount(0),
- reportCount(0)
+ caseLimit(std::numeric_limits<int>::max()),
+ errorLimit(std::numeric_limits<int>::max()),
+ randomSeed(1),
+ hushSimilar(true),
+ maxHayLength(40),
+ thePos(0),
+ thePlacement(placeEof),
+ theStringPos(0),
+ theBareNeedlePos(0),
+ theFindString(0),
+ theFindSBuf(0),
+ theReportFunc(),
+ theReportNeedle(),
+ theReportPos(),
+ theReportQuote('"'),
+ caseCount(0),
+ errorCount(0),
+ reportCount(0)
{
}
break;
}
}
+
typedef SBufFindTest::Placement Placement;
#endif
+
#define STUB_RETSTATREF(x) { stub_fatal(STUB_API " required"); static x v; return v; }
#endif /* STUB */
+
typedef RefCount<TestSwapDir> TestSwapDirPointer;
#endif /* TEST_TESTSWAPDIR */
+
#include "tests/STUB.h"
void CollapsedForwarding::Broadcast(StoreEntry const&) STUB
+
void CommIO::NotifyIOClose() STUB
void CommIO::NULLFDHandler(int, void *) STUB
void CommIO::FlushPipe() STUB
+
void DelayId::delayRead(DeferredRead const&) STUB_NOP
#endif /* USE_DELAY_POOLS */
+
DiskIOModule *DiskIOModule::Find(char const *) STUB_RETVAL(NULL)
DiskIOModule *DiskIOModule::FindDefault() STUB_RETVAL(NULL)
std::vector<DiskIOModule*> const &DiskIOModule::Modules() STUB_RETSTATREF(std::vector<DiskIOModule*>)
+
EventLoop *EventLoop::Running = NULL;
EventLoop::EventLoop(): errcount(0), last_loop(false), timeService(NULL),
- primaryEngine(NULL), loop_delay(0), error(false), runOnceResult(false)
- STUB_NOP
+ primaryEngine(NULL), loop_delay(0), error(false), runOnceResult(false)
+ STUB_NOP
+
+ void EventLoop::registerEngine(AsyncEngine *engine) STUB
- void EventLoop::registerEngine(AsyncEngine *engine) STUB
#include <cstring>
Helper::ChildConfig::ChildConfig():
- n_max(0),
- n_startup(0),
- n_idle(1),
- concurrency(0),
- n_running(0),
- n_active(0),
- queue_size(0),
- defaultQueueSize(true)
+ n_max(0),
+ n_startup(0),
+ n_idle(1),
+ concurrency(0),
+ n_running(0),
+ n_active(0),
+ queue_size(0),
+ defaultQueueSize(true)
{}
Helper::ChildConfig::ChildConfig(const unsigned int m):
- n_max(m),
- n_startup(0),
- n_idle(1),
- concurrency(0),
- n_running(0),
- n_active(0),
- queue_size(2 * m),
- defaultQueueSize(true)
+ n_max(m),
+ n_startup(0),
+ n_idle(1),
+ concurrency(0),
+ n_running(0),
+ n_active(0),
+ queue_size(2 * m),
+ defaultQueueSize(true)
{}
int
}
void Helper::ChildConfig::parseConfig() STUB
+
#include "tests/STUB.h"
HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0),
- expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0),
- protoPrefix("HTTP/"), do_clean(false), bodySizeMax(-2)
- STUB_NOP
- HttpReply::~HttpReply() STUB
- void HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB
- void HttpReply::packHeadersInto(Packer * p) const STUB
- void HttpReply::reset() STUB
- void httpBodyPackInto(const HttpBody * body, Packer * p) STUB
- bool HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
- int HttpReply::httpMsgParseError() STUB_RETVAL(0)
- bool HttpReply::expectingBody(const HttpRequestMethod&, int64_t&) const STUB_RETVAL(false)
- bool HttpReply::parseFirstLine(const char *start, const char *end) STUB_RETVAL(false)
- void HttpReply::hdrCacheInit() STUB
- HttpReply * HttpReply::clone() const STUB_RETVAL(NULL)
- bool HttpReply::inheritProperties(const HttpMsg *aMsg) STUB_RETVAL(false)
- int64_t HttpReply::bodySize(const HttpRequestMethod&) const STUB_RETVAL(0)
+ expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0),
+ protoPrefix("HTTP/"), do_clean(false), bodySizeMax(-2)
+ STUB_NOP
+ HttpReply::~HttpReply() STUB
+ void HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB
+ void HttpReply::packHeadersInto(Packer * p) const STUB
+ void HttpReply::reset() STUB
+ void httpBodyPackInto(const HttpBody * body, Packer * p) STUB
+ bool HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
+ int HttpReply::httpMsgParseError() STUB_RETVAL(0)
+ bool HttpReply::expectingBody(const HttpRequestMethod&, int64_t&) const STUB_RETVAL(false)
+ bool HttpReply::parseFirstLine(const char *start, const char *end) STUB_RETVAL(false)
+ void HttpReply::hdrCacheInit() STUB
+ HttpReply * HttpReply::clone() const STUB_RETVAL(NULL)
+ bool HttpReply::inheritProperties(const HttpMsg *aMsg) STUB_RETVAL(false)
+ int64_t HttpReply::bodySize(const HttpRequestMethod&) const STUB_RETVAL(0)
+
#include "tests/STUB.h"
HttpRequest::HttpRequest() : HttpMsg(hoRequest) STUB
- HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) STUB
- HttpRequest::~HttpRequest() STUB
- void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const STUB
- bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
- void HttpRequest::hdrCacheInit() STUB
- void HttpRequest::reset() STUB
- bool HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t&) const STUB_RETVAL(false)
- void HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) STUB
- bool HttpRequest::parseFirstLine(const char *start, const char *end) STUB_RETVAL(false)
- HttpRequest * HttpRequest::clone() const STUB_RETVAL(NULL)
- bool HttpRequest::inheritProperties(const HttpMsg *aMsg) STUB_RETVAL(false)
- int64_t HttpRequest::getRangeOffsetLimit() STUB_RETVAL(0)
- const char *HttpRequest::storeId() STUB_RETVAL(".")
+ HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) STUB
+ HttpRequest::~HttpRequest() STUB
+ void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const STUB
+ bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
+ void HttpRequest::hdrCacheInit() STUB
+ void HttpRequest::reset() STUB
+ bool HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t&) const STUB_RETVAL(false)
+ void HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) STUB
+ bool HttpRequest::parseFirstLine(const char *start, const char *end) STUB_RETVAL(false)
+ HttpRequest * HttpRequest::clone() const STUB_RETVAL(NULL)
+ bool HttpRequest::inheritProperties(const HttpMsg *aMsg) STUB_RETVAL(false)
+ int64_t HttpRequest::getRangeOffsetLimit() STUB_RETVAL(0)
+ const char *HttpRequest::storeId() STUB_RETVAL(".")
+
void memBufReport(MemBuf * mb) STUB
void packerToMemInit(Packer * p, MemBuf * mb) STUB
+
void MemObject::trimUnSwappable() STUB
int64_t MemObject::policyLowestOffsetToKeep(bool swap) const STUB_RETVAL(-1)
MemObject::MemObject() :
- inmem_lo(0),
- nclients(0),
- request(NULL),
- ping_reply_callback(NULL),
- ircb_data(NULL),
- id(0),
- object_sz(-1),
- swap_hdr_sz(0),
- vary_headers(NULL),
- _reply(NULL)
+ inmem_lo(0),
+ nclients(0),
+ request(NULL),
+ ping_reply_callback(NULL),
+ ircb_data(NULL),
+ id(0),
+ object_sz(-1),
+ swap_hdr_sz(0),
+ vary_headers(NULL),
+ _reply(NULL)
{
memset(&clients, 0, sizeof(clients));
memset(&start_ping, 0, sizeof(start_ping));
void MemObject::markEndOfReplyHeaders() STUB
size_t MemObject::inUseCount() STUB_RETVAL(0)
int64_t MemObject::availableForSwapOut() const STUB_RETVAL(0)
+
void MemStore::markForUnlink(StoreEntry&) STUB
bool MemStore::anchorCollapsed(StoreEntry&, bool&) STUB_RETVAL(false)
bool MemStore::updateCollapsed(StoreEntry&) STUB_RETVAL(false)
+
String Ipc::Port::MakeAddr(char const*, int) STUB_RETVAL("")
String Ipc::Port::CoordinatorAddr() STUB_RETVAL("")
+
void SBuf::toLower() STUB
void SBuf::toUpper() STUB
String SBuf::toString() const STUB_RETVAL(String(""))
+
const StatHist * collectSBufDestructTimeStats() STUB_RETVAL(NULL)
void recordMemBlobSizeAtDestruct(SBuf::size_type) {}
const StatHist * collectMemBlobDestructTimeStats() STUB_RETVAL(NULL)
+
#include "tests/STUB.h"
void Ipc::SendMessage(const String& toAddress, const TypedMsgHdr& message) STUB
+
HierarchyLogEntry::HierarchyLogEntry() STUB
ping_data::ping_data() :
- n_sent(0),
- n_recv(0),
- n_replies_expected(0),
- timeout(0),
- timedout(0),
- w_rtt(0),
- p_rtt(0)
+ n_sent(0),
+ n_recv(0),
+ n_replies_expected(0),
+ timeout(0),
+ timedout(0),
+ w_rtt(0),
+ p_rtt(0)
{
start.tv_sec = 0;
start.tv_usec = 0;
stop.tv_sec = 0;
stop.tv_usec = 0;
}
+
/* DEBUG: section 28 Access Control */
#include "squid.h"
+
void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head) STUB
void dump_acl_list(StoreEntry*, ACLList*) STUB
YesNoNone::operator void*() const { STUB_NOP; return NULL; }
+
void Mgr::RegisterAction(char const *, char const *, Mgr::ClassActionCreationHandler *, int, int) {}
Mgr::Action::Pointer CacheManager::createRequestedAction(const Mgr::ActionParams &) STUB_RETVAL(NULL)
+
int cbdataReferenceValid(const void *p) STUB_RETVAL(0)
cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func) STUB_RETVAL(CBDATA_UNKNOWN)
+
#endif
void clientOpenListenSockets(void) STUB
void clientHttpConnectionsClose(void) STUB
+
void clientOpenListenSockets(void) STUB
void clientHttpConnectionsClose(void) STUB
void httpRequestFree(void *) STUB
+
#if !_USE_INLINE_
#include "client_side_request.cci"
#endif
+
void commStartHalfClosedMonitor(int fd) STUB
bool commHasHalfClosedMonitor(int fd) STUB_RETVAL(false)
int CommSelectEngine::checkEvents(int timeout) STUB_RETVAL(0)
+
if (CurrentDebug) {
*CurrentDebug << "assertion failed: " << file << ":" << line <<
- ": \"" << msg << "\"";
+ ": \"" << msg << "\"";
}
abort();
}
return os;
}
+
bool TemplateFile::loadDefault() STUB_RETVAL(false)
TemplateFile::TemplateFile(char const*, err_type) STUB
bool TemplateFile::loadFor(const HttpRequest *) STUB_RETVAL(false)
+
void EventScheduler::schedule(const char *name, EVH * func, void *arg, double when, int weight, bool cbdata) STUB
int EventScheduler::checkEvents(int timeout) STUB_RETVAL(-1)
EventScheduler *EventScheduler::GetInstance() STUB_RETVAL(NULL)
+
ExternalACLLookup * ExternalACLLookup::Instance() STUB_RETVAL(NULL)
void ExternalACLLookup::checkForAsync(ACLChecklist *) const STUB
void ExternalACLLookup::LookupDone(void *, const ExternalACLEntryPointer &) STUB
+
void fatalf(const char *fmt,...) STUB
void fatalvf(const char *fmt, va_list args) STUB
void fatal_dump(const char *message) STUB
+
void fd_bytes(int fd, int len, unsigned int type) STUB
void fd_note(int fd, const char *s) STUB
void fdAdjustReserved() STUB
+
helper_stateful_server *helperStatefulDefer(statefulhelper * hlp) STUB_RETVAL(NULL)
void helperStatefulReleaseServer(helper_stateful_server * srv) STUB
CBDATA_CLASS_INIT(statefulhelper);
+
#include "tests/STUB.h"
const char * httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) STUB_RETVAL(NULL)
+
void icpConnectionClose(void) STUB
int icpSetCacheKey(const cache_key * key) STUB_RETVAL(0)
const cache_key *icpGetCacheKey(const char *url, int reqnum) STUB_RETVAL(NULL)
+
#include "tests/STUB.h"
char * internalLocalUri(const char *dir, const char *name) STUB_RETVAL(NULL)
+
#include "tests/STUB.h"
pid_t ipcCreate(int, const char *, const char *const [], const char *, Ip::Address &, int *, int *, void **) STUB_RETVAL(-1)
+
{
Ipc::Forwarder foo(NULL,1.0);
}
+
void Ipc::TypedMsgHdr::putFixed(void const*, size_t) STUB
void Ipc::TypedMsgHdr::getString(String&) const STUB
void Ipc::TypedMsgHdr::putString(String const&) STUB
+
ipcache_addrs *ipcacheCheckNumeric(const char *name) STUB_RETVAL(NULL)
void ipcache_restart(void) STUB
int ipcacheAddEntryFromHosts(const char *name, const char *ipaddr) STUB_RETVAL(-1)
+
void Auth::Init() STUB_NOP
#endif /* USE_AUTH */
+
int ACLProxyAuth::matchProxyAuth(ACLChecklist *) STUB_RETVAL(0)
#endif /* USE_AUTH */
+
void Comm::ConnOpener::start() STUB
void Comm::ConnOpener::swanSong() STUB
Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &, AsyncCall::Pointer &, time_t) : AsyncJob("STUB Comm::ConnOpener") STUB
- Comm::ConnOpener::~ConnOpener() STUB
- void Comm::ConnOpener::setHost(const char *) STUB
- const char * Comm::ConnOpener::getHost() const STUB_RETVAL(NULL)
+ Comm::ConnOpener::~ConnOpener() STUB
+ void Comm::ConnOpener::setHost(const char *) STUB
+ const char * Comm::ConnOpener::getHost() const STUB_RETVAL(NULL)
#include "comm/forward.h"
- bool Comm::IsConnOpen(const Comm::ConnectionPointer &) STUB_RETVAL(false)
+ bool Comm::IsConnOpen(const Comm::ConnectionPointer &) STUB_RETVAL(false)
#include "comm/IoCallback.h"
- void Comm::IoCallback::setCallback(iocb_type, AsyncCall::Pointer &, char *, FREE *, int) STUB
- void Comm::IoCallback::selectOrQueueWrite() STUB
- void Comm::IoCallback::cancel(const char *reason) STUB
- void Comm::IoCallback::finish(Comm::Flag code, int xerrn) STUB
- Comm::CbEntry *Comm::iocb_table = NULL;
+ void Comm::IoCallback::setCallback(iocb_type, AsyncCall::Pointer &, char *, FREE *, int) STUB
+ void Comm::IoCallback::selectOrQueueWrite() STUB
+ void Comm::IoCallback::cancel(const char *reason) STUB
+ void Comm::IoCallback::finish(Comm::Flag code, int xerrn) STUB
+ Comm::CbEntry *Comm::iocb_table = NULL;
void Comm::CallbackTableInit() STUB
void Comm::CallbackTableDestruct() STUB
void Comm::Write(const Comm::ConnectionPointer &conn, MemBuf *mb, AsyncCall::Pointer &callback) STUB
void Comm::WriteCancel(const Comm::ConnectionPointer &conn, const char *reason) STUB
/*PF*/ void Comm::HandleWrite(int, void*) STUB
+
bool Eui::Eui64::lookupNdp(const Ip::Address &c) STUB_RETVAL(false)
bool Eui::Eui64::lookupSlaac(const Ip::Address &c) STUB_RETVAL(false)
#endif
+
bool Format::Format::parse(char const*) STUB_RETVAL(false)
Format::Format::Format(char const*) STUB
Format::Format::~Format() STUB
+
void netdbExchangeUpdatePeer(Ip::Address &, CachePeer *, double, double) STUB
CachePeer *netdbClosestParent(HttpRequest *) STUB_RETVAL(NULL)
void netdbHostData(const char *host, int *samp, int *rtt, int *hops) STUB
+
int memPoolGetGlobalStats(MemPoolGlobalStats * stats) STUB_RETVAL(0)
int memPoolInUseCount(MemAllocator *) STUB_RETVAL(0)
int memPoolsTotalAllocated(void) STUB_RETVAL(0)
+
void Mgr::StringParam::unpackValue(const Ipc::TypedMsgHdr& msg) STUB
static String t;
const String& Mgr::StringParam::value() const STUB_RETVAL(t)
+
#include "ssl/Config.h"
Ssl::Config::Config():
#if USE_SSL_CRTD
- ssl_crtd(NULL),
+ ssl_crtd(NULL),
#endif
- ssl_crt_validator(NULL)
+ ssl_crt_validator(NULL)
{
ssl_crt_validator_Children.concurrency = 1;
STUB_NOP
} //namespace Ssl
#endif
+
#include "tests/STUB.h"
mem_node::mem_node(int64_t offset):nodeBuffer(0,offset,data) STUB
- size_t mem_node::InUseCount() STUB_RETVAL(0)
+ size_t mem_node::InUseCount() STUB_RETVAL(0)
+
#include "tests/STUB.h"
size_t headersEnd(const char *mime, size_t l) STUB_RETVAL(0)
+
void
peerConnClosed(CachePeer *p) STUB
+
void PconnModule::registerWithCacheManager(void) STUB
void PconnModule::add(PconnPool *) STUB
void PconnModule::dump(StoreEntry *) STUB
+
void redirectShutdown(void) STUB
void redirectStart(ClientHttpRequest *, HLPCB *, void *) STUB
void storeIdStart(ClientHttpRequest *, HLPCB *, void *) STUB
+
class StoreEntry;
const char *storeEntryFlags(const StoreEntry *) STUB_RETVAL(NULL)
+
void destroyStoreEntry(void *) STUB
// in Packer.cc !? void packerToStoreInit(Packer * p, StoreEntry * e) STUB
void storeGetMemSpace(int size) STUB
+
bool store_client::memReaderHasLowerOffset(int64_t anOffset) const STUB_RETVAL(false)
void store_client::dumpStats(MemBuf * output, int clientNumber) const STUB
int store_client::getType() const STUB_RETVAL(0)
+
void storeDigestNoteStoreReady(void) STUB
void storeDigestDel(const StoreEntry *) STUB
void storeDigestReport(StoreEntry *) STUB
+
buf.appended(buf.spaceSize());
return true;
}
+
// has a StoreIoStats global
memset(this, 0, sizeof(*this));
}
+
char *storeSwapMetaPack(tlv * tlv_list, int *length) STUB_RETVAL(NULL)
tlv *storeSwapMetaBuild(StoreEntry * e) STUB_RETVAL(NULL)
void storeSwapTLVFree(tlv * n) STUB
+
void strwordquote(MemBuf * mb, const char *str) STUB
void keepCapabilities(void) STUB
void restoreCapabilities(bool keep) STUB
+
void parse_wccp2_method(int *) STUB
#endif /* USE_WCCPv2 */
+
void wordlistJoin(wordlist **, wordlist **) STUB
wordlist *wordlistDup(const wordlist *) STUB_RETVAL(NULL)
void wordlistDestroy(wordlist **) STUB
+
}
#endif /* USE_AUTH */
+
#endif /* USE_AUTH */
#endif /* SQUID_SRC_TEST_ACLMAXUSERIP_H */
+
unsigned paramlength;
}
- params[]={ {"digest", digest_parms, 2},
+ params[]= { {"digest", digest_parms, 2},
{"basic", basic_parms, 2},
{"ntlm", ntlm_parms, 1},
{"negotiate", negotiate_parms, 1}
#endif /* HAVE_AUTH_MODULE_NEGOTIATE */
#endif /* USE_AUTH */
+
#endif /* USE_AUTH */
#endif /* SQUID_SRC_TEST_AUTH_H */
+
{
CPPUNIT_ASSERT_EQUAL(0, 0);
}
+
action->run(sentry, false);
CPPUNIT_ASSERT_EQUAL(1,(int)sentry->flags);
}
+
CPPUNIT_ASSERT(module == NULL);
#endif
}
+
EventScheduler *scheduler = dynamic_cast<EventScheduler *>(EventScheduler::GetInstance());
CPPUNIT_ASSERT(NULL != scheduler);
}
+
CPPUNIT_ASSERT_EQUAL(10, first_engine.lasttimeout);
CPPUNIT_ASSERT_EQUAL(0, second_engine.lasttimeout);
}
+
}
}
#endif /* __cplusplus >= 201103L */
+
input.reset();
error = Http::scNone;
}
+
input.reset();
error = Http::scNone;
}
+
buffer2 << HttpRequestMethod(SBuf("get"));
CPPUNIT_ASSERT_EQUAL(String("get"), String(buffer2.str().c_str()));
}
+
return result.wasSuccessful() ? 0 : 1;
}
+
}
return _ToRefCount::Instances == 0 ? 0 : 1;
}
+
comm_init();
- httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
+ httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
- httpReplyInitModule(); /* must go before accepting replies */
+ httpReplyInitModule(); /* must go before accepting replies */
mem_policy = createRemovalPolicy(Config.replPolicy);
CPPUNIT_ASSERT_EQUAL(static_cast<StoreEntry *>(NULL), pe2);
}
}
+
};
#endif /* SQUID_SRC_TEST_TESTROCK_H */
+
const char *alphabet="abcdefghijklmnopqrstuvwxyz";
SBuf a(alphabet);
std::string s(alphabet); // TODO
- { //regular chopping
+ { //regular chopping
SBuf b(a);
b.chop(3,3);
SBuf ref("def");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // chop at end
+ { // chop at end
SBuf b(a);
b.chop(b.length()-3);
SBuf ref("xyz");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // chop at beginning
+ { // chop at beginning
SBuf b(a);
b.chop(0,3);
SBuf ref("abc");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // chop to zero length
+ { // chop to zero length
SBuf b(a);
b.chop(5,0);
SBuf ref("");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // chop beyond end (at npos)
+ { // chop beyond end (at npos)
SBuf b(a);
b.chop(SBuf::npos,4);
SBuf ref("");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // chop beyond end
+ { // chop beyond end
SBuf b(a);
b.chop(b.length()+2,4);
SBuf ref("");
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // null-chop
+ { // null-chop
SBuf b(a);
b.chop(0,b.length());
SBuf ref(a);
CPPUNIT_ASSERT_EQUAL(ref,b);
}
- { // overflow chopped area
+ { // overflow chopped area
SBuf b(a);
b.chop(b.length()-3,b.length());
SBuf ref("xyz");
testSBuf::testStringOps()
{
SBuf sng(ToLower(literal)),
- ref("the quick brown fox jumped over the lazy dog");
+ ref("the quick brown fox jumped over the lazy dog");
CPPUNIT_ASSERT_EQUAL(ref,sng);
sng=literal;
CPPUNIT_ASSERT_EQUAL(0,sng.compare(ref,caseInsensitive));
SBuf sb(alphabet);
CPPUNIT_ASSERT_EQUAL(astr,sb.toStdString());
}
+
SBuf literal("The quick brown fox jumped over the lazy dog");
static int sbuf_tokens_number=9;
-static SBuf tokens[]={
+static SBuf tokens[]= {
SBuf("The",3), SBuf("quick",5), SBuf("brown",5), SBuf("fox",3),
SBuf("jumped",6), SBuf("over",4), SBuf("the",3), SBuf("lazy",4),
SBuf("dog",3)
SBuf joined=SBufContainerJoin(foo,SBuf(" "));
CPPUNIT_ASSERT_EQUAL(literal,joined);
}
+
CPPUNIT_ASSERT(ts3 == ts1);
}
+
};
#endif /* TESTSTATHIST_H_ */
+
CPPUNIT_ASSERT_EQUAL(static_cast<uint64_t>(3), aStore->maxSize());
Store::Root(NULL);
}
+
virtual void stat(StoreEntry &) const; /* output stats to the provided store entry */
- virtual void reference(StoreEntry &) {} /* Reference this object */
+ virtual void reference(StoreEntry &) {} /* Reference this object */
virtual bool dereference(StoreEntry &, bool) { return true; }
EBIT_CLR(e->flags, KEY_PRIVATE);
e->ping_status = PING_NONE;
EBIT_CLR(e->flags, ENTRY_VALIDATED);
- e->hashInsert((const cache_key *)name.termedBuf()); /* do it after we clear KEY_PRIVATE */
+ e->hashInsert((const cache_key *)name.termedBuf()); /* do it after we clear KEY_PRIVATE */
return e;
}
Store::Root(NULL);
}
+
EBIT_CLR(e->flags, KEY_PRIVATE);
e->ping_status = PING_NONE;
EBIT_CLR(e->flags, ENTRY_VALIDATED);
- e->hashInsert((const cache_key *)name.termedBuf()); /* do it after we clear KEY_PRIVATE */
+ e->hashInsert((const cache_key *)name.termedBuf()); /* do it after we clear KEY_PRIVATE */
return e;
}
Store::Root(NULL);
}
+
registerEngine(EventScheduler::GetInstance());
setTimeService(&default_time_engine);
}
+
};
#endif /* SQUID_TESTSTORESUPPORT_H */
+
String ref("34");
CPPUNIT_ASSERT(check == ref);
}
+
CPPUNIT_ASSERT(urlPointer != NULL);
delete urlPointer;
}
+
CPPUNIT_TEST_SUITE_REGISTRATION( testUfs );
typedef RefCount<Fs::Ufs::UFSSwapDir> SwapDirPointer;
-extern REMOVALPOLICYCREATE createRemovalPolicy_lru; /* XXX fails with --enable-removal-policies=heap */
+extern REMOVALPOLICYCREATE createRemovalPolicy_lru; /* XXX fails with --enable-removal-policies=heap */
static void
addSwapDir(SwapDirPointer aStore)
comm_init();
- httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
+ httpHeaderInitModule(); /* must go before any header processing (e.g. the one in errorInitialize) */
- httpReplyInitModule(); /* must go before accepting replies */
+ httpReplyInitModule(); /* must go before accepting replies */
inited = true;
}
RequestFlags flags;
flags.cachable = true;
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, Http::METHOD_GET);
- HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
+ HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
rep->setHeaders(Http::scOkay, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000);
pe->setPublicKey();
if (0 > system ("rm -rf " TESTDIR))
throw std::runtime_error("Failed to clean test work directory");
}
+
String from_buf(buffer.str().c_str());
CPPUNIT_ASSERT_EQUAL(http_str, from_buf);
}
+
fclose(fp);
snprintf(command, 256, "%s %s < %s", Config.EmailProgram, Config.adminEmail, filename);
- if (system(command)) {} /* XXX should avoid system(3) */
+ if (system(command)) {} /* XXX should avoid system(3) */
unlink(filename);
#if !HAVE_MKSTEMP
xfree(filename); // tempnam() requires us to free its allocation
#if PRINT_STACK_TRACE
#if _SQUID_HPUX_
{
- extern void U_STACK_TRACE(void); /* link with -lcl */
+ extern void U_STACK_TRACE(void); /* link with -lcl */
fflush(debug_log);
dup2(fileno(debug_log), 2);
U_STACK_TRACE();
#endif /* _SQUID_HPUX_ */
#if _SQUID_SOLARIS_ && HAVE_LIBOPCOM_STACK
- { /* get ftp://opcom.sun.ca/pub/tars/opcom_stack.tar.gz and */
- extern void opcom_stack_trace(void); /* link with -lopcom_stack */
+ { /* get ftp://opcom.sun.ca/pub/tars/opcom_stack.tar.gz and */
+ extern void opcom_stack_trace(void); /* link with -lopcom_stack */
fflush(debug_log);
dup2(fileno(debug_log), fileno(stdout));
opcom_stack_trace();
}
#if !HAVE_SIGACTION
- if (signal(sig, sigusr2_handle) == SIG_ERR) /* reinstall */
+ if (signal(sig, sigusr2_handle) == SIG_ERR) /* reinstall */
debugs(50, DBG_CRITICAL, "signal: sig=" << sig << " func=sigusr2_handle: " << xstrerror());
#endif
if (getrlimit(RLIMIT_DATA, &rl) < 0) {
debugs(50, DBG_CRITICAL, "getrlimit: RLIMIT_DATA: " << xstrerror());
} else if (rl.rlim_max > rl.rlim_cur) {
- rl.rlim_cur = rl.rlim_max; /* set it to the max */
+ rl.rlim_cur = rl.rlim_max; /* set it to the max */
if (setrlimit(RLIMIT_DATA, &rl) < 0) {
snprintf(tmp_error_buf, ERROR_BUF_SZ, "setrlimit: RLIMIT_DATA: %s", xstrerror());
if (getrlimit(RLIMIT_VMEM, &rl) < 0) {
debugs(50, DBG_CRITICAL, "getrlimit: RLIMIT_VMEM: " << xstrerror());
} else if (rl.rlim_max > rl.rlim_cur) {
- rl.rlim_cur = rl.rlim_max; /* set it to the max */
+ rl.rlim_cur = rl.rlim_max; /* set it to the max */
if (setrlimit(RLIMIT_VMEM, &rl) < 0) {
snprintf(tmp_error_buf, ERROR_BUF_SZ, "setrlimit: RLIMIT_VMEM: %s", xstrerror());
setmode(fileno(fp), O_TEXT);
#endif
- while (fgets(buf, 1024, fp)) { /* for each line */
+ while (fgets(buf, 1024, fp)) { /* for each line */
wordlist *hosts = NULL;
char *addr;
- if (buf[0] == '#') /* MS-windows likes to add comments */
+ if (buf[0] == '#') /* MS-windows likes to add comments */
continue;
- strtok(buf, "#"); /* chop everything following a comment marker */
+ strtok(buf, "#"); /* chop everything following a comment marker */
lt = buf;
nt = strpbrk(lt, w_space);
- if (nt == NULL) /* empty line */
+ if (nt == NULL) /* empty line */
continue;
- *nt = '\0'; /* null-terminate the address */
+ *nt = '\0'; /* null-terminate the address */
debugs(1, 5, "etc_hosts: address is '" << addr << "'");
while ((nt = strpbrk(lt, w_space))) {
char *host = NULL;
- if (nt == lt) { /* multiple spaces */
+ if (nt == lt) { /* multiple spaces */
debugs(1, 5, "etc_hosts: multiple spaces, skipping");
lt = nt + 1;
continue;
Ip::Interceptor.StopTransparency("Missing needed capability support.");
#endif /* HAVE_SYS_CAPABILITY_H */
}
+
void dumpMallocStats(void);
#endif /* SQUID_TOOLS_H_ */
+
void dataSent (size_t amount);
int len;
char *buf;
- int64_t *size_ptr; /* pointer to size in an ConnStateData for logging */
+ int64_t *size_ptr; /* pointer to size in an ConnStateData for logging */
Comm::ConnectionPointer conn; ///< The currently connected connection.
typedef void (TunnelStateData::*Method)(Ssl::PeerConnectorAnswer &);
MyAnswerDialer(Method method, TunnelStateData *tunnel):
- method_(method), tunnel_(tunnel), answer_() {}
+ method_(method), tunnel_(tunnel), answer_() {}
/* CallDialer API */
virtual bool canDial(AsyncCall &call) { return tunnel_.valid(); }
}
TunnelStateData::TunnelStateData() :
- url(NULL),
- http(),
- request(NULL),
- status_ptr(NULL),
- logTag_ptr(NULL),
- connectRespBuf(NULL),
- connectReqWriting(false)
+ url(NULL),
+ http(),
+ request(NULL),
+ status_ptr(NULL),
+ logTag_ptr(NULL),
+ connectRespBuf(NULL),
+ connectReqWriting(false)
{
debugs(26, 3, "TunnelStateData constructed this=" << this);
}
return;
}
- const CbcPointer<TunnelStateData> safetyLock(this); /* ??? should be locked by the caller... */
+ const CbcPointer<TunnelStateData> safetyLock(this); /* ??? should be locked by the caller... */
if (cbdataReferenceValid(this))
copyRead(client, ReadClient);
return;
}
- CbcPointer<TunnelStateData> safetyLock(this); /* ??? should be locked by the caller... */
+ CbcPointer<TunnelStateData> safetyLock(this); /* ??? should be locked by the caller... */
if (cbdataReferenceValid(this))
copyRead(server, ReadServer);
mb.init();
mb.Printf("CONNECT %s HTTP/1.1\r\n", tunnelState->url);
HttpStateData::httpBuildRequestHeader(tunnelState->request.getRaw(),
- NULL, /* StoreEntry */
- tunnelState->al, /* AccessLogEntry */
+ NULL, /* StoreEntry */
+ tunnelState->al, /* AccessLogEntry */
&hdr_out,
- flags); /* flags */
+ flags); /* flags */
packerToMemInit(&p, &mb);
hdr_out.packInto(&p);
hdr_out.clean();
// does not see it) and only then start shoveling data to the client
AsyncCall::Pointer writeCall = commCbCall(5,5, "tunnelConnectReqWriteDone",
CommIoCbPtrFun(tunnelConnectReqWriteDone,
- tunnelState));
+ tunnelState));
Comm::Write(srv, &mb, writeCall);
tunnelState->connectReqWriting = true;
tunnelState->request = request;
tunnelState->server.size_ptr = NULL; //Set later if ClientSocketContext is available
- // Temporary static variable to store the unneeded for our case status code
+ // Temporary static variable to store the unneeded for our case status code
static int status_code = 0;
tunnelState->status_ptr = &status_code;
tunnelState->client.conn = clientConn;
Comm::Write(tunnelState->client.conn, buf.content(), buf.contentSize(), call, NULL);
}
#endif //USE_OPENSSL
+
/* disk.c / diskd.c callback typedefs */
typedef void DRCB(int, const char *buf, int size, int errflag, void *data);
/* Disk read CB */
-typedef void DWCB(int, int, size_t, void *); /* disk write CB */
-typedef void DOCB(int, int errflag, void *data); /* disk open CB */
-typedef void DCCB(int, int errflag, void *data); /* disk close CB */
-typedef void DUCB(int errflag, void *data); /* disk unlink CB */
-typedef void DTCB(int errflag, void *data); /* disk trunc CB */
+typedef void DWCB(int, int, size_t, void *); /* disk write CB */
+typedef void DOCB(int, int errflag, void *data); /* disk open CB */
+typedef void DCCB(int, int errflag, void *data); /* disk close CB */
+typedef void DUCB(int errflag, void *data); /* disk unlink CB */
+typedef void DTCB(int errflag, void *data); /* disk trunc CB */
class DnsLookupDetails;
typedef void FQDNH(const char *, const DnsLookupDetails &details, void *);
typedef int READ_HANDLER(int, char *, int);
typedef int WRITE_HANDLER(int, const char *, int);
-typedef int QS(const void *, const void *); /* qsort */
+typedef int QS(const void *, const void *); /* qsort */
typedef void STABH(void *);
typedef void ERCB(int fd, void *, size_t);
class StoreEntry;
/*Use uint64_t to store miliseconds*/
typedef uint64_t time_msec_t;
#endif /* SQUID_TYPEDEFS_H */
+
}
#endif /* USE_UNLINKD */
+
#endif /* USE_UNLINKD */
#endif /* SQUID_UNLINKD_H_ */
+
#include "URL.h"
#include "urn.h"
-#define URN_REQBUF_SZ 4096
+#define URN_REQBUF_SZ 4096
class UrnState : public StoreClient
{
debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs");
- if (urls == NULL) { /* unkown URN error */
+ if (urls == NULL) { /* unkown URN error */
debugs(52, 3, "urnTranslateDone: unknown URN " << e->url());
err = new ErrorState(ERR_URN_RESOLVE, Http::scNotFound, urnState->request.getRaw());
err->url = xstrdup(e->url());
debugs(52, 3, "urnParseReply: Found " << i << " URLs");
return list;
}
+
void urnStart(HttpRequest *, StoreEntry *);
#endif /* SQUID_URN_H_ */
+
}
#endif /* USE_WCCP */
+
#endif /* USE_WCCP */
#endif /* SQUID_WCCP_H_ */
+
/* KDW WCCP V2 */
-#define WCCP2_HASH_ASSIGNMENT 0x00
-#define WCCP2_MASK_ASSIGNMENT 0x01
+#define WCCP2_HASH_ASSIGNMENT 0x00
+#define WCCP2_MASK_ASSIGNMENT 0x01
-#define WCCP2_NONE_SECURITY_LEN 0
-#define WCCP2_MD5_SECURITY_LEN SQUID_MD5_DIGEST_LENGTH // 16
+#define WCCP2_NONE_SECURITY_LEN 0
+#define WCCP2_MD5_SECURITY_LEN SQUID_MD5_DIGEST_LENGTH // 16
/* Useful defines */
-#define WCCP2_NUMPORTS 8
-#define WCCP2_PASSWORD_LEN 8
+#define WCCP2_NUMPORTS 8
+#define WCCP2_PASSWORD_LEN 8
/* WCCPv2 Pakcet format structures */
/* Defined in draft-wilson-wccp-v2-12-oct-2001.txt */
};
/* item type values */
-#define WCCP2_SECURITY_INFO 0
-#define WCCP2_SERVICE_INFO 1
-#define WCCP2_ROUTER_ID_INFO 2
-#define WCCP2_WC_ID_INFO 3
-#define WCCP2_RTR_VIEW_INFO 4
-#define WCCP2_WC_VIEW_INFO 5
-#define WCCP2_REDIRECT_ASSIGNMENT 6
-#define WCCP2_QUERY_INFO 7
-#define WCCP2_CAPABILITY_INFO 8
-#define WCCP2_ALT_ASSIGNMENT 13
-#define WCCP2_ASSIGN_MAP 14
-#define WCCP2_COMMAND_EXTENSION 15
+#define WCCP2_SECURITY_INFO 0
+#define WCCP2_SERVICE_INFO 1
+#define WCCP2_ROUTER_ID_INFO 2
+#define WCCP2_WC_ID_INFO 3
+#define WCCP2_RTR_VIEW_INFO 4
+#define WCCP2_WC_VIEW_INFO 5
+#define WCCP2_REDIRECT_ASSIGNMENT 6
+#define WCCP2_QUERY_INFO 7
+#define WCCP2_CAPABILITY_INFO 8
+#define WCCP2_ALT_ASSIGNMENT 13
+#define WCCP2_ASSIGN_MAP 14
+#define WCCP2_COMMAND_EXTENSION 15
/** \interface WCCPv2_Protocol
* Sect 5.5 WCCP Message Header
};
/* security options */
-#define WCCP2_NO_SECURITY 0
-#define WCCP2_MD5_SECURITY 1
+#define WCCP2_NO_SECURITY 0
+#define WCCP2_MD5_SECURITY 1
/** \interface WCCPv2_Protocol
* Sect 5.6.1 Security Info Component
uint16_t port7;
};
/* services */
-#define WCCP2_SERVICE_STANDARD 0
-#define WCCP2_SERVICE_DYNAMIC 1
+#define WCCP2_SERVICE_STANDARD 0
+#define WCCP2_SERVICE_DYNAMIC 1
/* service IDs */
-#define WCCP2_SERVICE_ID_HTTP 0x00
+#define WCCP2_SERVICE_ID_HTTP 0x00
/* service flags */
-#define WCCP2_SERVICE_SRC_IP_HASH 0x1
-#define WCCP2_SERVICE_DST_IP_HASH 0x2
-#define WCCP2_SERVICE_SRC_PORT_HASH 0x4
-#define WCCP2_SERVICE_DST_PORT_HASH 0x8
-#define WCCP2_SERVICE_PORTS_DEFINED 0x10
-#define WCCP2_SERVICE_PORTS_SOURCE 0x20
-#define WCCP2_SERVICE_SRC_IP_ALT_HASH 0x100
-#define WCCP2_SERVICE_DST_IP_ALT_HASH 0x200
-#define WCCP2_SERVICE_SRC_PORT_ALT_HASH 0x400
-#define WCCP2_SERVICE_DST_PORT_ALT_HASH 0x800
+#define WCCP2_SERVICE_SRC_IP_HASH 0x1
+#define WCCP2_SERVICE_DST_IP_HASH 0x2
+#define WCCP2_SERVICE_SRC_PORT_HASH 0x4
+#define WCCP2_SERVICE_DST_PORT_HASH 0x8
+#define WCCP2_SERVICE_PORTS_DEFINED 0x10
+#define WCCP2_SERVICE_PORTS_SOURCE 0x20
+#define WCCP2_SERVICE_SRC_IP_ALT_HASH 0x100
+#define WCCP2_SERVICE_DST_IP_ALT_HASH 0x200
+#define WCCP2_SERVICE_SRC_PORT_ALT_HASH 0x400
+#define WCCP2_SERVICE_DST_PORT_ALT_HASH 0x800
/* TODO the following structures need to be re-defined for correct full operation.
wccp2_cache_identity_element needs to be merged as a sub-struct of
static struct wccp2_capability_element_t wccp2_capability_element;
/* capability types */
-#define WCCP2_CAPABILITY_FORWARDING_METHOD 0x01
-#define WCCP2_CAPABILITY_ASSIGNMENT_METHOD 0x02
-#define WCCP2_CAPABILITY_RETURN_METHOD 0x03
+#define WCCP2_CAPABILITY_FORWARDING_METHOD 0x01
+#define WCCP2_CAPABILITY_ASSIGNMENT_METHOD 0x02
+#define WCCP2_CAPABILITY_RETURN_METHOD 0x03
// 0x04 ?? - advertised by a 4507 (ios v15.1) Cisco switch
// 0x05 ?? - advertised by a 4507 (ios v15.1) Cisco switch
/* capability values */
-#define WCCP2_METHOD_GRE 0x00000001
-#define WCCP2_METHOD_L2 0x00000002
+#define WCCP2_METHOD_GRE 0x00000001
+#define WCCP2_METHOD_L2 0x00000002
/* when type=WCCP2_CAPABILITY_FORWARDING_METHOD */
-#define WCCP2_FORWARDING_METHOD_GRE WCCP2_METHOD_GRE
-#define WCCP2_FORWARDING_METHOD_L2 WCCP2_METHOD_L2
+#define WCCP2_FORWARDING_METHOD_GRE WCCP2_METHOD_GRE
+#define WCCP2_FORWARDING_METHOD_L2 WCCP2_METHOD_L2
/* when type=WCCP2_CAPABILITY_ASSIGNMENT_METHOD */
-#define WCCP2_ASSIGNMENT_METHOD_HASH 0x00000001
-#define WCCP2_ASSIGNMENT_METHOD_MASK 0x00000002
+#define WCCP2_ASSIGNMENT_METHOD_HASH 0x00000001
+#define WCCP2_ASSIGNMENT_METHOD_MASK 0x00000002
/* when type=WCCP2_CAPABILITY_RETURN_METHOD */
-#define WCCP2_PACKET_RETURN_METHOD_GRE WCCP2_METHOD_GRE
-#define WCCP2_PACKET_RETURN_METHOD_L2 WCCP2_METHOD_L2
+#define WCCP2_PACKET_RETURN_METHOD_GRE WCCP2_METHOD_GRE
+#define WCCP2_PACKET_RETURN_METHOD_L2 WCCP2_METHOD_L2
/** \interface WCCPv2_Protocol
* 5.7.8 Value Element
size_t wccp_packet_size;
struct wccp2_service_list_t *next;
- char wccp_password[WCCP2_PASSWORD_LEN + 1]; /* hold the trailing C-string NUL */
+ char wccp_password[WCCP2_PASSWORD_LEN + 1]; /* hold the trailing C-string NUL */
uint32_t wccp2_security_type;
};
router_capability_header = (struct wccp2_capability_info_header_t *) &wccp2_i_see_you.data[offset];
break;
- /* Nothing to do for the types below */
+ /* Nothing to do for the types below */
case WCCP2_ASSIGN_MAP:
case WCCP2_REDIRECT_ASSIGNMENT:
int service_id = 0;
int flags = 0;
int portlist[WCCP2_NUMPORTS];
- int protocol = -1; /* IPPROTO_TCP | IPPROTO_UDP */
+ int protocol = -1; /* IPPROTO_TCP | IPPROTO_UDP */
struct wccp2_service_list_t *srv;
int priority = -1;
{}
#endif /* USE_WCCPv2 */
+
#endif /* USE_WCCPv2 */
#endif /* WCCP2_H_ */
+
StoreEntry *entry;
HttpRequest::Pointer request;
FwdState::Pointer fwd;
- char buf[BUFSIZ+1]; /* readReply adds terminating NULL */
+ char buf[BUFSIZ+1]; /* readReply adds terminating NULL */
bool dataWritten;
};
p->entry->unlock("whoisClose");
delete p;
}
+
void whoisStart(FwdState *);
#endif /* SQUID_WHOIS_H_ */
+
}
#endif /* SQUID_WINDOWS_ */
+
#endif
#endif /* SQUID_WIN32_H_ */
+
SBufList ToSBufList(wordlist *);
#endif /* SQUID_WORDLIST_H */
+
"!('a'<='c')",
"(1==1)|('abc'=='def')",
"(4!=5)&(4==5)",
- "(1==1)|(2==3)&(3==4)", /* should be true because of precedence */
+ "(1==1)|(2==3)&(3==4)", /* should be true because of precedence */
"(1 & 4)",
"(\"abc\" | \"edf\")", "1==1==1",
"!('')",
return 0;
}
+
assert (ChildVirtual::Calls.deletes() == 1);
return 0;
}
+
debugs(1, DBG_IMPORTANT,streamPointer->getAnInt() << " " << aStreamObject.getACString());
return 0;
}
+
* This came from ejb's hsearch.
*/
-#define PRIME1 37
-#define PRIME2 1048583
+#define PRIME1 37
+#define PRIME2 1048583
/* Hash function from Chris Torek. */
unsigned int
case 0:
do {
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 7:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 6:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 5:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 4:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 3:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 2:
HASH4;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case 1:
HASH4;
} while (--loop);
if (hid->current_ptr != NULL) {
hid->current_ptr = hid->current_ptr->next;
if (hid->current_ptr != NULL)
- return (hid->current_ptr); /* next item */
+ return (hid->current_ptr); /* next item */
}
/* find next bucket */
for (i = hid->current_slot + 1; i < hid->size; i++) {
if (hid->buckets[i] != NULL)
return (hid->current_ptr = hid->buckets[i]);
}
- return NULL; /* end of list */
+ return NULL; /* end of list */
}
int
for (prev = NULL, walker = hid->buckets[i];
walker != NULL; prev = walker, walker = walker->next) {
if (walker == hl) {
- if (prev == NULL) { /* it's the head */
+ if (prev == NULL) { /* it's the head */
hid->buckets[i] = walker->next;
} else {
- prev->next = walker->next; /* skip it */
+ prev->next = walker->next; /* skip it */
}
/* fix walker state if needed */
if (walker == hid->current_ptr)
exit(0);
}
#endif
+
extern int hash_links_allocated;
/* AYJ: defined by globals.h */
-//extern int store_hash_buckets; /* 0 */
-//extern hash_table *store_table; /* NULL */
+//extern int store_hash_buckets; /* 0 */
+//extern hash_table *store_table; /* NULL */
extern hash_table *hash_create(HASHCMP *, int, HASHHASH *);
extern void hash_insert(hash_table *, const char *, void *);
extern int hash_delete(hash_table *, const char *);
HASHHASH hash4;
}
+
assert (mem_node::InUseCount() == 0);
return 0;
}
+
assert (mem_node::InUseCount() == 0);
return 0;
}
+
#ifdef WITH_LIB
sizeToPoolInit();
#endif
- mem_table = hash_create(ptrcmp, 229, hash4); /* small hash table */
+ mem_table = hash_create(ptrcmp, 229, hash4); /* small hash table */
init_stats();
while (fgets(mbuf, 256, fp) != NULL) {
if (run_stats > 0 && (++a) % run_stats == 0)
print_stats();
p = NULL;
switch (mbuf[0]) {
- case 'm': /* malloc */
+ case 'm': /* malloc */
p = strtok(&mbuf[2], ":");
if (!p)
badformat();
strcpy(mi->orig_ptr, p);
mi->size = size;
size2id(size, mi);
- mi->my_ptr = xmemAlloc(mi); /* (void *)xmalloc(size); */
+ mi->my_ptr = xmemAlloc(mi); /* (void *)xmalloc(size); */
assert(mi->my_ptr);
my_hash_insert(mem_table, mi->orig_ptr, mi);
mstat.mallocs++;
break;
- case 'c': /* calloc */
+ case 'c': /* calloc */
p = strtok(&mbuf[2], ":");
if (!p)
badformat();
strcpy(mi->orig_ptr, p);
size2id(size, mi);
mi->size = amt * size;
- mi->my_ptr = xmemAlloc(mi); /*(void *)xmalloc(amt*size); */
+ mi->my_ptr = xmemAlloc(mi); /*(void *)xmalloc(amt*size); */
assert(mi->my_ptr);
my_hash_insert(mem_table, mi->orig_ptr, mi);
mstat.callocs++;
mi = (memitem *) (mem_entry->item);
assert(mi->pool);
assert(mi->my_ptr);
- xmemFree(mi); /* xfree(mi->my_ptr); */
- size2id(atoi(p), mi); /* we don't need it here I guess? */
+ xmemFree(mi); /* xfree(mi->my_ptr); */
+ size2id(atoi(p), mi); /* we don't need it here I guess? */
strcpy(mi->orig_ptr, abuf);
p = strtok(NULL, "\n");
if (!p)
badformat();
- mi->my_ptr = xmemAlloc(mi); /* (char *)xmalloc(atoi(p)); */
+ mi->my_ptr = xmemAlloc(mi); /* (char *)xmalloc(atoi(p)); */
assert(mi->my_ptr);
mstat.reallocs++;
break;
mi = (memitem *) (mem_entry->item);
assert(mi->pool);
assert(mi->my_ptr);
- xmemFree(mi); /* xfree(mi->my_ptr); */
+ xmemFree(mi); /* xfree(mi->my_ptr); */
hash_unlink(mem_table, mem_entry, 1);
free(mi);
mstat.frees++;
const char *
make_nam(int id, int size)
{
- const char *buf = malloc(30); /* argh */
+ const char *buf = malloc(30); /* argh */
snprintf((char *)buf, sizeof(buf)-1, "pl:%d/%d", id, size);
return buf;
}
fprintf(stderr, "}\n");
#endif
}
+
memcpy(buf, r->reply_hdrs + r->hdr_length, blen);
len += blen;
}
- r->reply_hdrs[r->hdr_length] = '\0'; /* Null terminate headers */
+ r->reply_hdrs[r->hdr_length] = '\0'; /* Null terminate headers */
/* Parse headers */
r->content_length = get_header_int_value("content-length:", r->reply_hdrs, end);
/* fprintf(stderr, "CONTENT_LENGTH = %d\n", r->content_length); */
assert(bytes_left >= 0);
bytes_used = len < bytes_left ? len : bytes_left;
} else {
- bytes_left = len + 1; /* Unknown end... */
+ bytes_left = len + 1; /* Unknown end... */
bytes_used = len;
}
if (opt_checksum) {
main_loop();
return 0;
}
+
CheckSyntheticWorks();
return 0;
}
+
reply_done(int fd, void *data)
{
struct _request *r = data;
- if (opt_range); /* skip size checks for now */
+ if (opt_range); /* skip size checks for now */
else if (strcmp(r->method, "HEAD") == 0);
else if (r->bodysize != r->content_length && r->content_length >= 0)
fprintf(stderr, "ERROR: %s got %d of %d bytes\n",
if (size && strcmp(size, "-") != 0)
r->validsize = atoi(size);
else
- r->validsize = -1; /* Unknown */
+ r->validsize = -1; /* Unknown */
if (checksum && strcmp(checksum, "-") != 0)
r->validsum = strtoul(checksum, NULL, 0);
if (status)
r->validstatus = atoi(status);
- r->content_length = -1; /* Unknown */
+ r->content_length = -1; /* Unknown */
if (opt_accel) {
host = strchr(url, '/') + 2;
url = strchr(host, '/');
printf("Exiting normally\n");
return 0;
}
+
pwfd = c2p[1];
if ((pid = fork()) < 0)
abort();
- if (pid > 0) { /* parent */
+ if (pid > 0) { /* parent */
/* close shared socket with child */
close(crfd);
close(cwfd);
close(i);
sleep(1);
}
+
m->next = m->prev = NULL;
}
+
select(1, NULL, NULL, NULL, &to);
return 0;
}
+
/*
* Static variables and constants
*/
-static const time_t passwd_ttl = 60 * 60 * 3; /* in sec */
+static const time_t passwd_ttl = 60 * 60 * 3; /* in sec */
static const char *script_name = "/cgi-bin/cachemgr.cgi";
static const char *progname = NULL;
static time_t now;
if (status == 401 || status == 407) {
reset_auth(req);
- status = 403; /* Forbiden, see comments in case isForward: */
+ status = 403; /* Forbiden, see comments in case isForward: */
}
/* this is a way to pass HTTP status to the Web server */
if (statusStr)
- printf("Status: %d %s", status, statusStr); /* statusStr has '\n' */
+ printf("Status: %d %s", status, statusStr); /* statusStr has '\n' */
break;
case isHeaders:
/* forward header field */
- if (!strcmp(buf, "\r\n")) { /* end of headers */
- fputs("Content-Type: text/html\r\n", stdout); /* add our type */
+ if (!strcmp(buf, "\r\n")) { /* end of headers */
+ fputs("Content-Type: text/html\r\n", stdout); /* add our type */
istate = isBodyStart;
}
- if (strncasecmp(buf, "Content-Type:", 13)) /* filter out their type */
+ if (strncasecmp(buf, "Content-Type:", 13)) /* filter out their type */
fputs(buf, stdout);
break;
}
istate = isActions;
- /* yes, fall through, we do not want to loose the first line */
+ /* yes, fall through, we do not want to loose the first line */
case isActions:
if (strncmp(buf, "action:", 7) == 0) {
}
istate = isBody;
- /* yes, fall through, we do not want to loose the first line */
+ /* yes, fall through, we do not want to loose the first line */
case isBody:
/* interpret [and reformat] cache response */
* 401 to .cgi because web server filters out all auth info. Thus we
* disable authentication headers for now.
*/
- if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19)); /* skip */
+ if (!strncasecmp(buf, "WWW-Authenticate:", 17) || !strncasecmp(buf, "Proxy-Authenticate:", 19)); /* skip */
else
fputs(buf, stdout);
"GET cache_object://%s/%s%s%s HTTP/1.0\r\n"
"User-Agent: cachemgr.cgi/%s\r\n"
"Accept: */*\r\n"
- "%s" /* Authentication info or nothing */
+ "%s" /* Authentication info or nothing */
"\r\n",
req->hostname,
req->action,
fclose(fp);
return ret;
}
+
regfree(&rexp);
return cachedir.size();
}
+
};
REList::REList( const char* what, bool doCase )
- :next(0),data(xstrdup(what))
+ :next(0),data(xstrdup(what))
{
int result = regcomp( &rexp, what,
REG_EXTENDED | REG_NOSUB | (doCase ? 0 : REG_ICASE) );
const char* fn, const char* url, const SquidMetaList& meta )
// purpose: if cmdline-requested, send the purge request to the cache
// paramtr: fd (IN): open FD for the object file
-// metasize (IN): offset into data portion of file (meta data size)
+// metasize (IN): offset into data portion of file (meta data size)
// fn (IN): name of the object file
// url (IN): URL string stored in the object file
-// meta (IN): list containing further meta data
+// meta (IN): list containing further meta data
// returns: true for a successful action, false otherwise. The action
// may just print the file, send the purge request or even
// remove unwanted files.
delete list;
return 0;
}
+
#include "squid-tlv.hh"
SquidTLV::SquidTLV( SquidMetaType _type, size_t _size, void* _data )
- :next(0),size(_size)
+ :next(0),size(_size)
{
type = _type;
data = (char*) _data;
while ( temp && temp->type != type ) temp = temp->next;
return temp;
}
+
extern Parameters scParams;
#endif /* _SQUID_TOOLS_SQUIDCLIENT_PARAMETERS_H */
+
opterr = saved_opterr;
return false;
}
+
} // namespace Ping
#endif /* _SQUID_TOOLS_CLIENT_PING_H */
+
Config.tlsEnabled = false;
#endif
}
+
{
public:
TheConfig() :
- ioTimeout(120),
- localHost(NULL),
- port(CACHE_HTTP_PORT),
- tlsEnabled(false),
- tlsAnonymous(false) {
+ ioTimeout(120),
+ localHost(NULL),
+ port(CACHE_HTTP_PORT),
+ tlsEnabled(false),
+ tlsAnonymous(false) {
params = "NORMAL";
hostname = "localhost";
}
} // namespace Transport
#endif /* SQUID_TOOLS_SQUIDCLIENT_TRANSPORT_H */
+
}
#endif /* HAVE_GSSAPI */
+
#endif /* HAVE_GSSAPI */
#endif /* _SQUID_TOOLS_SQUIDCLIENT_GSSAPI_H */
+
#endif
#ifndef BUFSIZ
-#define BUFSIZ 8192
+#define BUFSIZ 8192
#endif
#ifndef MESSAGELEN
-#define MESSAGELEN 65536
+#define MESSAGELEN 65536
#endif
#ifndef HEADERLEN
-#define HEADERLEN 65536
+#define HEADERLEN 65536
#endif
/* Local functions */
<< "Usage: " << progname << " [Basic Options] [HTTP Options]" << std::endl
<< std::endl;
std::cerr
- << " -s | --quiet Silent. Do not print response message to stdout." << std::endl
- << " -v | --verbose Verbose debugging. Repeat (-vv) to increase output level." << std::endl
- << " Levels:" << std::endl
- << " 1 - Print outgoing request message to stderr." << std::endl
- << " 2 - Print action trace to stderr." << std::endl
- << " --help Display this help text." << std::endl
- << std::endl;
+ << " -s | --quiet Silent. Do not print response message to stdout." << std::endl
+ << " -v | --verbose Verbose debugging. Repeat (-vv) to increase output level." << std::endl
+ << " Levels:" << std::endl
+ << " 1 - Print outgoing request message to stderr." << std::endl
+ << " 2 - Print action trace to stderr." << std::endl
+ << " --help Display this help text." << std::endl
+ << std::endl;
Transport::Config.usage();
Ping::Config.usage();
std::cerr
- << "HTTP Options:" << std::endl
- << " -a Do NOT include Accept: header." << std::endl
- << " -A User-Agent: header. Use \"\" to omit." << std::endl
- << " -H 'string' Extra headers to send. Use '\\n' for new lines." << std::endl
- << " -i IMS If-Modified-Since time (in Epoch seconds)." << std::endl
- << " -j hosthdr Host header content" << std::endl
- << " -k Keep the connection active. Default is to do only one request then close." << std::endl
- << " -m method Request method, default is GET." << std::endl
+ << "HTTP Options:" << std::endl
+ << " -a Do NOT include Accept: header." << std::endl
+ << " -A User-Agent: header. Use \"\" to omit." << std::endl
+ << " -H 'string' Extra headers to send. Use '\\n' for new lines." << std::endl
+ << " -i IMS If-Modified-Since time (in Epoch seconds)." << std::endl
+ << " -j hosthdr Host header content" << std::endl
+ << " -k Keep the connection active. Default is to do only one request then close." << std::endl
+ << " -m method Request method, default is GET." << std::endl
#if HAVE_GSSAPI
- << " -n Proxy Negotiate(Kerberos) authentication" << std::endl
- << " -N WWW Negotiate(Kerberos) authentication" << std::endl
+ << " -n Proxy Negotiate(Kerberos) authentication" << std::endl
+ << " -N WWW Negotiate(Kerberos) authentication" << std::endl
#endif
- << " -P file Send content from the named file as request payload" << std::endl
- << " -r Force cache to reload URL" << std::endl
- << " -t count Trace count cache-hops" << std::endl
- << " -u user Proxy authentication username" << std::endl
- << " -U user WWW authentication username" << std::endl
- << " -V version HTTP Version. Use '-' for HTTP/0.9 omitted case" << std::endl
- << " -w password Proxy authentication password" << std::endl
- << " -W password WWW authentication password" << std::endl
- ;
+ << " -P file Send content from the named file as request payload" << std::endl
+ << " -r Force cache to reload URL" << std::endl
+ << " -t count Trace count cache-hops" << std::endl
+ << " -u user Proxy authentication username" << std::endl
+ << " -U user WWW authentication username" << std::endl
+ << " -V version HTTP Version. Use '-' for HTTP/0.9 omitted case" << std::endl
+ << " -w password Proxy authentication password" << std::endl
+ << " -W password WWW authentication password" << std::endl
+ ;
exit(1);
}
Ip::ProbeTransport(); // determine IPv4 or IPv6 capabilities before parsing.
if (argc < 2 || argv[argc-1][0] == '-') {
- usage(argv[0]); /* need URL */
+ usage(argv[0]); /* need URL */
} else if (argc >= 2) {
strncpy(url, argv[argc - 1], BUFSIZ);
url[BUFSIZ - 1] = '\0';
Ping::Config.parseCommandOpts(argc, argv, c, optIndex);
continue;
- case 'h': /* remote host */
- case 'l': /* local host */
- case 'p': /* port number */
+ case 'h': /* remote host */
+ case 'l': /* local host */
+ case 'p': /* port number */
// rewind and let the Transport::Config parser handle
optind -= 2;
version = optarg;
break;
- case 's': /* silent */
+ case 's': /* silent */
to_stdout = false;
break;
- case 'k': /* backward compat */
+ case 'k': /* backward compat */
keep_alive = 1;
break;
- case 'r': /* reload */
+ case 'r': /* reload */
reload = true;
break;
put_file = xstrdup(optarg);
break;
- case 'i': /* IMS */
+ case 'i': /* IMS */
ims = (time_t) atoi(optarg);
break;
debugVerbose(2, "verbosity level set to " << scParams.verbosityLevel);
break;
- case '?': /* usage */
+ case '?': /* usage */
default:
usage(argv[0]);
signal(SIGPIPE, pipe_handler);
#endif
}
+