summaryrefslogtreecommitdiff
path: root/profiles
diff options
context:
space:
mode:
authorGrzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>2015-03-03 17:59:47 +0100
committerSzymon Janc <szymon.janc@tieto.com>2015-03-09 16:04:11 +0100
commit38a7f19f04d70eec714fc6a4af9f367a68ff68b1 (patch)
treefcff716229359ab870a1d78bec234ef02e434ed9 /profiles
parent703e2b9b856429a5ba3fd4c9c85571fc4c515586 (diff)
downloadbluez-38a7f19f04d70eec714fc6a4af9f367a68ff68b1.tar.gz
profiles/network: Integrate get and check bnep setup services roles
While bnep setup, roles must be determined and checked if the connection scanario is possible. Get and check possible service roles routines are always performed in serie. So there is no need to split it to separate calls.
Diffstat (limited to 'profiles')
-rw-r--r--profiles/network/bnep.c37
-rw-r--r--profiles/network/bnep.h1
-rw-r--r--profiles/network/server.c6
3 files changed, 17 insertions, 27 deletions
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index b3c617967..7d7857504 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -591,26 +591,6 @@ ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp)
return send(sk, &rsp, sizeof(rsp), 0);
}
-uint16_t bnep_setup_chk(uint16_t dst, uint16_t src)
-{
- /* Allowed PAN Profile scenarios */
- switch (dst) {
- case BNEP_SVC_NAP:
- case BNEP_SVC_GN:
- if (src == BNEP_SVC_PANU)
- return 0;
- return BNEP_CONN_INVALID_SRC;
- case BNEP_SVC_PANU:
- if (src == BNEP_SVC_PANU || src == BNEP_SVC_GN ||
- src == BNEP_SVC_NAP)
- return 0;
-
- return BNEP_CONN_INVALID_SRC;
- }
-
- return BNEP_CONN_INVALID_DST;
-}
-
uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
uint16_t *src)
{
@@ -655,5 +635,20 @@ uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
return BNEP_CONN_INVALID_SVC;
}
- return BNEP_SUCCESS;
+ /* Allowed PAN Profile scenarios */
+ switch (*dst) {
+ case BNEP_SVC_NAP:
+ case BNEP_SVC_GN:
+ if (*src == BNEP_SVC_PANU)
+ return BNEP_SUCCESS;
+ return BNEP_CONN_INVALID_SRC;
+ case BNEP_SVC_PANU:
+ if (*src == BNEP_SVC_PANU || *src == BNEP_SVC_GN ||
+ *src == BNEP_SVC_NAP)
+ return BNEP_SUCCESS;
+
+ return BNEP_CONN_INVALID_SRC;
+ }
+
+ return BNEP_CONN_INVALID_DST;
}
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index bc43d4fa6..5aedf38f8 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -46,6 +46,5 @@ int bnep_server_add(int sk, uint16_t dst, char *bridge, char *iface,
void bnep_server_delete(char *bridge, char *iface, const bdaddr_t *addr);
ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
-uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role);
uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
uint16_t *src);
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 332525ef2..04f188a81 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -324,11 +324,7 @@ static gboolean bnep_setup(GIOChannel *chan,
return FALSE;
rsp = bnep_setup_decode(req, &dst_role, &src_role);
- if (rsp)
- goto reply;
-
- rsp = bnep_setup_chk(dst_role, src_role);
- if (rsp)
+ if (rsp != BNEP_SUCCESS)
goto reply;
rsp = BNEP_CONN_NOT_ALLOWED;