added internal channel ops;
This commit is contained in:
parent
7b025730d7
commit
f142cd3f6f
@ -14,7 +14,7 @@ lib_LTLIBRARIES = libsntllv2.la
|
|||||||
|
|
||||||
|
|
||||||
libsntllv2_la_SOURCES = \
|
libsntllv2_la_SOURCES = \
|
||||||
connex.c sntllv2.c
|
connex.c sntllv2.c chansx.c
|
||||||
|
|
||||||
libsntllv2_la_LDFLAGS = -Wl,--export-dynamic
|
libsntllv2_la_LDFLAGS = -Wl,--export-dynamic
|
||||||
|
|
||||||
|
52
lib/chansx.c
52
lib/chansx.c
@ -43,8 +43,60 @@
|
|||||||
/* locally used functions */
|
/* locally used functions */
|
||||||
uint8_t _channel_open(conn_t *co, uint16_t *chid)
|
uint8_t _channel_open(conn_t *co, uint16_t *chid)
|
||||||
{
|
{
|
||||||
|
chnl_t *chan;
|
||||||
|
uint16_t typeid = *chid; /* our type */
|
||||||
|
uint16_t chidx;
|
||||||
|
usrtc_t *rpc_list = co->rpc_list;
|
||||||
|
usrtc_node_t *node;
|
||||||
|
rpc_typed_list_t *rlist;
|
||||||
|
cx_rpc_list_t *rpclist;
|
||||||
|
|
||||||
|
node = usrtc_lookup(rpc_list, (void *)&typeid);
|
||||||
|
if(!node) return SNE_EPERM;
|
||||||
|
else rlist = (rpc_typed_list_t *)usrtc_node_getdata(node);
|
||||||
|
|
||||||
|
if(rlist) rpclist = rlist->rpc_list;
|
||||||
|
else return SNE_FAILED;
|
||||||
|
|
||||||
|
chan = malloc(sizeof(chnl_t));
|
||||||
|
if(!chan) return SNE_ENOMEM;
|
||||||
|
|
||||||
|
/* init channel */
|
||||||
|
chan->connection = co;
|
||||||
|
chan->rpc_list = rpclist;
|
||||||
|
chan->flags = 0;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&co->idx_ch_lock);
|
||||||
|
chidx = idx_allocate(&co->idx_ch);
|
||||||
|
pthread_mutex_unlock(&co->idx_ch_lock);
|
||||||
|
|
||||||
|
if(chidx == IDX_INVAL) {
|
||||||
|
free(chan);
|
||||||
|
return SNE_MCHANNELS;
|
||||||
|
}
|
||||||
|
|
||||||
|
chan->cid = chidx;
|
||||||
|
co->channels[chidx] = chan;
|
||||||
|
*chid = chidx;
|
||||||
|
|
||||||
|
return SNE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t _channel_close(conn_t *co, uint16_t chid)
|
uint8_t _channel_close(conn_t *co, uint16_t chid)
|
||||||
{
|
{
|
||||||
|
chnl_t *chan;
|
||||||
|
|
||||||
|
if(chid > 512) return SNE_INVALINDEX;
|
||||||
|
else chan = co->channels[chid];
|
||||||
|
|
||||||
|
if(!chan) return SNE_NOSUCHCHAN;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&co->idx_ch_lock);
|
||||||
|
idx_free(&co->idx_ch, chid);
|
||||||
|
co->channels[chid] = NULL;
|
||||||
|
pthread_mutex_unlock(&co->idx_ch_lock);
|
||||||
|
|
||||||
|
free(chan);
|
||||||
|
|
||||||
|
return SNE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
8
lib/internal.h
Normal file
8
lib/internal.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __SNTLL_INTERNAL_H__
|
||||||
|
#define __SNTLL_INTERNAL_H__
|
||||||
|
|
||||||
|
/* channel operations */
|
||||||
|
uint8_t _channel_open(conn_t *co, uint16_t *chid);
|
||||||
|
uint8_t _channel_close(conn_t *co, uint16_t chid);
|
||||||
|
|
||||||
|
#endif /* __SNTLL_INTERNAL_H__ */
|
@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
#include <sntl/sntllv2.h>
|
#include <sntl/sntllv2.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct __sntll_bundle_type {
|
typedef struct __sntll_bundle_type {
|
||||||
void *buf;
|
void *buf;
|
||||||
conn_t *conn;
|
conn_t *conn;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user