Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
6662b1bb
Commit
6662b1bb
authored
Oct 28, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pull the switch and give VCL_IP a proper type.
parent
c73544e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
38 deletions
+28
-38
vrt.h
include/vrt.h
+1
-2
vsa.h
include/vsa.h
+3
-3
vsa.c
lib/libvarnish/vsa.c
+16
-23
vmod_std_conversions.c
lib/libvmod_std/vmod_std_conversions.c
+8
-10
No files found.
include/vrt.h
View file @
6662b1bb
...
...
@@ -56,8 +56,7 @@ typedef double VCL_DURATION;
typedef
const
char
*
VCL_ENUM
;
typedef
const
char
*
VCL_HEADER
;
typedef
long
VCL_INT
;
//typedef const struct suckaddr * VCL_IP;
typedef
const
void
*
VCL_IP
;
typedef
const
struct
suckaddr
*
VCL_IP
;
typedef
double
VCL_REAL
;
typedef
const
char
*
VCL_STRING
;
typedef
double
VCL_TIME
;
...
...
include/vsa.h
View file @
6662b1bb
...
...
@@ -33,9 +33,9 @@
struct
suckaddr
;
extern
const
int
vsa_suckaddr_len
;
int
VSA_Sane
(
const
void
*
);
socklen_t
VSA_Len
(
const
void
*
);
unsigned
VSA_Port
(
const
void
*
);
int
VSA_Sane
(
const
struct
suckaddr
*
);
socklen_t
VSA_Len
(
const
struct
suckaddr
*
);
unsigned
VSA_Port
(
const
struct
suckaddr
*
);
int
VSA_Compare
(
const
struct
suckaddr
*
,
const
struct
suckaddr
*
);
const
struct
sockaddr
*
VSA_Get_Sockaddr
(
const
struct
suckaddr
*
,
socklen_t
*
sl
);
...
...
lib/libvarnish/vsa.c
View file @
6662b1bb
...
...
@@ -252,9 +252,11 @@ VSA_Build(void *d, const void *s, unsigned sal)
default:
break
;
}
if
(
l
!=
0
)
if
(
l
!=
0
)
{
memcpy
(
&
sua
->
sa
,
s
,
l
);
return
(
sua
);
return
(
sua
);
}
return
(
NULL
);
}
const
struct
sockaddr
*
...
...
@@ -276,11 +278,10 @@ VSA_Get_Sockaddr(const struct suckaddr *sua, socklen_t *sl)
}
int
VSA_Sane
(
const
void
*
s
)
VSA_Sane
(
const
struct
suckaddr
*
s
)
{
const
struct
sockaddr
*
sa
=
s
;
switch
(
s
a
->
sa_family
)
{
switch
(
s
->
sa
.
sa_family
)
{
case
PF_INET
:
case
PF_INET6
:
return
(
1
);
...
...
@@ -290,17 +291,16 @@ VSA_Sane(const void *s)
}
socklen_t
VSA_Len
(
const
void
*
s
)
VSA_Len
(
const
struct
suckaddr
*
s
)
{
const
struct
sockaddr
*
sa
=
s
;
switch
(
s
a
->
sa_family
)
{
switch
(
s
->
sa
.
sa_family
)
{
case
PF_INET
:
return
(
sizeof
(
s
truct
sockaddr_in
));
return
(
sizeof
(
s
->
sa4
));
case
PF_INET6
:
return
(
sizeof
(
s
truct
sockaddr_in
6
));
return
(
sizeof
(
s
->
sa
6
));
default:
WRONG
(
"Illegal socket family"
);
return
(
0
);
}
}
...
...
@@ -313,22 +313,15 @@ VSA_Compare(const struct suckaddr *s1, const struct suckaddr *s2)
}
unsigned
VSA_Port
(
const
void
*
s
)
VSA_Port
(
const
struct
suckaddr
*
s
)
{
const
struct
sockaddr
*
sa
=
s
;
switch
(
s
a
->
sa_family
)
{
switch
(
s
->
sa
.
sa_family
)
{
case
PF_INET
:
{
const
struct
sockaddr_in
*
ain
=
s
;
return
(
ntohs
((
ain
->
sin_port
)));
}
return
(
ntohs
(
s
->
sa4
.
sin_port
));
case
PF_INET6
:
{
const
struct
sockaddr_in6
*
ain
=
s
;
return
(
ntohs
((
ain
->
sin6_port
)));
}
return
(
ntohs
(
s
->
sa6
.
sin6_port
));
default:
WRONG
(
"Illegal socket family"
);
return
(
0
);
}
}
lib/libvmod_std/vmod_std_conversions.c
View file @
6662b1bb
...
...
@@ -127,7 +127,7 @@ VCL_IP
vmod_ip
(
const
struct
vrt_ctx
*
ctx
,
VCL_STRING
s
,
VCL_IP
d
)
{
struct
addrinfo
hints
,
*
res0
=
NULL
;
const
struct
addrinfo
*
res
,
*
best
=
NULL
;
const
struct
addrinfo
*
res
;
int
error
;
void
*
p
;
struct
suckaddr
*
r
;
...
...
@@ -136,6 +136,10 @@ vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d)
AN
(
d
);
assert
(
VSA_Sane
(
d
));
p
=
WS_Alloc
(
ctx
->
ws
,
vsa_suckaddr_len
);
AN
(
p
);
r
=
NULL
;
if
(
s
!=
NULL
)
{
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
PF_UNSPEC
;
...
...
@@ -143,19 +147,13 @@ vmod_ip(const struct vrt_ctx *ctx, VCL_STRING s, VCL_IP d)
error
=
getaddrinfo
(
s
,
"80"
,
&
hints
,
&
res0
);
if
(
!
error
)
{
for
(
res
=
res0
;
res
!=
NULL
;
res
=
res
->
ai_next
)
{
if
(
VSA_Sane
(
res
->
ai_addr
)
&&
res
->
ai_addrlen
>=
VSA_Len
(
res
->
ai_addr
))
{
best
=
res
;
r
=
VSA_Build
(
p
,
res
->
ai_addr
,
res
->
ai_addrlen
);
if
(
r
!=
NULL
)
break
;
}
}
}
}
p
=
WS_Alloc
(
ctx
->
ws
,
vsa_suckaddr_len
);
AN
(
p
);
if
(
best
!=
NULL
)
r
=
VSA_Build
(
p
,
best
->
ai_addr
,
best
->
ai_addrlen
);
else
{
if
(
r
==
NULL
)
{
r
=
p
;
memcpy
(
r
,
d
,
vsa_suckaddr_len
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment