Skip to content

Commit

Permalink
Add functionality to enable libiwpm to provide the remote connecting
Browse files Browse the repository at this point in the history
peer address information to its clients
  • Loading branch information
tatyana-en committed Sep 23, 2014
1 parent f5de47f commit eee8aef
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 105 deletions.
9 changes: 7 additions & 2 deletions include/iwarp_pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ typedef struct iwpm_wire_msg {
/* big endian IP addresses and ports */
__u8 cpipaddr[IWPM_IPADDR_SIZE];
__u8 apipaddr[IWPM_IPADDR_SIZE];
__u8 mapped_cpipaddr[IWPM_IPADDR_SIZE];
} iwpm_wire_msg;

typedef struct iwpm_send_msg {
int pm_sock;
struct sockaddr_storage dest_addr;
iwpm_wire_msg data;
iwpm_wire_msg data;
int length;
} iwpm_send_msg;

typedef struct iwpm_mapping_request {
Expand Down Expand Up @@ -191,10 +193,13 @@ typedef struct iwpm_msg_parms {
__be16 apport;
char cpipaddr[IWPM_IPADDR_SIZE];
__be16 cpport;
char mapped_cpipaddr[IWPM_IPADDR_SIZE];
__be16 mapped_cpport;
unsigned char ver;
unsigned char mt;
unsigned char pmtime;
__u64 assochandle;
int msize;
} iwpm_msg_parms;

/* iwarp_pm_common.c */
Expand Down Expand Up @@ -263,7 +268,7 @@ int update_iwpm_map_request(__u64, struct sockaddr_storage *, int, iwpm_mapping_

void remove_iwpm_map_request(iwpm_mapping_request *);

void form_iwpm_send_msg(int, struct sockaddr_storage *, iwpm_send_msg *);
void form_iwpm_send_msg(int, struct sockaddr_storage *, int, iwpm_send_msg *);

int send_iwpm_msg(void (*form_msg_type)(iwpm_wire_msg *, iwpm_msg_parms *),
iwpm_msg_parms *, struct sockaddr_storage *, int);
Expand Down
2 changes: 1 addition & 1 deletion include/iwpm_netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum {
RDMA_NL_IWPM_ADD_MAPPING,
RDMA_NL_IWPM_QUERY_MAPPING,
RDMA_NL_IWPM_REMOVE_MAPPING,
RDMA_NL_IWPM_REMOTE_INFO,
RDMA_NL_IWPM_HANDLE_ERR,
RDMA_NL_IWPM_MAPINFO,
RDMA_NL_IWPM_MAPINFO_NUM,
Expand Down Expand Up @@ -72,7 +73,6 @@ enum {
IWPM_NLA_RREG_ULIB_VER,
IWPM_NLA_RREG_PID_ERR,
IWPM_NLA_RREG_PID_MAX

};

/* iwpm netlink manage mapping attributes */
Expand Down
13 changes: 12 additions & 1 deletion src/iwarp_pm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ int parse_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms)
memcpy(&msg_parms->apipaddr, &pm_msg->apipaddr, IWPM_IPADDR_SIZE);
/* copy connecting peer IP address */
memcpy(&msg_parms->cpipaddr, &pm_msg->cpipaddr, IWPM_IPADDR_SIZE);

if (msg_parms->mt == IWARP_PM_MT_REQ) {
msg_parms->mapped_cpport = pm_msg->reserved;
memcpy(&msg_parms->mapped_cpipaddr, &pm_msg->mapped_cpipaddr, IWPM_IPADDR_SIZE);
}
return ret_value;
}

Expand All @@ -364,6 +367,10 @@ static void form_iwpm_msg(iwpm_wire_msg *pm_msg, iwpm_msg_parms *msg_parms)
pm_msg->cpport = msg_parms->cpport;
memcpy(&pm_msg->apipaddr, &msg_parms->apipaddr, IWPM_IPADDR_SIZE);
memcpy(&pm_msg->cpipaddr, &msg_parms->cpipaddr, IWPM_IPADDR_SIZE);
if (msg_parms->mt == IWARP_PM_MT_REQ) {
pm_msg->reserved = msg_parms->mapped_cpport;
memcpy(&pm_msg->mapped_cpipaddr, &msg_parms->mapped_cpipaddr, IWPM_IPADDR_SIZE);
}
}

/**
Expand All @@ -375,6 +382,7 @@ void form_iwpm_request(struct iwpm_wire_msg *pm_msg,
struct iwpm_msg_parms *msg_parms)
{
msg_parms->mt = IWARP_PM_MT_REQ;
msg_parms->msize = IWARP_PM_MESSAGE_SIZE + IWPM_IPADDR_SIZE;
form_iwpm_msg(pm_msg, msg_parms);
}

Expand All @@ -387,6 +395,7 @@ void form_iwpm_accept(struct iwpm_wire_msg *pm_msg,
struct iwpm_msg_parms *msg_parms)
{
msg_parms->mt = IWARP_PM_MT_ACC;
msg_parms->msize = IWARP_PM_MESSAGE_SIZE;
form_iwpm_msg(pm_msg, msg_parms);
}

Expand All @@ -399,6 +408,7 @@ void form_iwpm_ack(struct iwpm_wire_msg *pm_msg,
struct iwpm_msg_parms *msg_parms)
{
msg_parms->mt = IWARP_PM_MT_ACK;
msg_parms->msize = IWARP_PM_MESSAGE_SIZE;
form_iwpm_msg(pm_msg, msg_parms);
}

Expand All @@ -411,6 +421,7 @@ void form_iwpm_reject(struct iwpm_wire_msg *pm_msg,
struct iwpm_msg_parms *msg_parms)
{
msg_parms->mt = IWARP_PM_MT_REJ;
msg_parms->msize = IWARP_PM_MESSAGE_SIZE;
form_iwpm_msg(pm_msg, msg_parms);
}

Expand Down
6 changes: 4 additions & 2 deletions src/iwarp_pm_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int send_iwpm_msg(void (*form_msg_type)(iwpm_wire_msg *, iwpm_msg_parms *),
iwpm_send_msg send_msg;

form_msg_type(&send_msg.data, msg_parms);
form_iwpm_send_msg(send_sock, recv_addr, &send_msg);
form_iwpm_send_msg(send_sock, recv_addr, msg_parms->msize, &send_msg);
return add_iwpm_pending_msg(&send_msg);
}

Expand Down Expand Up @@ -588,9 +588,11 @@ void print_iwpm_mapped_ports(iwpm_mapped_port *iwpm_ports)
/**
* form_iwpm_send_msg - Form a message to send on the wire
*/
void form_iwpm_send_msg(int pm_sock, struct sockaddr_storage *dest, iwpm_send_msg *send_msg)
void form_iwpm_send_msg(int pm_sock, struct sockaddr_storage *dest,
int length, iwpm_send_msg *send_msg)
{
send_msg->pm_sock = pm_sock;
send_msg->length = length;
memcpy(&send_msg->dest_addr, dest, sizeof(send_msg->dest_addr));
}

Expand Down

0 comments on commit eee8aef

Please sign in to comment.