Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Packetdrill_tarr_ext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Gense
Packetdrill_tarr_ext
Commits
47948322
Commit
47948322
authored
9 years ago
by
Michael Tüxen
Browse files
Options
Downloads
Patches
Plain Diff
Get things compiling on FreeBSD (64 bit).
parent
341816b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gtests/net/packetdrill/run_system_call.c
+47
-7
47 additions, 7 deletions
gtests/net/packetdrill/run_system_call.c
with
47 additions
and
7 deletions
gtests/net/packetdrill/run_system_call.c
+
47
−
7
View file @
47948322
...
@@ -229,6 +229,26 @@ static int check_type(struct expression *expression,
...
@@ -229,6 +229,26 @@ static int check_type(struct expression *expression,
}
}
}
}
/* Sets the value from the expression argument, checking that it is a
* valid size_t, and matches the expected type. Returns STATUS_OK on
* success; on failure returns STATUS_ERR and sets error message.
*/
static
int
get_socklen_t
(
struct
expression
*
expression
,
socklen_t
*
value
,
char
**
error
)
{
if
(
check_type
(
expression
,
EXPR_INTEGER
,
error
))
return
STATUS_ERR
;
if
(
expression
->
value
.
num
<
0
)
{
asprintf
(
error
,
"Value out of range for socklen_t: %lld"
,
expression
->
value
.
num
);
return
STATUS_ERR
;
}
*
value
=
expression
->
value
.
num
;
return
STATUS_OK
;
}
#ifdef linux
/* Sets the value from the expression argument, checking that it is a
/* Sets the value from the expression argument, checking that it is a
* valid size_t, and matches the expected type. Returns STATUS_OK on
* valid size_t, and matches the expected type. Returns STATUS_OK on
* success; on failure returns STATUS_ERR and sets error message.
* success; on failure returns STATUS_ERR and sets error message.
...
@@ -247,6 +267,7 @@ static int get_size_t(struct expression *expression,
...
@@ -247,6 +267,7 @@ static int get_size_t(struct expression *expression,
*
value
=
expression
->
value
.
num
;
*
value
=
expression
->
value
.
num
;
return
STATUS_OK
;
return
STATUS_OK
;
}
}
#endif
/* Sets the value from the expression argument, checking that it is a
/* Sets the value from the expression argument, checking that it is a
* valid u32, and matches the expected type. Returns STATUS_OK on
* valid u32, and matches the expected type. Returns STATUS_OK on
...
@@ -618,6 +639,21 @@ int check_u32_expr(struct expression *expr, u32 value, char *val_name, char **er
...
@@ -618,6 +639,21 @@ int check_u32_expr(struct expression *expr, u32 value, char *val_name, char **er
return
STATUS_OK
;
return
STATUS_OK
;
}
}
int
check_socklen_t_expr
(
struct
expression
*
expr
,
socklen_t
value
,
char
*
val_name
,
char
**
error
)
{
if
(
expr
->
type
!=
EXPR_ELLIPSIS
)
{
socklen_t
script_val
;
if
(
get_socklen_t
(
expr
,
&
script_val
,
error
))
{
return
STATUS_ERR
;
}
if
(
script_val
!=
value
)
{
asprintf
(
error
,
"%s: expected: %u actual: %u"
,
val_name
,
script_val
,
value
);
return
STATUS_ERR
;
}
}
return
STATUS_OK
;
}
#if defined(__FreeBSD__) || defined(linux)
#if defined(__FreeBSD__) || defined(linux)
static
int
check_u8array_expr
(
struct
expression
*
expr_list
,
u8
*
data
,
size_t
data_len
,
char
*
val_name
,
char
**
error
)
{
static
int
check_u8array_expr
(
struct
expression
*
expr_list
,
u8
*
data
,
size_t
data_len
,
char
*
val_name
,
char
**
error
)
{
if
(
expr_list
->
type
!=
EXPR_ELLIPSIS
)
{
if
(
expr_list
->
type
!=
EXPR_ELLIPSIS
)
{
...
@@ -739,7 +775,7 @@ error_out:
...
@@ -739,7 +775,7 @@ error_out:
* STATUS_ERR.
* STATUS_ERR.
*/
*/
static
int
cmsg_new
(
struct
expression
*
expression
,
static
int
cmsg_new
(
struct
expression
*
expression
,
void
**
cmsg_ptr
,
s
ize
_t
*
cmsg_len_ptr
,
void
**
cmsg_ptr
,
s
ocklen
_t
*
cmsg_len_ptr
,
bool
send
,
char
**
error
)
bool
send
,
char
**
error
)
{
{
struct
expression_list
*
list
;
struct
expression_list
*
list
;
...
@@ -815,7 +851,7 @@ static int cmsg_new(struct expression *expression,
...
@@ -815,7 +851,7 @@ static int cmsg_new(struct expression *expression,
return
STATUS_ERR
;
return
STATUS_ERR
;
}
}
}
}
*
cmsg_len_ptr
=
cmsg_size
;
*
cmsg_len_ptr
=
(
socklen_t
)
cmsg_size
;
cmsg
=
calloc
(
1
,
cmsg_size
);
cmsg
=
calloc
(
1
,
cmsg_size
);
*
cmsg_ptr
=
(
void
*
)
cmsg
;
*
cmsg_ptr
=
(
void
*
)
cmsg
;
...
@@ -827,7 +863,7 @@ static int cmsg_new(struct expression *expression,
...
@@ -827,7 +863,7 @@ static int cmsg_new(struct expression *expression,
if
(
check_type
(
expr
,
EXPR_CMSGHDR
,
error
))
if
(
check_type
(
expr
,
EXPR_CMSGHDR
,
error
))
goto
error_out
;
goto
error_out
;
cmsg_expr
=
expr
->
value
.
cmsghdr
;
cmsg_expr
=
expr
->
value
.
cmsghdr
;
if
(
get_s
ize
_t
(
cmsg_expr
->
cmsg_len
,
&
cmsg
->
cmsg_len
,
error
))
if
(
get_s
ocklen
_t
(
cmsg_expr
->
cmsg_len
,
&
cmsg
->
cmsg_len
,
error
))
goto
error_out
;
goto
error_out
;
if
(
get_s32
(
cmsg_expr
->
cmsg_level
,
&
cmsg
->
cmsg_level
,
error
))
if
(
get_s32
(
cmsg_expr
->
cmsg_level
,
&
cmsg
->
cmsg_level
,
error
))
goto
error_out
;
goto
error_out
;
...
@@ -951,8 +987,8 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char
...
@@ -951,8 +987,8 @@ static int check_cmsghdr(struct expression *expr_list, struct msghdr *msg, char
if
(
check_s32_expr
(
expr
->
cmsg_type
,
cmsg_ptr
->
cmsg_type
,
if
(
check_s32_expr
(
expr
->
cmsg_type
,
cmsg_ptr
->
cmsg_type
,
"cmsghdr.cmsg_type"
,
error
))
"cmsghdr.cmsg_type"
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
(
check_
u32
_expr
(
expr
->
cmsg_len
,
cmsg_ptr
->
cmsg_len
,
if
(
check_
socklen_t
_expr
(
expr
->
cmsg_len
,
cmsg_ptr
->
cmsg_len
,
"cmsghdr.cmsg_len"
,
error
))
"cmsghdr.cmsg_len"
,
error
))
return
STATUS_ERR
;
return
STATUS_ERR
;
if
(
check_s32_expr
(
expr
->
cmsg_level
,
cmsg_ptr
->
cmsg_level
,
if
(
check_s32_expr
(
expr
->
cmsg_level
,
cmsg_ptr
->
cmsg_level
,
"cmsghdr.cmsg_level"
,
error
))
"cmsghdr.cmsg_level"
,
error
))
...
@@ -1106,7 +1142,7 @@ static int msghdr_new(struct expression *expression,
...
@@ -1106,7 +1142,7 @@ static int msghdr_new(struct expression *expression,
struct
msghdr_expr
*
msg_expr
;
/* input expression from script */
struct
msghdr_expr
*
msg_expr
;
/* input expression from script */
socklen_t
name_len
=
sizeof
(
struct
sockaddr_storage
);
socklen_t
name_len
=
sizeof
(
struct
sockaddr_storage
);
struct
msghdr
*
msg
=
NULL
;
/* live output */
struct
msghdr
*
msg
=
NULL
;
/* live output */
s
ize
_t
cmsg_len
=
0
;
s
ocklen
_t
cmsg_len
=
0
;
if
(
check_type
(
expression
,
EXPR_MSGHDR
,
error
))
if
(
check_type
(
expression
,
EXPR_MSGHDR
,
error
))
goto
error_out
;
goto
error_out
;
...
@@ -1150,14 +1186,18 @@ static int msghdr_new(struct expression *expression,
...
@@ -1150,14 +1186,18 @@ static int msghdr_new(struct expression *expression,
}
}
if
(
msg_expr
->
msg_controllen
!=
NULL
)
{
if
(
msg_expr
->
msg_controllen
!=
NULL
)
{
#ifdef linux
if
(
get_size_t
(
msg_expr
->
msg_controllen
,
&
msg
->
msg_controllen
,
error
))
if
(
get_size_t
(
msg_expr
->
msg_controllen
,
&
msg
->
msg_controllen
,
error
))
#else
if
(
get_socklen_t
(
msg_expr
->
msg_controllen
,
&
msg
->
msg_controllen
,
error
))
#endif
goto
error_out
;
goto
error_out
;
}
}
if
(
msg
->
msg_controllen
!=
cmsg_len
)
{
if
(
msg
->
msg_controllen
!=
cmsg_len
)
{
asprintf
(
error
,
asprintf
(
error
,
"msg_controllen %zu does not match %zu size of cmsghdr array"
,
"msg_controllen %zu does not match %zu size of cmsghdr array"
,
msg
->
msg_controllen
,
cmsg_len
);
(
size_t
)
msg
->
msg_controllen
,
(
size_t
)
cmsg_len
);
goto
error_out
;
goto
error_out
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment