Пример #1
0
static void
list_bindery(char *server, char *type, char *patt) {
	struct ncp_bindery_object q;
	int i, found = 0, connid;
	char default_pattern[] = "*";
	char *pattern = default_pattern;
	u_long objtype;

	ncp_str_upper(type);
	objtype = 0;

	for(i = 0; btypes[i].type; i++) {
		if (strcmp(btypes[i].name, type) == 0) {
			objtype = btypes[i].type;
			break;
		}
	}
	if (!objtype) {
		printf("Bindery object of type %s is unknown\n", type);
		return;
	}
	if (patt != NULL)
		pattern = patt;
	ncp_str_upper(pattern);
	connid = ncp_get_connid(server, 1);
	if (connid < 0) return;

	connid = ncp_get_connid(server, 1);
	if (connid < 0) return;


	printf("\nServer: %s\n", server);
	printf("%-52s%-10s\n"
	       "-----------------------------------------------"
	       "-------------\n",
	       "Object name",
	       "Object ID");

	q.object_id = 0xffffffff;
	while (ncp_scan_bindery_object(connid, q.object_id,
				       objtype, pattern, &q) == 0)
	{
		found = 1;
		printf("%-52s", q.object_name);
		printf("%08X\n", (unsigned int) q.object_id);
	}

	if (!found) {
		printf("No bindery objects found\n");
	}
	return;
}
Пример #2
0
static int 
__P(sncp_conn_scan(struct proc *p, struct sncp_conn_scan_args *uap)){
	int connHandle = 0, error;
	struct ncp_conn_args li, *lip;
	struct ncp_conn *conn;
	struct ncp_handle *hp;
	char *user = NULL, *password = NULL;

	if (uap->li) {
		if (copyin(uap->li,&li,sizeof(li))) return EFAULT;
		lip = &li;
	} else {
		lip = NULL;
	}

	if (lip != NULL) {
		lip->server[sizeof(lip->server)-1]=0; /* just to make sure */
		ncp_str_upper(lip->server);
		if (lip->user) {
			user = ncp_str_dup(lip->user);
			if (user == NULL) return EINVAL;
			ncp_str_upper(user);
		}
		if (lip->password) {
			password = ncp_str_dup(lip->password);
			if (password == NULL) {
				if (user)
					free(user, M_NCPDATA);
				return EINVAL;
			}
			ncp_str_upper(password);
		}
		lip->user = user;
		lip->password = password;
	}
	error = ncp_conn_getbyli(lip,p,p->p_ucred,NCPM_EXECUTE,&conn);
	if (!error) { 		/* already have this login */
		ncp_conn_gethandle(conn, p, &hp);
		connHandle = hp->nh_id;
		ncp_conn_unlock(conn,p);
		copyout(&connHandle,uap->connHandle,sizeof(connHandle));
	}
	if (user) free(user, M_NCPDATA);
	if (password) free(password, M_NCPDATA);
	p->p_retval[0] = error;
	return error;

}
Пример #3
0
static void
show_queuelist(char *server, char *patt) {
	struct ncp_bindery_object q;
	int found = 0, connid;
	char default_pattern[] = "*";
	char *pattern = default_pattern;

	connid = ncp_get_connid(server, 1);
	if (connid < 0) return;
	if (patt != NULL)
		pattern = patt;
	ncp_str_upper(pattern);

	printf("\nServer: %s\n", server);
	printf("%-52s%-10s\n"
	       "-----------------------------------------------"
	       "-------------\n",
	       "Print queue name",
	       "Queue ID");
	q.object_id = 0xffffffff;

	while (ncp_scan_bindery_object(connid, q.object_id,
				       NCP_BINDERY_PQUEUE, pattern, &q) == 0)
	{
		found = 1;
		printf("%-52s", q.object_name);
		printf("%08X\n", (unsigned int) q.object_id);
	}

	if (!found) {
		printf("No queues found\n");
	}
	return;
}
Пример #4
0
int
ncp_li_setserver(struct ncp_conn_loginfo *li, const char *arg) {
	if (strlen(arg) >= NCP_BINDERY_NAME_LEN) {
		ncp_error("server name '%s' too long", 0, arg);
		return ENAMETOOLONG;
	}
	ncp_str_upper(strcpy(li->server, arg));
	return 0;
}
Пример #5
0
/*
 * Find an existing connection and reference it
 */
int
ncp_conn_find(char *server,char *user) {
	struct ncp_conn_args ca;
	int connid, error;

	if (server == NULL && user == NULL) {
		error = ncp_conn_scan(NULL,&connid);
		if (error) return -2;
		return connid;
	}
	if (server == NULL)
		return -2;
	ncp_str_upper(server);
	if (user) ncp_str_upper(user);
	bzero(&ca, sizeof(ca));
	ncp_li_setserver(&ca, server);
	ncp_li_setuser(&ca, user);
	error = ncp_conn_scan(&ca,&connid);
	if (error)
		connid = -1;
	return connid;
}
Пример #6
0
static int
ncp_find_server_ipx(struct ncp_conn_loginfo *li, int type) {
	char server[NCP_BINDERY_NAME_LEN + 1];
	int error;
	char nearest[NCP_BINDERY_NAME_LEN + 1];
	struct nw_property prop;
	struct ipx_addr *n_addr = (struct ipx_addr *) &prop;
/*	struct ncp_conn_loginfo ltmp;*/
	int connid;

	bzero(server, sizeof(server));
	bzero(nearest, sizeof(nearest));

	strcpy(server, li->server);
	ncp_str_upper(server);

	if ((error = sap_find_nearest(type, &li->ipxaddr, nearest)) != 0) {
		return error;
	}
	/* if no server specified return info about nearest */
	if (!li->server[0]) {
		strcpy(li->server, nearest);
		return 0;
	}
/*	printf("%s\n",ipx_ntoa(li->ipxaddr.sipx_addr));*/
	if (strcmp(server, nearest) == 0) {
		return 0;
	}
	/* We have to ask the nearest server for our wanted server */
	li->opt=0;
	if ((error = ncp_connect(li, &connid)) != 0) {
		return error;
	}
	if (ncp_read_property_value(connid, type, server, 1, "NET_ADDRESS", &prop) != 0) {
		ncp_disconnect(connid);
		return EHOSTUNREACH;
	}
	if ((error = ncp_disconnect(connid)) != 0) {
		return error;
	}
	li->ipxaddr.sipx_family = AF_IPX;
	li->ipxaddr.sipx_addr.x_net = n_addr->x_net;
	li->ipxaddr.sipx_port = n_addr->x_port;
	li->ipxaddr.sipx_addr.x_host = n_addr->x_host;
	return 0;
}
Пример #7
0
int
ncp_li_setuser(struct ncp_conn_loginfo *li, char *arg) {
	if (arg && strlen(arg) >= NCP_BINDERY_NAME_LEN) {
		ncp_error("user name '%s' too long", 0, arg);
		return ENAMETOOLONG;
	}
	if (li->user)
		free(li->user);
	if (arg) {
		li->user = strdup(arg);
		if (li->user == NULL)
			return ENOMEM;
		ncp_str_upper(li->user);
	} else
		li->user = NULL;
	return 0;
}