Skip to content

Commit

Permalink
[libsock] fix compile dependency on libptcp
Browse files Browse the repository at this point in the history
  • Loading branch information
gozfree committed Sep 7, 2021
1 parent a0bac5a commit 13b1ca9
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 2,793 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BASIC_LIBS="libposix libtime liblog libdarray libthread libgevent libworkq libdi
librbtree libringbuffer libvector libbase64 libmedia-io \
libdebug libfile libconfig libuac libuvc libqueue libplugin libhal libsubmask"
FRAMEWORK_LIBS="libipc"
NETWORK_LIBS="libsock librpc librtsp librtmpc"
NETWORK_LIBS="libsock libptcp librpc librtsp librtmpc"

usage()
{
Expand Down
32 changes: 18 additions & 14 deletions gear-lib/libp2p/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ TGT_LIB_H = $(LIBNAME).h
TGT_LIB_A = $(LIBNAME).a
TGT_LIB_SO = $(LIBNAME).so
TGT_LIB_SO_VER = $(TGT_LIB_SO).${VER}
TGT_UNIT_TEST = test_$(LIBNAME) test_libstun test_libptcp
TGT_UNIT_TEST = test_$(LIBNAME) test_libstun
# test_file_transfer
#test_libptcp

OBJS_LIB = $(LIBNAME).o
OBJS_LIB += libstun.o libptcp.o
OBJS_LIB += libstun.o
# libptcp.o
OBJS_UNIT_TEST = test_$(LIBNAME).o

###############################################################################
Expand All @@ -55,17 +58,8 @@ CFLAGS += -I$(OUTPUT)/include/gear-lib
SHARED := -shared

LDFLAGS := $($(ARCH)_LDFLAGS)
LDFLAGS += -L$(OUTLIBPATH)/lib -lrpc -lhash -lgevent -lsock -lthread
LDFLAGS += -L$(PLATFORM_LIB) -pthread
ifeq ($(ARCH), pi)
LDFLAGS += -lgcc_s
endif
LDFLAGS += $(ANDROID_PRE_LDFLAGS)
LDFLAGS += $($(ARCH)_LDFLAGS)
ifneq ($(ARCH), android)
LDFLAGS += -lrt
endif

LDFLAGS += -L$(OUTLIBPATH)/lib/gear-lib -lrpc -lhash -lgevent -lsock -lthread -ltime -lworkq -lposix -lptcp
LDFLAGS += -pthread -lrt

###############################################################################
# target
Expand All @@ -91,9 +85,19 @@ $(TGT_LIB_SO): $(OBJS_LIB)
@mv $(TGT_LIB_SO) $(TGT_LIB_SO_VER)
@ln -sf $(TGT_LIB_SO_VER) $(TGT_LIB_SO)

$(TGT_UNIT_TEST): $(OBJS_UNIT_TEST) $(ANDROID_MAIN_OBJ)
test_libp2p: test_libp2p.o
$(CC_V) -o $@ $^ $(TGT_LIB_A) $(LDFLAGS)

test_libstun: test_libstun.o
$(CC_V) -o $@ $^ $(TGT_LIB_A) $(LDFLAGS)

test_libptcp: test_libptcp.o
$(CC_V) -o $@ $^ $(TGT_LIB_A) $(LDFLAGS)

test_file_transfer: test_file_transfer.o
$(CC_V) -o $@ $^ $(TGT_LIB_A) $(LDFLAGS)


clean:
$(RM_V) -f $(OBJS)
$(RM_V) -f $(TGT)
Expand Down
10 changes: 9 additions & 1 deletion gear-lib/libp2p/libp2p.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int on_get_connect_list_resp(struct rpc_session *r, void *arg, size_t len
{
char *ptr;
int num = 0;
printf("on_get_connect_list, len = %d\n", len);
printf("on_get_connect_list, len = %zu\n", len);
num = len / MAX_UUID_LEN;
for (ptr = (char *)arg; num > 0; --num) {
printf("uuid list: %s\n", ptr);
Expand Down Expand Up @@ -301,6 +301,12 @@ struct p2p *p2p_init(const char *rpc_srv, const char *stun_srv)
return NULL;
}
RPC_REGISTER_MSG_MAP(RPC_CLIENT_API);
printf("RPC_TEST:%d\n", RPC_TEST);
printf("RPC_GET_CONNECT_LIST:%d\n", RPC_GET_CONNECT_LIST);
printf("RPC_PEER_POST_MSG:%d\n", RPC_PEER_POST_MSG);
printf("RPC_SHELL_HELP:%d\n", RPC_SHELL_HELP);
printf("RPC_GET_CONNECT_LIST:%d\n", RPC_GET_CONNECT_LIST);

sock_getaddr_by_fd(p2p->rpc->base.fd, &tmpaddr);
sock_addr_ntop(_local_ip, tmpaddr.ip);
//_local_port = tmpaddr.port;
Expand Down Expand Up @@ -331,8 +337,10 @@ struct p2p *p2p_init(const char *rpc_srv, const char *stun_srv)
int p2p_connect(struct p2p *p2p, uint32_t peer_id)
{
int len = (int)sizeof(struct nat_info);
printf("rpc_peer_post_msg from %x to %x\n", p2p->rpc->uuid, peer_id);
p2p->rpc->uuid = peer_id;
//rpc_send(p2p->rpc, (void *)&p2p->nat, len);
printf("rpc_peer_post_msg len = %d\n", len);
rpc_peer_post_msg(p2p->rpc, (void *)&p2p->nat, len);
p2p->rpc_state = P2P_RPC_SYN_SENT;

Expand Down
Loading

0 comments on commit 13b1ca9

Please sign in to comment.