Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
7bd835d9
Commit
7bd835d9
authored
May 07, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean and rename client and server files
parent
471ae88b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
79 deletions
+31
-79
simple-client/src/client.c
simple-client/src/client.c
+31
-32
simple-client/src/getip.c
simple-client/src/getip.c
+0
-41
simple-client/src/getip.h
simple-client/src/getip.h
+0
-6
simple-server/src/server.c
simple-server/src/server.c
+0
-0
No files found.
simple-client/src/
main
.c
→
simple-client/src/
client
.c
View file @
7bd835d9
...
...
@@ -25,6 +25,8 @@ typedef struct thread_param {
thread_stat_t
stats
;
}
thread_param_t
;
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
);
// Real-time thread
// Sends packets at a regular intervall
...
...
@@ -60,6 +62,35 @@ static void *packet_sending_thread(void *p) {
return
NULL
;
}
// Main thread, has non-real time priority
// Handles the IO and creates real time threads
int
main
(
int
argc
,
char
*
argv
[])
{
pthread_t
thread
;
thread_param_t
param
;
// Default values
param
.
interval
=
1
;
param
.
max_cycles
=
-
1
;
param
.
priority
=
99
;
process_options
(
argc
,
argv
,
&
param
);
if
(
pthread_create
(
&
thread
,
NULL
,
packet_sending_thread
,
(
void
*
)
&
param
))
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create thread"
);
for
(;;)
{
usleep
(
100000
);
printf
(
"Nb cycles: %d
\n
"
,
param
.
stats
.
nb_cycles
);
if
(
param
.
max_cycles
==
param
.
stats
.
nb_cycles
)
break
;
}
exit
(
EXIT_SUCCESS
);
}
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
)
{
for
(;;)
{
...
...
@@ -92,35 +123,3 @@ static void process_options(int argc, char *argv[], thread_param_t * param) {
param
->
ip_address
=
argv
[
optind
];
}
// Main thread, has non-real time priority
// Handles the IO and creates real time threads
int
main
(
int
argc
,
char
*
argv
[])
{
pthread_t
thread
;
thread_param_t
param
;
// Default values
param
.
interval
=
1
;
param
.
max_cycles
=
-
1
;
param
.
priority
=
80
;
process_options
(
argc
,
argv
,
&
param
);
int
err
=
pthread_create
(
&
thread
,
NULL
,
packet_sending_thread
,
(
void
*
)
&
param
);
if
(
err
)
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create thread"
);
for
(;;)
{
usleep
(
100000
);
printf
(
"Nb cycles: %d
\n
"
,
param
.
stats
.
nb_cycles
);
if
(
param
.
max_cycles
==
param
.
stats
.
nb_cycles
)
break
;
}
exit
(
EXIT_SUCCESS
);
}
simple-client/src/getip.c
deleted
100644 → 0
View file @
471ae88b
#include "getip.h"
#include <ifaddrs.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void
print_ifs
(
void
)
{
struct
ifaddrs
*
ifap
;
getifaddrs
(
&
ifap
);
printf
(
"Interfaces:
\n\n
"
);
for
(
struct
ifaddrs
*
cur_ifap
=
ifap
;
cur_ifap
;
cur_ifap
=
cur_ifap
->
ifa_next
)
{
printf
(
"%s, "
,
cur_ifap
->
ifa_name
);
void
*
addr
;
char
*
ipver
;
char
ipstr
[
INET6_ADDRSTRLEN
];
struct
sockaddr
*
sa
=
cur_ifap
->
ifa_addr
;
if
(
sa
->
sa_family
==
AF_INET
)
{
// IPV4
struct
sockaddr_in
*
ipv4
=
(
struct
sockaddr_in
*
)
sa
;
addr
=
&
(
ipv4
->
sin_addr
);
ipver
=
"IPv4"
;
}
else
{
struct
sockaddr_in6
*
ipv6
=
(
struct
sockaddr_in6
*
)
sa
;
addr
=
&
(
ipv6
->
sin6_addr
);
ipver
=
"IPv6"
;
}
inet_ntop
(
sa
->
sa_family
,
addr
,
ipstr
,
sizeof
ipstr
);
printf
(
" %s: %s
\n
"
,
ipver
,
ipstr
);
}
freeifaddrs
(
ifap
);
}
simple-client/src/getip.h
deleted
100644 → 0
View file @
471ae88b
#ifndef GETIP_H
#define GETIP_H
void
print_ifs
(
void
);
#endif
simple-server/src/
main
.c
→
simple-server/src/
server
.c
View file @
7bd835d9
File moved
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