forked from nuttx/nuttx-update
rpmsg_socket: add prefix "rpmsg-socket" for the name of rpmsg endpoint
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
a39fb6bc7a
commit
ce4b79d554
1 changed files with 11 additions and 5 deletions
|
@ -50,6 +50,7 @@
|
|||
|
||||
#define RPMSG_SOCKET_CMD_SYNC 1
|
||||
#define RPMSG_SOCKET_CMD_DATA 2
|
||||
#define RPMSG_SOCKET_NAME_PREFIX "rpmsg-socket"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
|
@ -406,6 +407,7 @@ static void rpmsg_socket_device_created(FAR struct rpmsg_device *rdev,
|
|||
FAR void *priv)
|
||||
{
|
||||
FAR struct rpmsg_socket_conn_s *conn = priv;
|
||||
char buf[RPMSG_SOCKET_NAME_SIZE];
|
||||
|
||||
if (conn->ept.rdev)
|
||||
{
|
||||
|
@ -415,8 +417,10 @@ static void rpmsg_socket_device_created(FAR struct rpmsg_device *rdev,
|
|||
if (strcmp(conn->rpaddr.rp_cpu, rpmsg_get_cpuname(rdev)) == 0)
|
||||
{
|
||||
conn->ept.priv = conn;
|
||||
snprintf(buf, sizeof(buf), "%s:%s", RPMSG_SOCKET_NAME_PREFIX,
|
||||
conn->rpaddr.rp_name);
|
||||
|
||||
rpmsg_create_ept(&conn->ept, rdev, conn->rpaddr.rp_name,
|
||||
rpmsg_create_ept(&conn->ept, rdev, buf,
|
||||
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
||||
rpmsg_socket_ept_cb, rpmsg_socket_ns_unbind);
|
||||
}
|
||||
|
@ -453,11 +457,13 @@ static void rpmsg_socket_ns_bind(FAR struct rpmsg_device *rdev,
|
|||
FAR struct rpmsg_socket_conn_s *server = priv;
|
||||
FAR struct rpmsg_socket_conn_s *tmp;
|
||||
FAR struct rpmsg_socket_conn_s *new;
|
||||
char buf[RPMSG_SOCKET_NAME_SIZE];
|
||||
int cnt = 0;
|
||||
int ret;
|
||||
|
||||
if (strncmp(name, server->rpaddr.rp_name,
|
||||
strlen(server->rpaddr.rp_name)))
|
||||
snprintf(buf, sizeof(buf), "%s:%s", RPMSG_SOCKET_NAME_PREFIX,
|
||||
server->rpaddr.rp_name);
|
||||
if (strncmp(name, buf, strlen(buf)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -555,8 +561,8 @@ static int rpmsg_socket_setaddr(FAR struct rpmsg_socket_conn_s *conn,
|
|||
|
||||
rpaddr = &conn->rpaddr;
|
||||
len = strlen(rpaddr->rp_name);
|
||||
snprintf(&rpaddr->rp_name[len], RPMSG_SOCKET_NAME_SIZE - len - 1,
|
||||
"%u", g_rpmsg_id++);
|
||||
snprintf(&rpaddr->rp_name[len], sizeof(rpaddr->rp_name) - len - 1,
|
||||
":%u", g_rpmsg_id++);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue