Commit 36134017 authored by Joanne Hugé's avatar Joanne Hugé

Add an option to set packet priority

parent ba1c0eea
......@@ -50,6 +50,7 @@ typedef struct thread_param {
typedef struct main_param {
int refresh_rate;
int packet_priority;
} main_param_t;
static inline void add_ns(struct timespec *t, uint64_t ns);
......@@ -116,11 +117,12 @@ int main(int argc, char *argv[]) {
param.enable_etf = 0;
main_param.refresh_rate = 50000;
main_param.packet_priority = 3;
// Process bash options
process_options(argc, argv, &param, &main_param);
init_udp_etf(param.enable_etf, param.network_if);
init_udp_etf(param.enable_etf, main_param.packet_priority, param.network_if);
usleep(10000);
......@@ -144,7 +146,7 @@ int main(int argc, char *argv[]) {
static void process_options(int argc, char *argv[], thread_param_t *param,
main_param_t *main_param) {
for (;;) {
int c = getopt(argc, argv, "aef:i:l:p:r:");
int c = getopt(argc, argv, "aef:i:l:p:q:r:");
if (c == -1) break;
......@@ -167,6 +169,9 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
case 'p':
param->priority = atoi(optarg);
break;
case 'q':
main_param->packet_priority = atoi(optarg);
break;
case 'r':
main_param->refresh_rate = atoi(optarg);
break;
......
......@@ -114,9 +114,11 @@ static int set_if(char *network_if) {
/*
* Init UDP socket
*/
void init_udp_etf(int use_etf, char *network_if) {
void init_udp_etf(int use_etf, int packet_priority, char *network_if) {
int index;
so_priority = packet_priority;
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) error(EXIT_FAILURE, errno, "Socket creation failed\n");
......
......@@ -4,7 +4,7 @@
#include <stdint.h>
int send_udp_packet(const char *ip4);
void init_udp_etf(int use_etf, char * network_if);
void init_udp_etf(int use_etf, int so_priority, char * network_if);
void send_udp_packet_etf(int use_etf, uint64_t txtime, const char *server_ip);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment