return (sp->mysockaddr);
}
+int
+VRT_r_server_port(struct sess *sp)
+{
+ char abuf[TCP_ADDRBUFSIZE];
+ char pbuf[TCP_PORTBUFSIZE];
+
+ if (sp->mysockaddr->sa_family == AF_UNSPEC)
+ AZ(getsockname(sp->fd, sp->mysockaddr, &sp->mysockaddrlen));
+ TCP_name(sp->mysockaddr, sp->mysockaddrlen, abuf, sizeof abuf, pbuf, sizeof pbuf);
+
+ return (atoi(pbuf));
+}
+
/*--------------------------------------------------------------------
* Add an element to the array/list of hash bits.
*/
struct sockaddr * VRT_r_client_ip(const struct sess *);
struct sockaddr * VRT_r_server_ip(struct sess *);
+int VRT_r_server_port(struct sess *);
const char * VRT_r_req_request(const struct sess *);
void VRT_l_req_request(const struct sess *, const char *, ...);
const char * VRT_r_req_url(const struct sess *);
vsb_cat(sb, "\n");
vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n");
vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n");
+ vsb_cat(sb, "int VRT_r_server_port(struct sess *);\n");
vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char *, ...);\n");
vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\n");
-#!/usr/local/bin/tclsh8.4
+#!/usr/bin/tclsh8.4
#-
# Copyright (c) 2006 Verdens Gang AS
# Copyright (c) 2006-2008 Linpro AS
{recv pipe pass hash miss hit fetch deliver }
"struct sess *"
}
-
+ { server.port
+ RO INT
+ {recv pipe pass hash miss hit fetch deliver }
+ "struct sess *"
+ }
# Request paramters
{ req.request
RW STRING
0,
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
},
+ { "server.port", INT, 11,
+ "VRT_r_server_port(sp)",
+ NULL,
+ V_RO,
+ 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ },
{ "req.request", STRING, 11,
"VRT_r_req_request(sp)",
"VRT_l_req_request(sp, ",
.It Va server.ip
The IP address of the socket on which the client connection was
received.
+.It Va server.port
+The port number of the socket on which the client connection was
+received.
.It Va req.request
The request type (e.g. "GET", "HEAD").
.It Va req.url