예제 #1
0
static void register_server(uint16_t id)
{
	char path[MAX_PATH_LENGTH];
	bdaddr_t src;
	int dev_id;

	if (!conf->server_enabled)
		return;

	snprintf(path, MAX_PATH_LENGTH, NETWORK_PATH "/%s", bnep_name(id));

	if (g_slist_find_custom(server_paths, path,
				(GCompareFunc) strcmp))
		return;

	bacpy(&src, BDADDR_ANY);
	dev_id = hci_get_route(&src);
	if (dev_id < 0 || hci_devba(dev_id, &src))
		return;

	if (server_register(path, &src, id) < 0)
		return;

	server_store(path);

	server_paths = g_slist_append(server_paths, g_strdup(path));
}
예제 #2
0
static void
reactor_proc_enterlist(struct net_reactor* reactor)
{
    struct rwlist_entermsg_data* enter_msg = NULL;
    struct rwlist_s*    enter_list = reactor->enter_list;
    struct server_s* server = reactor->server;

    while((enter_msg = (struct rwlist_entermsg_data*)ox_rwlist_pop(enter_list, 0)) != NULL)
    {
        struct net_session_s* session = net_session_malloc();
        if(session != NULL)
        {
            session->reactor = reactor;
            session->ud = enter_msg->ud;

            if(!server_register(server, session, enter_msg->fd))
            {
                printf("register failed , free session \n");
                free(session);
            }
        }
        else
        {
            ox_socket_close(enter_msg->fd);
        }
    }
}
예제 #3
0
static int gn_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
	const char *path = adapter_get_path(adapter);

	DBG("path %s", path);

	return server_register(adapter, BNEP_SVC_GN);
}
예제 #4
0
static int network_server_probe(struct btd_adapter *adapter)
{
	const gchar *path = adapter_get_path(adapter);

	DBG("path %s", path);

	return server_register(adapter);
}
예제 #5
0
static void disable_nap(gpointer key, gpointer value, gpointer user_data)
{
	struct tethering_info *info = user_data;
	struct connman_device *device = value;
	const char *path;

	DBG("");

	path = connman_device_get_string(device, "Path");

	server_register(path, "nap", info->technology, info->bridge, FALSE);
}
예제 #6
0
/*服务端接收客户端命令,并进行解析,处理完毕返回0,返回1说明该套结字断开连接*/
int server_recv (struct pollfd  *poll_fd)
{
    struct cmd  cmdtemp ;
    struct link_list  *link_list_ptemp = NULL ;
    struct online_list  *online_list_ptemp = NULL ;
    int recv_len = 0 ;
    memset (&cmdtemp, 0, sizeof (struct cmd)) ;printf ("i get a bag\n") ;
    /*接收命令包*/
    if((recv_len = recv (poll_fd -> fd, &cmdtemp,  sizeof (struct cmd), 0)) < 0) {
        close (poll_fd -> fd) ;
        my_err ("recv", __LINE__) ;
        return -1 ;
    }
    /*如果该套结字断开连接,返回1则提示该套结字断开连接*/
    else if(recv_len == 0) {
        printf ("a client quit\n") ;
        /*从连接链表和在线用户链表中查找此套结字描述符,删去该结点*/
        if((link_list_ptemp = link_list_discover (link_list_PHEAD, poll_fd -> fd)) != NULL) {
            link_list_PHEAD = link_list_del (link_list_PHEAD, link_list_ptemp) ;
        }
        else if((online_list_ptemp = online_list_discover (online_list_PHEAD, poll_fd -> fd)) != NULL) {
            online_list_PHEAD = online_list_del (online_list_PHEAD, online_list_ptemp) ;
        }
        close (poll_fd -> fd) ;
        return 1 ;
    }
    /*接收正常的命令包,对其进行解析*/
    else {
        switch(cmdtemp.cmd_flag) {
            case MESSAGE :
                if(server_send (&cmdtemp) < 0) {
                    return -1 ;
                }
                break ;
            case LOGIN :
                if(server_login (poll_fd -> fd, &cmdtemp) <= 0) {
                    return -1 ;
                }
                printf ("login end \n") ;
                break ;
            case REGISTER :
                if(server_register (&cmdtemp, poll_fd -> fd) < 0) {
                    return -1 ;
                }
                break ;
            default :
                break ;
        }
        return 0 ;
    }
}
예제 #7
0
파일: server.c 프로젝트: Gaoyuan0710/MyFtp
void deal(int conn_fd)
{
	char buf[32];
	char name[32];
	char passwd[32];
	char pathname[SIZE] = {"/home/qiong/userinfo/"};
	int  ret;
	int  flag;
	int  fd;
	int zan;


	my_recv(conn_fd, buf, sizeof(buf));
	printf("%c\n", buf[0]);
	if (buf[0] == 'l')
	{
		sys_log("进入用户登陆界面");
		server_check(conn_fd);
	}
	else if (buf[0] == 'r')
	{
		sys_log("进入用户注册界面");
		server_register(conn_fd);	
	}	
	else if (buf[0] == 'x')
	{
		chdir("/home/qiong/shujia/source/");
		server_browse(conn_fd, "../source/");
	}
	else if (buf[0] == 'q')
	{
		sys_log("浏览本地上传目录");
		chdir("/home/qiong/shujia/source/");
		server_look(conn_fd, "../source/");
	}
	else if (buf[0] == 'd')
	{
		sys_log("查找资源");
		sys_find(conn_fd);
		deal(conn_fd);
	}
}
예제 #8
0
파일: server.c 프로젝트: 2asoft/freebsd
/*
 * The server_update() function is called whenever the channel count is
 * changed. We maintain the SDP record and open or close the server socket
 * as required.
 */
void
server_update(int count)
{

	if (server_limit == 0)
		return;

	log_debug("count %d", count);

	server_avail = UINT8_MAX - (count - 1) * UINT8_MAX / server_limit;
	log_info("Service Availability: %d/%d", server_avail, UINT8_MAX);

	if (server_avail == 0 && server_fd != -1)
		server_close();

	if (server_avail > 0 && server_fd == -1)
		server_open();

	if (service_name)
		server_register();
}