Skip to content

Commit 974eed0

Browse files
committed
sanity checks for port number in CheckSetup() is added
1 parent 5efd5c1 commit 974eed0

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

vpr/src/base/CheckSetup.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
void CheckSetup(const t_packer_opts& PackerOpts,
1111
const t_placer_opts& PlacerOpts,
1212
const t_router_opts& RouterOpts,
13+
const t_server_opts& ServerOpts,
1314
const t_det_routing_arch& RoutingArch,
1415
const std::vector<t_segment_inf>& Segments,
1516
const t_timing_inf Timing,
@@ -99,4 +100,12 @@ void CheckSetup(const t_packer_opts& PackerOpts,
99100
"Place channel width must be even for unidirectional.\n");
100101
}
101102
}
103+
104+
if (ServerOpts.is_server_mode_enabled) {
105+
if (ServerOpts.port_num < DYMANIC_PORT_RANGE_MIN || ServerOpts.port_num > DYNAMIC_PORT_RANGE_MAX) {
106+
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
107+
"Specified server port number `--port %d` is out of range [%d-%d]. Please specify a port number within that range.\n",
108+
ServerOpts.port_num, DYMANIC_PORT_RANGE_MIN, DYNAMIC_PORT_RANGE_MAX);
109+
}
110+
}
102111
}

vpr/src/base/CheckSetup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
#define CHECKSETUP_H
33
#include "vpr_types.h"
44

5+
const int DYMANIC_PORT_RANGE_MIN = 49152;
6+
const int DYNAMIC_PORT_RANGE_MAX = 65535;
7+
58
void CheckSetup(const t_packer_opts& PackerOpts,
69
const t_placer_opts& PlacerOpts,
710
const t_router_opts& RouterOpts,
11+
const t_server_opts& ServerOpts,
812
const t_det_routing_arch& RoutingArch,
913
const std::vector<t_segment_inf>& Segments,
1014
const t_timing_inf Timing,

vpr/src/base/vpr_api.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ void vpr_init_with_options(const t_options* options, t_vpr_setup* vpr_setup, t_a
315315
CheckSetup(vpr_setup->PackerOpts,
316316
vpr_setup->PlacerOpts,
317317
vpr_setup->RouterOpts,
318+
vpr_setup->ServerOpts,
318319
vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing, arch->Chans);
319320

320321
/* flush any messages to user still in stdout that hasn't gotten displayed */
@@ -1333,11 +1334,12 @@ void vpr_check_arch(const t_arch& Arch) {
13331334
void vpr_check_setup(const t_packer_opts& PackerOpts,
13341335
const t_placer_opts& PlacerOpts,
13351336
const t_router_opts& RouterOpts,
1337+
const t_server_opts& ServerOpts,
13361338
const t_det_routing_arch& RoutingArch,
13371339
const std::vector<t_segment_inf>& Segments,
13381340
const t_timing_inf& Timing,
13391341
const t_chan_width_dist& Chans) {
1340-
CheckSetup(PackerOpts, PlacerOpts, RouterOpts, RoutingArch,
1342+
CheckSetup(PackerOpts, PlacerOpts, RouterOpts, ServerOpts, RoutingArch,
13411343
Segments, Timing, Chans);
13421344
}
13431345

vpr/src/base/vpr_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void vpr_check_arch(const t_arch& Arch);
198198
void vpr_check_setup(const t_packer_opts& PackerOpts,
199199
const t_placer_opts& PlacerOpts,
200200
const t_router_opts& RouterOpts,
201+
const t_server_opts& ServerOpts,
201202
const t_det_routing_arch& RoutingArch,
202203
const std::vector<t_segment_inf>& Segments,
203204
const t_timing_inf& Timing,

0 commit comments

Comments
 (0)