bfcp: set source address in bfcp_msg_decode()
This commit is contained in:
parent
0ed89f31f4
commit
5450209a83
3 changed files with 9 additions and 16 deletions
|
@ -185,7 +185,8 @@ int bfcp_msg_vencode(struct mbuf *mb, enum bfcp_prim prim,
|
|||
uint32_t attrc, va_list ap);
|
||||
int bfcp_msg_encode(struct mbuf *mb, enum bfcp_prim prim, uint32_t confid,
|
||||
uint16_t tid, uint16_t userid, uint32_t attrc, ...);
|
||||
int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb);
|
||||
int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb,
|
||||
const struct sa *src);
|
||||
struct bfcp_attr *bfcp_msg_attr(const struct bfcp_msg *msg,
|
||||
enum bfcp_attrib type);
|
||||
struct bfcp_attr *bfcp_msg_attr_apply(const struct bfcp_msg *msg,
|
||||
|
@ -195,7 +196,6 @@ enum bfcp_prim bfcp_msg_prim(const struct bfcp_msg *msg);
|
|||
uint32_t bfcp_msg_confid(const struct bfcp_msg *msg);
|
||||
uint16_t bfcp_msg_tid(const struct bfcp_msg *msg);
|
||||
uint16_t bfcp_msg_userid(const struct bfcp_msg *msg);
|
||||
void bfcp_msg_set_src(struct bfcp_msg *msg, const struct sa *src);
|
||||
const struct sa *bfcp_msg_src(const struct bfcp_msg *msg);
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,8 @@ int bfcp_msg_encode(struct mbuf *mb, enum bfcp_prim prim, uint32_t confid,
|
|||
}
|
||||
|
||||
|
||||
int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb)
|
||||
int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb,
|
||||
const struct sa *src)
|
||||
{
|
||||
struct bfcp_msg *msg;
|
||||
size_t start, extra;
|
||||
|
@ -117,6 +118,9 @@ int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb)
|
|||
list_append(&msg->attrl, &attr->le, attr);
|
||||
}
|
||||
|
||||
if (src)
|
||||
msg->src = *src;
|
||||
|
||||
out:
|
||||
if (err)
|
||||
mem_deref(msg);
|
||||
|
@ -129,7 +133,7 @@ int bfcp_msg_decode(struct bfcp_msg **msgp, struct mbuf *mb)
|
|||
|
||||
static bool attr_match(const struct bfcp_attr *attr, void *arg)
|
||||
{
|
||||
return attr->type == *(uint8_t *)arg;
|
||||
return attr->type == *(enum bfcp_attrib *)arg;
|
||||
}
|
||||
|
||||
|
||||
|
@ -245,15 +249,6 @@ const char *bfcp_prim_name(enum bfcp_prim prim)
|
|||
}
|
||||
|
||||
|
||||
void bfcp_msg_set_src(struct bfcp_msg *msg, const struct sa *src)
|
||||
{
|
||||
if (!msg || !src)
|
||||
return;
|
||||
|
||||
msg->src = *src;
|
||||
}
|
||||
|
||||
|
||||
const struct sa *bfcp_msg_src(const struct bfcp_msg *msg)
|
||||
{
|
||||
return msg ? &msg->src : NULL;
|
||||
|
|
|
@ -126,7 +126,7 @@ static void tcp_recv_handler(struct mbuf *mb, void *arg)
|
|||
|
||||
pos = conn->mbrx->pos;
|
||||
|
||||
err = bfcp_msg_decode(&msg, conn->mbrx);
|
||||
err = bfcp_msg_decode(&msg, conn->mbrx, &conn->paddr);
|
||||
if (err) {
|
||||
if (err == ENODATA) {
|
||||
conn->mbrx->pos = pos;
|
||||
|
@ -135,8 +135,6 @@ static void tcp_recv_handler(struct mbuf *mb, void *arg)
|
|||
break;
|
||||
}
|
||||
|
||||
bfcp_msg_set_src(msg, &conn->paddr);
|
||||
|
||||
ct = bfcp_ctrans_find(conn->bs, bfcp_msg_tid(msg));
|
||||
if (ct) {
|
||||
bfcp_ctrans_completed(ct, 0, msg);
|
||||
|
|
Loading…
Add table
Reference in a new issue