Skip to content

Commit

Permalink
libknet: remove hardcoded magic numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Nov 17, 2012
1 parent 06b399d commit af5c4b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions kronosnetd/vty_cli_cmds.c
Expand Up @@ -948,7 +948,7 @@ static int knet_cmd_link(struct knet_vty *vty)
int paramlen = 0, paramoffset = 0, err = 0;
char *param = NULL;
int link_id;
char src_ipaddr[KNET_MAX_HOST_LEN], src_port[6], dst_ipaddr[KNET_MAX_HOST_LEN], dst_port[6];
char src_ipaddr[KNET_MAX_HOST_LEN], src_port[KNET_MAX_PORT_LEN], dst_ipaddr[KNET_MAX_HOST_LEN], dst_port[KNET_MAX_PORT_LEN];

get_param(vty, 1, &param, &paramlen, &paramoffset);
link_id = param_to_int(param, paramlen);
Expand All @@ -957,13 +957,13 @@ static int knet_cmd_link(struct knet_vty *vty)
param_to_str(src_ipaddr, KNET_MAX_HOST_LEN, param, paramlen);

memset(src_port, 0, sizeof(src_port));
snprintf(src_port, 6, "%d", knet_iface->cfg_ring.base_port + host->node_id);
snprintf(src_port, KNET_MAX_PORT_LEN, "%d", knet_iface->cfg_ring.base_port + host->node_id);

get_param(vty, 3, &param, &paramlen, &paramoffset);
param_to_str(dst_ipaddr, KNET_MAX_HOST_LEN, param, paramlen);

memset(dst_port, 0, sizeof(dst_port));
snprintf(dst_port, 6, "%d", knet_iface->cfg_ring.base_port + knet_iface->cfg_eth.node_id);
snprintf(dst_port, KNET_MAX_PORT_LEN, "%d", knet_iface->cfg_ring.base_port + knet_iface->cfg_eth.node_id);

klink = &host->link[link_id];
if (!klink->configured) {
Expand Down
7 changes: 4 additions & 3 deletions libknet/libknet.h
Expand Up @@ -12,6 +12,7 @@ typedef struct knet_handle *knet_handle_t;
#define KNET_MAX_HOST 65536
#define KNET_MAX_LINK 8
#define KNET_MAX_HOST_LEN 64
#define KNET_MAX_PORT_LEN 6

#define KNET_CBUFFER_SIZE 4096
/*
Expand All @@ -29,10 +30,10 @@ struct knet_link {
uint8_t link_id;
int listener_sock;
char src_ipaddr[KNET_MAX_HOST_LEN];
char src_port[6];
char src_port[KNET_MAX_PORT_LEN];
struct sockaddr_storage src_addr;
char dst_ipaddr[KNET_MAX_HOST_LEN];
char dst_port[6];
char dst_port[KNET_MAX_PORT_LEN];
struct sockaddr_storage dst_addr;
unsigned int configured:1; /* link is configured and ready to be used */
unsigned int connected:1; /* link is enabled for data */
Expand Down Expand Up @@ -76,7 +77,7 @@ struct knet_hinfo_link {
uint8_t khl_link_priority;
uint64_t khl_link_latency;
char khl_link_dst_ipaddr[KNET_MAX_HOST_LEN];
char khl_link_dst_port[6];
char khl_link_dst_port[KNET_MAX_PORT_LEN];
} __attribute__((packed));

struct knet_hinfo_link_table {
Expand Down

0 comments on commit af5c4b8

Please sign in to comment.