void VRT_l_req_proto(struct sess *, const char *);
struct backend * VRT_r_req_backend(struct sess *);
void VRT_l_req_backend(struct sess *, struct backend *);
+int VRT_r_req_hash(struct sess *);
+void VRT_l_req_hash(struct sess *, int);
double VRT_r_obj_valid(struct sess *);
void VRT_l_obj_valid(struct sess *, double);
double VRT_r_obj_cacheable(struct sess *);
#include "vcc_compile.h"
#include "libvarnish.h"
+/*--------------------------------------------------------------------*/
+
+static void
+StringVal(struct tokenlist *tl)
+{
+ struct var *vp;
+ struct token *vt;
+
+ if (tl->t->tok == CSTR) {
+ EncToken(tl->fb, tl->t);
+ vcc_NextToken(tl);
+ return;
+ }
+ ExpectErr(tl, VAR);
+ ERRCHK(tl);
+ vt = tl->t;
+ vp = FindVar(tl, tl->t, vcc_vars);
+ ERRCHK(tl);
+ if (!vp->has_string) {
+ vsb_printf(tl->sb,
+ "No string representation of '%s'\n", vp->name);
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+ switch (vp->fmt) {
+ case STRING:
+ Fb(tl, 0, "%s", vp->rname);
+ break;
+ default:
+ vsb_printf(tl->sb,
+ "String representation of '%s' not implemented yet.\n",
+ vp->name);
+ vcc_ErrWhere(tl, tl->t);
+ return;
+ }
+ vcc_NextToken(tl);
+}
/*--------------------------------------------------------------------*/
" only '=' is legal for backend\n");
vcc_ErrWhere(tl, tl->t);
return;
+ case HASH:
+ ExpectErr(tl, T_INCR);
+ vcc_NextToken(tl);
+ StringVal(tl);
+ Fb(tl, 0, ");\n");
+ return;
default:
vsb_printf(tl->sb,
"Assignments not possible for '%s'\n", vp->name);
p[i] = '\0';
v->name = p;
v->fmt = STRING;
+ v->has_string = vh->has_string;
if (!memcmp(vh->name, "req.", 4))
w = 1;
else
IP,
HOSTNAME,
PORTNAME,
+ HASH,
HEADER
};
unsigned len;
const char *rname;
const char *lname;
+ unsigned has_string;
};
struct method {
# Objects which operate on backends
set beobj {
- { backend.host HOSTNAME }
- { backend.port PORTNAME }
- { backend.dnsttl TIME }
+ { backend.host HOSTNAME 0 }
+ { backend.port PORTNAME 0 }
+ { backend.dnsttl TIME 0 }
}
# Objects which operate on sessions
set spobj {
- { client.ip IP }
- { server.ip IP }
- { req.request STRING }
- { req.host STRING }
- { req.url STRING }
- { req.proto STRING }
- { req.backend BACKEND }
- { obj.valid BOOL }
- { obj.cacheable BOOL }
- { obj.ttl TIME }
- { req.http. HEADER }
- { resp.http. HEADER }
+ { client.ip IP 1}
+ { server.ip IP 1}
+ { req.request STRING 1}
+ { req.host STRING 1}
+ { req.url STRING 1}
+ { req.proto STRING 1}
+ { req.backend BACKEND 0}
+ { req.hash HASH 0}
+ { obj.valid BOOL 0}
+ { obj.cacheable BOOL 0}
+ { obj.ttl TIME 0}
+ { req.http. HEADER 1}
+ { resp.http. HEADER 1}
}
set tt(IP) "struct sockaddr *"
set tt(HEADER) "const char *"
set tt(HOSTNAME) "const char *"
set tt(PORTNAME) "const char *"
+set tt(HASH) "int"
#----------------------------------------------------------------------
# Boilerplate warning for all generated files.
puts $fo "\t\{ \"$n\", $t, [string length $n],"
puts $fo "\t \"VRT_r_${m}($pa)\","
puts $fo "\t \"VRT_l_${m}($pa, \","
+ puts $fo "\t [lindex $v 2]"
puts $fo "\t\},"
puts $fp "$tt($t) VRT_r_${m}($ty);"
{ "backend.host", HOSTNAME, 12,
"VRT_r_backend_host(backend)",
"VRT_l_backend_host(backend, ",
+ 0
},
{ "backend.port", PORTNAME, 12,
"VRT_r_backend_port(backend)",
"VRT_l_backend_port(backend, ",
+ 0
},
{ "backend.dnsttl", TIME, 14,
"VRT_r_backend_dnsttl(backend)",
"VRT_l_backend_dnsttl(backend, ",
+ 0
},
{ NULL }
};
{ "client.ip", IP, 9,
"VRT_r_client_ip(sp)",
"VRT_l_client_ip(sp, ",
+ 1
},
{ "server.ip", IP, 9,
"VRT_r_server_ip(sp)",
"VRT_l_server_ip(sp, ",
+ 1
},
{ "req.request", STRING, 11,
"VRT_r_req_request(sp)",
"VRT_l_req_request(sp, ",
+ 1
},
{ "req.host", STRING, 8,
"VRT_r_req_host(sp)",
"VRT_l_req_host(sp, ",
+ 1
},
{ "req.url", STRING, 7,
"VRT_r_req_url(sp)",
"VRT_l_req_url(sp, ",
+ 1
},
{ "req.proto", STRING, 9,
"VRT_r_req_proto(sp)",
"VRT_l_req_proto(sp, ",
+ 1
},
{ "req.backend", BACKEND, 11,
"VRT_r_req_backend(sp)",
"VRT_l_req_backend(sp, ",
+ 0
+ },
+ { "req.hash", HASH, 8,
+ "VRT_r_req_hash(sp)",
+ "VRT_l_req_hash(sp, ",
+ 0
},
{ "obj.valid", BOOL, 9,
"VRT_r_obj_valid(sp)",
"VRT_l_obj_valid(sp, ",
+ 0
},
{ "obj.cacheable", BOOL, 13,
"VRT_r_obj_cacheable(sp)",
"VRT_l_obj_cacheable(sp, ",
+ 0
},
{ "obj.ttl", TIME, 7,
"VRT_r_obj_ttl(sp)",
"VRT_l_obj_ttl(sp, ",
+ 0
},
{ "req.http.", HEADER, 9,
"VRT_r_req_http_(sp)",
"VRT_l_req_http_(sp, ",
+ 1
},
{ "resp.http.", HEADER, 10,
"VRT_r_resp_http_(sp)",
"VRT_l_resp_http_(sp, ",
+ 1
},
{ NULL }
};