#include "stdint.h"
#include <stdlib.h>
#include <string.h>
#include "dn_additional.h"
#include "dn_common.h"
#include "dn_device.h"
#include "dn_tcp.h"
#include "dn_udp.h"
#include "dn_com.h"
#include "dn_thread.h"
#include "bcap_common.h"
#include "bcap_mapid.h"
#include "bcap_server.h"
Go to the source code of this file.
Classes | |
struct | CONN_BCAP_SERVER |
b-CAP server communication object. More... | |
struct | VEC_OBJECT |
A vector for stacking created objects. More... | |
Macros | |
#define | _BCAP_SERVER_MAX (BCAP_TCP_MAX + BCAP_UDP_MAX + BCAP_COM_MAX) |
A definition for the maximum count of servers. More... | |
#define | _FUNCTION_ID_MAX (137 + 1) |
A definition for the maximum count of b-CAP function IDs. More... | |
Enumerations | |
enum | CHANGE_RELATION { ADD_CHILD, DELETE_CHILD, DESTROY_SELF } |
change relation information. More... | |
Functions | |
static THRET THTYPE | accept_thread (void *arg) |
The accepting thread for TCP connection. More... | |
static HRESULT | bcap_callfunc (struct BCAP_PACKET *recv_packet, struct BCAP_PACKET *send_packet) |
Execute a callback function with the received b-CAP command. More... | |
HRESULT | bCap_Close_Server (int *pfd) |
Ends b-CAP server. More... | |
HRESULT | bCap_Open_Server (const char *connect, uint32_t timeout, int *pfd) |
Starts b-CAP server. More... | |
HRESULT | bCap_SetCallFunc (int32_t id, CALL_FUNC_BCAP func) |
Sets a callback function. More... | |
static HRESULT | change_relation (struct CONN_BCAP_SERVER *own, int mode, int *sock) |
Changes thread's relationships for TCP connection. More... | |
static struct CONN_BCAP_SERVER * | check_address (int index) |
Checks whether the index has been used or not. More... | |
static int | check_lifelimit (struct CONN_BCAP_SERVER *parent) |
Checks the life limit all of child nodes, and if expired then deletes. More... | |
static THRET THTYPE | exec_thread (void *arg) |
The executing thread. More... | |
static int | find_open_address (int type) |
Returns the open address of m_conn_param. More... | |
static HRESULT | pop_vector (struct CONN_BCAP_SERVER *bcap_param, struct VEC_OBJECT **pObj, int index) |
Pops the object where is in the indicated index from the vector. More... | |
static HRESULT | push_vector (struct CONN_BCAP_SERVER *bcap_param, struct VEC_OBJECT *pObj) |
Pushes the created object to the vector. More... | |
static HRESULT | receive_execute (struct CONN_BCAP_SERVER *bcap_param) |
Receives the b-CAP packet and executes callback functions. More... | |
static THRET THTYPE | recv_thread (void *arg) |
The receiving thread. More... | |
static struct CONN_BCAP_SERVER * | search_node (struct CONN_BCAP_SERVER *parent, const void *arg, int size) |
Searches the target node which has a specified argument. More... | |
static int | search_vector (struct CONN_BCAP_SERVER *bcap_param, int32_t id, uint32_t hObj) |
Searches the target object with function ID and object handle. More... | |
Variables | |
static struct CONN_BCAP_SERVER | m_conn_param [_BCAP_SERVER_MAX] |
static CALL_FUNC_BCAP | m_list_func [_FUNCTION_ID_MAX] |
#define _BCAP_SERVER_MAX (BCAP_TCP_MAX + BCAP_UDP_MAX + BCAP_COM_MAX) |
A definition for the maximum count of servers.
Software License Agreement (MIT License)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition at line 56 of file bcap_server.c.
#define _FUNCTION_ID_MAX (137 + 1) |
A definition for the maximum count of b-CAP function IDs.
Definition at line 62 of file bcap_server.c.
enum CHANGE_RELATION |
change relation information.
Enumerator | |
---|---|
ADD_CHILD | |
DELETE_CHILD |
Add a child |
DESTROY_SELF |
Delete all children |
Definition at line 68 of file bcap_server.c.
|
static |
The accepting thread for TCP connection.
[in] | arg | The argument of accepting thread: CONN_BCAP_SERVER. |
Definition at line 980 of file bcap_server.c.
|
static |
Execute a callback function with the received b-CAP command.
[in] | recv_packet | The received b-CAP packet. |
[in] | send_packet | The b-CAP packet to be sent. |
Definition at line 525 of file bcap_server.c.
HRESULT bCap_Close_Server | ( | int * | pfd | ) |
Ends b-CAP server.
[in,out] | pfd | The pointer of File descriptor. |
Definition at line 1184 of file bcap_server.c.
Starts b-CAP server.
[in] | timeout | Timeout value. |
[out] | pfd | The pointer of File descriptor. |
Definition at line 1056 of file bcap_server.c.
HRESULT bCap_SetCallFunc | ( | int32_t | id, |
CALL_FUNC_BCAP | func | ||
) |
Sets a callback function.
[in] | id | The b-CAP function ID. |
[in] | func | A callback function to be set. |
Definition at line 1044 of file bcap_server.c.
|
static |
Changes thread's relationships for TCP connection.
[in,out] | own | The connection parameter to be changed. |
[in] | mode | The change mode. |
[in] | sock | The client connection. |
Definition at line 315 of file bcap_server.c.
|
static |
Checks whether the index has been used or not.
[in] | index | The index of m_conn_param. |
Definition at line 165 of file bcap_server.c.
|
static |
Checks the life limit all of child nodes, and if expired then deletes.
[in] | parent | The server object. |
Definition at line 495 of file bcap_server.c.
|
static |
The executing thread.
[in] | arg | The argument of executing thread: CONN_BCAP_SERVER. |
Definition at line 841 of file bcap_server.c.
|
static |
Returns the open address of m_conn_param.
[in] | type | Connection type. |
Definition at line 127 of file bcap_server.c.
|
static |
Pops the object where is in the indicated index from the vector.
[in] | bcap_param | The server object. |
[out] | pObj | the poped object. |
[in] | index | The indicated index. |
Definition at line 217 of file bcap_server.c.
|
static |
Pushes the created object to the vector.
[in] | bcap_param | The server object. |
[in] | pObj | The created object to push. |
Definition at line 186 of file bcap_server.c.
|
static |
Receives the b-CAP packet and executes callback functions.
[in,out] | bcap_param | b-CAP communication object. |
Definition at line 560 of file bcap_server.c.
The receiving thread.
[in] | arg | The argument of receiving thread: CONN_BCAP_SERVER. |
Definition at line 880 of file bcap_server.c.
|
static |
Searches the target node which has a specified argument.
[in] | parent | The server object. |
[in] | arg | A specified argument. |
[in] | size | The size of argument. |
Definition at line 291 of file bcap_server.c.
|
static |
Searches the target object with function ID and object handle.
[in] | bcap_param | The server object. |
[in] | id | Function ID. |
[in] | hObj | Object handle. |
Definition at line 266 of file bcap_server.c.
|
static |
Definition at line 115 of file bcap_server.c.
|
static |
Definition at line 114 of file bcap_server.c.