Esempio n. 1
0
int
match_command_line_opt( char *argvi, CommandLineOpts *options )
{
    register char *ptr = argvi;
    register int opt ;

    if( ptr == NULL )
        return -1;
show_debug (__FILE__,__FUNCTION__,__LINE__, "ptr = \"%s\"", ptr);
    if( *ptr == '-' )
    {
        ++ptr;
        if( *ptr == '-' )
        {
            ++ptr;
show_debug (__FILE__,__FUNCTION__,__LINE__, "ptr = \"%s\"", ptr);
            for( opt = 0 ; options[opt].handler ; ++opt )
                if( strcmp(options[opt].long_opt, ptr ) == 0 )
                    break;
        }else
        {
show_debug (__FILE__,__FUNCTION__,__LINE__, "ptr = \"%s\"", ptr);
            for( opt = 0 ; options[opt].handler ; ++opt )
                if( options[opt].short_opt )
                    if( strcmp(options[opt].short_opt, ptr ) == 0 )
                        break;
        }
    }else
        opt = -1;
    if( options[opt].handler == NULL )
        opt = -1;
    return opt;
}
Esempio n. 2
0
static int hik_talk_open(struct service *srv, struct talk_info *talk, 
							talk_handle_t *hdl, media_info_t *info)
{
    struct hik_service *hik_srv;
	long talk_hanle;
	
	NMP_ASSERT(srv && talk);

	if(talk->frm)
	{
		free(talk->frm);
		talk->frm = NULL;
	}
	talk->frm = (frame_t *)malloc(sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
	if(!talk->frm)
	{
		return -1;
	}

	hik_srv = (hik_service_t *)srv;
	talk->handle = hik_get_user_id(&hik_srv->parm);
	
    if (HIK_LOGOUT == hik_get_user_id(&hik_srv->parm))
    {
        show_debug("dah device is disconnected.\n");
    }
	else
	{
		talk->init_g722_encoder = NET_DVR_InitG722Encoder();
		talk->init_g722_decoder = NET_DVR_InitG722Decoder();
		if(hik_srv->init_g722_decoder == NULL && hik_srv->init_g722_encoder)
		{		
			show_debug("NET_DVR_InitG722Encoder error[%d]\n", NET_DVR_GetLastError());
			if(talk->frm)
			{
				free(talk->frm);
				talk->frm = NULL;
			}
			return -1;
		}

		talk_hanle = NET_DVR_StartVoiceCom_MR_V30(talk->handle, info->channel + 1, 
													hik_audio_data_callback, (void *)talk);
    	if (talk_hanle < 0)
    	{
        	show_error("pyd---NET_DVR_StartVoiceCom_MR_V30 fail %d\n", NET_DVR_GetLastError());
			if(talk->frm)
			{
				free(talk->frm);
				talk->frm = NULL;
			}

        	return -1;
    	}
		show_info("**********hik talk->handle = %d, talk_handle = %ld\n", talk->handle, talk_hanle);
		talk->talk_handle = talk_hanle;
	}
    
    return 0; 
}
Esempio n. 3
0
void asdbus_EndSessionOk ()
{
		show_debug(__FILE__, __FUNCTION__, __LINE__, "dbus EndSessionOk");
#ifdef HAVE_DBUS_CONTEXT
	if (ASDBus.session_conn) {
		DBusMessage *message =
				dbus_message_new_method_call (SESSIONMANAGER_NAME,
																			ASDBus.gnomeSessionPath,	/*"/org/gnome/SessionManager", */
																			IFACE_SESSION_PRIVATE,
																			"EndSessionResponse");
		show_debug(__FILE__, __FUNCTION__, __LINE__, "dbus EndSessionResponse to iface = \"%s\", path = \"%s\", manager = \"%s\"", 
			    IFACE_SESSION_PRIVATE, ASDBus.gnomeSessionPath, SESSIONMANAGER_NAME);
		if (message) {
			DBusMessageIter iter;
			char *reason = "";
			dbus_bool_t ok = 1;
			dbus_uint32_t msg_serial;

			dbus_message_iter_init_append (message, &iter);
			dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &ok);
			dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &reason);
			dbus_message_set_no_reply (message, TRUE);
			if (!dbus_connection_send
					(ASDBus.session_conn, message, &msg_serial))
				show_error ("Failed to send EndSession indicator.");
			else
				show_progress ("Sent Ok to end session (time, %ld).", time (NULL));
			dbus_message_unref (message);
		}
	}
#endif
}
Esempio n. 4
0
static int 
hie_record_data_callback(HSTREAM handle, const StreamMediaFrame *strm_data, 
    DWORD user_data)
{
    stream_info_t *strm_info;
    hie_rec_strm_t *rec_strm;

    NMP_ASSERT(HIE_INVALID_HANDLE != handle);
    NMP_ASSERT(strm_data);
    NMP_ASSERT(user_data);

    strm_info = (stream_info_t*)user_data;
    rec_strm  = (hie_rec_strm_t*)strm_info;

    if (eFrameSysHeader == strm_data->dwFrameType)
    {
        if (!strm_info->opened && !strm_info->media_size)
        {
            memcpy(strm_info->media_info, strm_data->cFrameBuffer.pBuffer, 
                strm_data->cFrameBuffer.dwBufLen);
            strm_info->media_size = strm_data->cFrameBuffer.dwBufLen;
        }
    }
    else
    {
        if (!strm_data->cFrameBuffer.pBuffer)
            return 0;

        while (1)
        {
            if (strm_info->opened && rec_strm->enable)
            {
                if (!test_stream_blockable((gpointer)strm_info->opened, 
                        (gsize)strm_data->cFrameBuffer.dwBufLen))
                {//printf("----------->%d\n", (int)strm_data->dwDataSize);
                    show_debug("channel: %d, len: %d\n", strm_info->channel, 
                        (int)strm_data->cFrameBuffer.dwBufLen);
                    write_stream_data((gpointer)strm_info->opened, 
                        (gulong)strm_info->ts, (gulong)DEF_TIMESTAMP, 
                        (guint8*)strm_data->cFrameBuffer.pBuffer, 
                        (gsize)strm_data->cFrameBuffer.dwBufLen, 
                        (guint8)strm_data->dwFrameType, (guint8*)NULL, 
                        (gsize)0, (guint8)0);
                    break;
                }
                else
                {
                    show_debug("Sleep some times.\n");
                    usleep(RECORD_PACKET_SLEEP_TIME);
                }
            }
            else
                break;
        }
    }

    return 0;
}
Esempio n. 5
0
static void config_upload_data(int fd, config_backup_t *cfg_bkp)
{
    FILE *fpw;
    backup_frame_t frame;

    int n_read, n_left, seq = 0;
    char buf[DEF_BACKUP_FRAME_SIZE];

    fpw = fopen(DEF_REVERT_FILE, "w");
    if (!fpw)
        return ;

    n_left = get_backup_left_size(cfg_bkp);
    show_debug("left: %d<-----------------------\n", n_left);
    while (n_left > 0)
    {
        n_read = my_recv(fd, &frame, sizeof(backup_frame_t), 0);
        if (n_read != sizeof(backup_frame_t))
            break;

        n_left -= n_read;

        if (DEF_REVERT_MAGIC != frame.magic)
            break;
        if (seq++ != frame.seq)
            break;
        if (0 >= frame.payload_len)
            break;
        if (DEF_BACKUP_KEY != frame.secret_key)
            break;

        n_read = my_recv(fd, buf, frame.payload_len, 0);
        if (n_read != frame.payload_len)
            break;

        config_simple_decrypt(&frame, buf, n_read);
        fwrite(buf, 1, n_read, fpw);

        n_left -= n_read;
        set_backup_left_size(cfg_bkp, n_left);
    }

    show_debug("left: %d<-----------------------\n", n_left);
    fclose(fpw);

    if (!n_left)
    {
        char sys_cmd[DEF_SYS_COMMAND_SIZE];
        sprintf(sys_cmd, "tar -jxvf %s -C %s", DEF_REVERT_FILE, 
            (char*)proxy_get_data_file_path());
        system(sys_cmd);

        proxy_task_t *task;
        task = proxy_new_task(REBOOT_SERVER, NULL, 0, NULL, NULL);
        if (task)
            proxy_thread_pool_push(task);
    }
}
Esempio n. 6
0
static void asdbus_set_dbus_timer (struct timeval *expires, DBusTimeout *timeout) {
	int interval = dbus_timeout_get_interval(timeout);
	gettimeofday (expires, NULL);
	tv_add_ms(expires, interval);
	show_debug(__FILE__,__FUNCTION__,__LINE__,"time = %d, adding dbus timeout data=%p, interval = %d\n", time(NULL), timeout, interval);
	timer_new (interval, asdbus_handle_timer, timeout);
}
Esempio n. 7
0
static int hbn_talk_recv(struct service *srv, talk_info_t *talk, char *data, int len, media_info_t *info)
{
    int ret = -1;
    hbn_service_t *hbn_srv;
    unsigned int in_data_len = 0;
    frame_t *frm = NULL;

    NMP_ASSERT(srv && talk && data);

    frm = (talk_frame_hdr_t*)data;
    if(ntohl(frm->magic) != TALK_MAGIC)
    {
        show_warn("magic[0x%x] error", ntohl(frm->magic));
        return -1;
    }
    in_data_len = ntohl(frm->frame_length);
printf("====================hbn_talk_recv len = %d\n", in_data_len);
    hbn_srv = (hbn_service_t*)srv;	
	ret = HB_NET_VoiceComSendData(talk->talk_handle, (char *)frm->frame_data, in_data_len);
	if(ret == FALSE)
	{
		show_debug("HB_NET_VoiceComSendData!, error = %d, user_id = %d\n", 
		        (int)HB_NET_GetLastError(), (int )hbn_get_user_id(&hbn_srv->parm));
		return -1;
	}

    return 0;
}
Esempio n. 8
0
static dbus_bool_t add_watch(DBusWatch *w, void *data)
{
    	if (!dbus_watch_get_enabled(w))
      		return TRUE;

	ASDBusFd *fd = safecalloc (1, sizeof(ASDBusFd));
	fd->fd =  dbus_watch_get_unix_fd(w);
	unsigned int flags = dbus_watch_get_flags(w);
	if (get_flags(flags, DBUS_WATCH_READABLE))
		fd->readable = True;
    /*short cond = EV_PERSIST;
    if (flags & DBUS_WATCH_READABLE)
        cond |= EV_READ;
    if (flags & DBUS_WATCH_WRITABLE)
        cond |= EV_WRITE; */

      // TODO add to the list of FDs
	dbus_watch_set_data(w, fd, NULL);
	if (ASDBus.watchFds == NULL)
		ASDBus.watchFds = create_asvector (sizeof(ASDBusFd*));

	append_vector(ASDBus.watchFds, &fd, 1);

	show_debug(__FILE__,__FUNCTION__,__LINE__,"added dbus watch fd=%d watch=%p readable =%d\n", fd->fd, w, fd->readable);
	return TRUE;
}
Esempio n. 9
0
int jny_proc_get_device_cfg(int user_id, void *parm, proxy_sdk_t *sdk_info)
{printf("---------------jny_proc_get_device_cfg-----enter\n");
	int ret;
    char addr[MAX_IP_LEN];
	ST_InetAddr p_stAddr;
	ST_DeviceSummaryParam p_pstDeviceSummaryInfo;
	
	NMP_ASSERT(parm && sdk_info);

    memset(addr, 0, sizeof(addr));
    if (!proxy_resolve_host_immediate((const char*)sdk_info->dev_host, addr, sizeof(addr)))
	{
		show_debug("Proxy device ipaddr is not found!!!!!!!!!!!!!!\n");
		return -1;
	}

	memset(&p_stAddr, 0, sizeof(ST_InetAddr));
	memcpy(p_stAddr.szHostIP, addr, strlen(addr));
	p_stAddr.nPORT = sdk_info->dev_port;
	p_stAddr.nIPProtoVer = IPPROTO_V4;

	memset(&p_pstDeviceSummaryInfo, 0, sizeof(ST_DeviceSummaryParam));
	ret = Remote_System_GetSystemInfo(user_id, p_stAddr, &p_pstDeviceSummaryInfo, UDP);
	if(ret != SN_SUCCESS)
	{
		jny_print_error(ret);
		return -1;
	}

	memcpy(parm, (void *)&p_pstDeviceSummaryInfo, sizeof(ST_DeviceSummaryParam));
	return 0;
}
Esempio n. 10
0
int jny_set_user_id(jny_service *jny_srv, int user_id)
{
    int ret, old;
    jny_parm *pm;

    NMP_ASSERT(jny_srv);

    pm = &jny_srv->parm;

    nmp_mutex_lock(pm->lock);
    old = pm->user_id;
    pm->user_id = user_id;
    nmp_mutex_unlock(pm->lock);

    if (JNY_LOGOUT != old)
    {
        	ret = Remote_Camera2_Close(old);
        
            show_debug("Remote_Camera2_Close: %s<-------------------------------\n", 
                (ret == SN_SUCCESS) ? "Success" : "Failure");
        jny_logout(old);
    }

    if (JNY_LOGOUT == user_id)
        jny_stop_all_stream(&jny_srv->rtsp);

    return user_id;
}
Esempio n. 11
0
void check_all_prompts(struct session *ses, char *original, char *line)
{
	struct listroot *root = ses->list[LIST_PROMPT];
	struct listnode *node;

	if (!HAS_BIT(ses->flags, SES_FLAG_SPLIT))
	{
		return;
	}

	for (root->update = 0 ; root->update < root->used ; root->update++)
	{
		if (check_one_regexp(ses, root->list[root->update], line, original, 0))
		{
			node = root->list[root->update];

			if (*node->right)
			{
				substitute(ses, node->right, original, SUB_ARG);
				substitute(ses, original, original, SUB_VAR|SUB_FUN|SUB_COL|SUB_ESC);
			}

			show_debug(ses, LIST_PROMPT, "#DEBUG PROMPT {%s}", node->left);

			do_one_prompt(ses, original, atoi(node->pr));

			SET_BIT(ses->flags, SES_FLAG_GAG);
		}
	}
}
Esempio n. 12
0
static int hbn_talk_close(struct service *srv, talk_info_t *talk)
{
    int ret = -1;
    hbn_service_t *hbn_srv;

    NMP_ASSERT(srv && talk);
	
    if(talk->frm)
    {
        nmp_dealloc(talk->frm, sizeof(frame_t) + MAX_ENCODE_BUFFER_LEN);
        talk->frm = NULL;
    }

	if(talk->pri_data)
	{
		nmp_dealloc(talk->pri_data, sizeof(HB_NET_VOICECOMPARAM));
		talk->pri_data = NULL;
	}
	
    hbn_srv = (hbn_service_t*)srv;
    if (HB_NET_StopVoiceCom(talk->talk_handle))
    {
        ret = 0;
    }
    else
    {
        show_debug("------------HB_NET_StopVoiceCom (%d)\n", (int)HB_NET_GetLastError());
    }

    return ret;
}
Esempio n. 13
0
char *
proxy_resolve_host_immediate(const char *host, char *addr, size_t size)
{
    int err;
    struct sockaddr_in socket;
    NMP_ASSERT(host && addr && !strlen(addr));

    find_host_node_by_host(hlist_manager, host, addr, size);
    if (!strlen(addr))
    {
        memset(&socket, 0, sizeof(struct sockaddr_in));
        err = nmp_resolve_host(&socket, (char*)host, 0);
        if (err)
        {
            show_debug("nmp_resolve_host[%s] err: %d\n", host, err);
            return NULL;
        }

        inet_ntop(socket.sin_family, &socket.sin_addr, 
            addr, size);
    }
    else
        return NULL;

    return addr;
}
Esempio n. 14
0
static void config_download_data(int fd, config_backup_t *cfg_bkp)
{
    FILE *fpr;
    backup_frame_t frame;

    int n_read, n_left, n_write;
    char buf[DEF_BACKUP_FRAME_SIZE];

    fpr = fopen(DEF_BACKUP_FILE, "r");
    if (!fpr)
        return ;

    frame.magic = DEF_REVERT_MAGIC;
    frame.seq = 0;
    frame.payload_len = DEF_BACKUP_FRAME_SIZE;
    frame.secret_key = DEF_BACKUP_KEY;

    n_left = get_backup_left_size(cfg_bkp);
    show_debug("left: %d<-----------------------\n", n_left);
    while (n_left > 0)
    {
        n_left -= sizeof(backup_frame_t);
        n_read = MIN(n_left, DEF_BACKUP_FRAME_SIZE);

        frame.payload_len = fread(buf, 1, n_read, fpr);
        config_simple_encrypt(&frame, buf, frame.payload_len);

        if (0 > send(fd, &frame, sizeof(backup_frame_t), 0))
        {
            show_info("recv error.[err: %d]\n", errno);
            break;
        }

        n_write = send(fd, buf, frame.payload_len, 0);
        if (0 > n_write)
        {
            show_info("recv error.[err: %d]\n", errno);
            break;
        }

        n_left -= n_write;
        frame.seq++;
    }

    show_debug("left: %d<-----------------------\n", n_left);
    fclose(fpr);
}
Esempio n. 15
0
static void toggle_watch(DBusWatch *w, void *data)
{
    show_debug(__FILE__,__FUNCTION__,__LINE__,"toggling dbus watch watch=%p\n", w);
    if (dbus_watch_get_enabled(w))
        add_watch(w, data);
    else
        remove_watch(w, data);
}
Esempio n. 16
0
static void remove_watch(DBusWatch *w, void *data)
{
    ASDBusFd* fd = dbus_watch_get_data(w);

    vector_remove_elem (ASDBus.watchFds, &fd);
    dbus_watch_set_data(w, NULL, NULL);
    show_debug(__FILE__,__FUNCTION__,__LINE__,"removed dbus watch watch=%p\n", w);
}
Esempio n. 17
0
static __inline__ int bsm_logout(int user_id)
{
    if (HI_NET_DEV_Logout((HI_U32)user_id))
    {
        show_debug("bsm_logout() successful, user_id: %d\n", user_id);
        return 0;
    }
    else
        return -1;
}
Esempio n. 18
0
void
standard_version (void)
{
show_debug (__FILE__,__FUNCTION__,__LINE__, "version = \"%s\", MyVersionFunc = %p", VERSION, MyVersionFunc);

    if( MyVersionFunc )
        MyVersionFunc();
    else
	    printf ("%s version %s\n", MyClass, VERSION);
}
Esempio n. 19
0
static __inline__ int 
hie_logout(HUSER user_id)
{
    if (!HieClient_UserLogout(user_id))
    {
        show_debug("HieClient_UserLogout() successful, user_id: %p\n", user_id);
        return 0;
    }
    else
        return -1;
}
Esempio n. 20
0
int check_all_aliases(struct session *ses, char *input) {
  struct listnode *node;
  struct listroot *root;
  char line[BUFFER_SIZE], tmp[BUFFER_SIZE], *arg;
  int i;

  root = ses->list[LIST_ALIAS];

  if (HAS_BIT(root->flags, LIST_FLAG_IGNORE)) {
    return FALSE;
  }

  for (i = 1; i < 100; i++) {
    if (*gtd->vars[i]) {
      RESTRING(gtd->vars[i], "");
    }
  }

  substitute(ses, input, line, SUB_VAR | SUB_FUN);

  for (root->update = 0; root->update < root->used; root->update++) {
    if (check_one_regexp(ses, root->list[root->update], line, line, PCRE_ANCHORED)) {
      node = root->list[root->update];

      i = strlen(node->left);

      if (!strncmp(node->left, line, i)) {
        if (line[i] && line[i] != ' ') {
          continue;
        }

        arg = get_arg_in_braces(ses, line, tmp, FALSE);

        RESTRING(gtd->vars[0], arg) for (i = 1; i < 100 && *arg; i++) {
          arg = get_arg_in_braces(ses, arg, tmp, FALSE);

          RESTRING(gtd->vars[i], tmp);
        }
      }

      substitute(ses, node->right, tmp, SUB_ARG);

      if (!strncmp(node->left, line, strlen(node->left))
          && !strcmp(node->right, tmp) && *gtd->vars[0]) {
        sprintf(input, "%s %s", tmp, gtd->vars[0]);
      } else {
        sprintf(input, "%s", tmp);
      }

      show_debug(ses, LIST_ALIAS, "#DEBUG ALIAS {%s} {%s}", node->left, gtd->vars[0]);

      return TRUE;
    }
  }
Esempio n. 21
0
static __inline__ int dah_logout(long user_id)
{
    CLIENT_StopListen(user_id);
    if (CLIENT_Logout(user_id))
    {
        show_debug("dah_logout() successful, user_id: %d\n", (int)user_id);
        return 0;
    }
    else
        return -1;
}
Esempio n. 22
0
static _asdbus_add_match (DBusConnection *conn, const char* iface, const char* member) {
	char match[256];
	sprintf(match,	member?"type='signal',interface='%s',member='%s'":"type='signal',interface='%s'", iface, member);
    	DBusError error;
    	dbus_error_init(&error);
    	dbus_bus_add_match(conn, match, &error);
	show_debug(__FILE__,__FUNCTION__,__LINE__, "added match :[%s]", match);
    	if (dbus_error_is_set(&error)) {
      		show_error("dbus_bus_add_match() %s failed: %s\n",   member, error.message);
      		dbus_error_free(&error);
	}
}
Esempio n. 23
0
static void 
jny_stop_real_stream(struct stream_info *strm_info)
{show_debug("%s()<------------------------\n", __FUNCTION__);
	NMP_ASSERT(strm_info);

	if (-1 != strm_info->handle)
    {
    	Remote_Camera2_Close(strm_info->handle);
        strm_info->handle = -1;
    }

	return ;
}
Esempio n. 24
0
static void 
dah_stop_record_stream(stream_info_t *strm_info)
{show_debug("%s()<------------------------\n", __FUNCTION__);
    NMP_ASSERT(strm_info);

    if (DAH_INVALID_HANDLE != strm_info->handle)
    {
        CLIENT_StopPlayBack((LONG)strm_info->handle);
        strm_info->handle = DAH_INVALID_HANDLE;
    }

    return ;
}
Esempio n. 25
0
static void 
bsm_stop_record_stream(stream_info_t *strm_info)
{show_debug("%s()<------------------------\n", __FUNCTION__);
    NMP_ASSERT(strm_info);

    if (BSM_INVALID_HANDLE != strm_info->handle)
    {
        //
        strm_info->handle = BSM_INVALID_HANDLE;
    }

    return ;
}
Esempio n. 26
0
static void 
bsm_stop_real_stream(stream_info_t *strm_info)
{show_debug("%s()<------------------------\n", __FUNCTION__);
    NMP_ASSERT(strm_info);

    if (BSM_INVALID_HANDLE != strm_info->handle)
    {
        HI_NET_DEV_StopStream((HI_U32)strm_info->handle);
        strm_info->handle = BSM_INVALID_HANDLE;
    }

    return ;
}
Esempio n. 27
0
void asdbus_handleDispatches (){
#ifdef ASDBUS_DISPATCH
	void *data;
	while ((data = extract_first_bidirelem (ASDBus.dispatches)) != NULL){
		ASDBusDispatch *d = (ASDBusDispatch*)data;
		while (dbus_connection_get_dispatch_status(d->data) == DBUS_DISPATCH_DATA_REMAINS){
			dbus_connection_dispatch(d->data);
			show_debug(__FILE__,__FUNCTION__,__LINE__,"dispatching dbus  data=%p\n", d->data);
		}
		free (d);
	}
#endif
}
Esempio n. 28
0
static __inline__ void dah_login(dah_service_t *dah_srv)
{
    char addr[MAX_IP_LEN];
    int state, error = 0;
    int user_id = DAH_LOGOUT;
    proxy_sdk_t sdk_info;

    NMP_ASSERT(dah_srv);

    if (proxy_get_device_private(dah_srv->owner, DEV_PRI_PRX_SDK, &sdk_info))
    {
        BUG();
    }

    memset(addr, 0, sizeof(addr));
    if (proxy_resolve_host_immediate((const char*)sdk_info.dev_host, addr, sizeof(addr)))
    {
        user_id = CLIENT_Login(addr, sdk_info.dev_port, 
                    sdk_info.username, sdk_info.password, 
                    &dah_srv->dah_info, &error);
    }
    else
        show_warn("Device host '%s' unsolved.\n", sdk_info.dev_host);

    if (DAH_LOGOUT != user_id)
    {
        CLIENT_StartListen(user_id);

        state = DAH_LOGIN;
        error = 0;
        show_debug("dah_login() successful, user_id: %d\n", user_id);
    }
    else
    {
        state = DAH_LOGOUT;
        //error = ;

        if (strlen(addr))
        {
            show_warn("dah_login(deviceID:%d) failure[%s:%s @ %s:%d]. Error: %d\n", 
                dah_srv->owner->fastenings.dev_id, 
                sdk_info.username, sdk_info.password, 
                addr, sdk_info.dev_port, error);
        }
    }

    dah_set_user_id(dah_srv, user_id);
    dah_set_state(dah_srv, (DAH_STATE_E)state, error);

    return ;
}
Esempio n. 29
0
static __inline__ void bsm_login(bsm_service_t *bsm_srv)
{
    char addr[MAX_IP_LEN];
    int state, error = 0;
    int user_id = BSM_LOGOUT;
    proxy_sdk_t sdk_info;

    NMP_ASSERT(bsm_srv);

    if (proxy_get_device_private(bsm_srv->owner, DEV_PRI_PRX_SDK, &sdk_info))
    {
        BUG();
    }

    memset(addr, 0, sizeof(addr));
    if (proxy_resolve_host_immediate((const char*)sdk_info.dev_host, addr, sizeof(addr)))
    {
        error = HI_NET_DEV_Login((HI_U32*)&user_id, 
            sdk_info.username, sdk_info.password, 
            addr, sdk_info.dev_port);
    }
    else
        show_warn("Device host '%s' unsolved.\n", sdk_info.dev_host);

    if (BSM_LOGOUT != user_id)
    {
        state = BSM_LOGIN;
        error = 0;
        show_debug("bsm_login() successful, user_id: %d\n", user_id);
    }
    else
    {
        state = BSM_LOGOUT;
        //error = ;

        if (strlen(addr))
        {
            show_warn("bsm_login(deviceID:%d) failure[%s:%s @ %s:%d]. Error: %d\n", 
                bsm_srv->owner->fastenings.dev_id, 
                sdk_info.username, sdk_info.password, 
                addr, sdk_info.dev_port, error);
        }
    }

    bsm_set_user_id(bsm_srv, user_id);
    bsm_set_state(bsm_srv, (BSM_STATE_E)state, error);

    return ;
}
Esempio n. 30
0
static __inline__ int jny_logout(long user_id)
{
	int ret;
	ret = Remote_Nvd_UnInit(user_id);

	if (ret != SN_SUCCESS)
	{
	    show_debug("jny_logout() successful, user_id: %d\n", (int)user_id);
	    return 0;
	}
	else
	{
	    return -1;
	}
}