mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
found the stupid bug
This commit is contained in:
parent
c6371e86e7
commit
23ae292e3d
4 changed files with 17 additions and 15 deletions
|
|
@ -100,7 +100,8 @@ fn test_main() -> ! {
|
||||||
"Hello, world! This is the server, PID {}",
|
"Hello, world! This is the server, PID {}",
|
||||||
xous::current_pid().unwrap()
|
xous::current_pid().unwrap()
|
||||||
);
|
);
|
||||||
let sid = xous_names::register_name(api::SERVER_NAME).unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
let sid = xns.register_name(api::SERVER_NAME).unwrap();
|
||||||
|
|
||||||
let mut logstring_callback_connections = [None; 32];
|
let mut logstring_callback_connections = [None; 32];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use hash32::{Hash, Hasher};
|
use hash32::{Hash, Hasher};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub const AUTHENTICATE_TIMEOUT: u32 = 10_000; // time in ms that a process has to respond to an authentication request
|
pub const AUTHENTICATE_TIMEOUT: u32 = 10_000; // time in ms that a process has to respond to an authentication request
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
|
|
@ -60,6 +61,7 @@ impl Default for XousServerName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl XousServerName {
|
impl XousServerName {
|
||||||
pub fn to_str(&self) -> &str {
|
pub fn to_str(&self) -> &str {
|
||||||
core::str::from_utf8(unsafe {
|
core::str::from_utf8(unsafe {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ pub mod api;
|
||||||
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use xous_ipc::{String, Buffer};
|
use xous_ipc::{String, Buffer};
|
||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
use num_traits::ToPrimitive;
|
||||||
|
|
||||||
pub struct XousNames {
|
pub struct XousNames {
|
||||||
conn: xous::CID,
|
conn: xous::CID,
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ use api::*;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
use heapless::FnvIndexMap;
|
use heapless::FnvIndexMap;
|
||||||
|
|
||||||
use core::convert::TryInto;
|
use num_traits::FromPrimitive;
|
||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
|
||||||
use xous_ipc::{String, Buffer};
|
use xous_ipc::{String, Buffer};
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
|
@ -39,12 +38,12 @@ fn xmain() -> ! {
|
||||||
if debug1{info!("NS: received message");}
|
if debug1{info!("NS: received message");}
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(api::Opcode::Register) => {
|
Some(api::Opcode::Register) => {
|
||||||
let mut mem = msg.body.memory_message_mut().unwrap();
|
let mem = msg.body.memory_message_mut().unwrap();
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
||||||
let xous_string = buffer.try_into::<xous_ipc::String::<64>, _>().unwrap();
|
let xous_string = buffer.try_into::<String::<64>, _>().unwrap();
|
||||||
let name = XousServerName::from_str(xous_string.as_str().unwrap());
|
let name = XousServerName::from_str(xous_string.as_str());
|
||||||
|
|
||||||
let mut response: api::Return;
|
let response: api::Return;
|
||||||
|
|
||||||
if debug1{info!("NS: registration request for '{}'", name);}
|
if debug1{info!("NS: registration request for '{}'", name);}
|
||||||
if !name_table.contains_key(&name) {
|
if !name_table.contains_key(&name) {
|
||||||
|
|
@ -72,12 +71,12 @@ fn xmain() -> ! {
|
||||||
buffer.serialize_from(response).unwrap();
|
buffer.serialize_from(response).unwrap();
|
||||||
}
|
}
|
||||||
Some(api::Opcode::Lookup) => {
|
Some(api::Opcode::Lookup) => {
|
||||||
let mut mem = msg.body.memory_message_mut().unwrap();
|
let mem = msg.body.memory_message_mut().unwrap();
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
||||||
let name_string = buffer.try_into::<xous_ipc::String::<64>, _>().unwrap();
|
let name_string = buffer.try_into::<String::<64>, _>().unwrap();
|
||||||
let name = XousServerName::from_str(name_string.as_str().unwrap());
|
let name = XousServerName::from_str(name_string.as_str());
|
||||||
if debug1{info!("NS: Lookup request for '{}'", name);}
|
if debug1{info!("NS: Lookup request for '{}'", name);}
|
||||||
let mut response: api::Return;
|
let response: api::Return;
|
||||||
if let Some(server_sid) = name_table.get(&name) {
|
if let Some(server_sid) = name_table.get(&name) {
|
||||||
let sender_pid = msg
|
let sender_pid = msg
|
||||||
.sender
|
.sender
|
||||||
|
|
@ -112,7 +111,7 @@ fn xmain() -> ! {
|
||||||
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
|
// no authenticate remedy currently supported, but we'd put that code somewhere around here eventually.
|
||||||
let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32();
|
let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32();
|
||||||
let auth_request = AuthenticateRequest {
|
let auth_request = AuthenticateRequest {
|
||||||
name: name_string,
|
name: String::<64>::from_str(name_string.as_str()),
|
||||||
pubkey_id: [0; 20], // placeholder
|
pubkey_id: [0; 20], // placeholder
|
||||||
challenge: [c1, c2, c3, c4],
|
challenge: [c1, c2, c3, c4],
|
||||||
};
|
};
|
||||||
|
|
@ -121,9 +120,9 @@ fn xmain() -> ! {
|
||||||
buffer.serialize_from(response).unwrap();
|
buffer.serialize_from(response).unwrap();
|
||||||
}
|
}
|
||||||
Some(api::Opcode::AuthenticatedLookup) => {
|
Some(api::Opcode::AuthenticatedLookup) => {
|
||||||
let mut mem = msg.body.memory_message_mut().unwrap();
|
let mem = msg.body.memory_message_mut().unwrap();
|
||||||
let buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
let buffer = unsafe { Buffer::from_memory_message_mut(mem) };
|
||||||
let auth_lookup = buffer.try_into::<api::AuthenticatedLookup, _>().unwrap();
|
let auth_lookup: AuthenticatedLookup = buffer.deserialize().unwrap();
|
||||||
info!("NS: AuthenticatedLookup request {:?}", auth_lookup);
|
info!("NS: AuthenticatedLookup request {:?}", auth_lookup);
|
||||||
error!("NS: AuthenticatedLookup not yet implemented");
|
error!("NS: AuthenticatedLookup not yet implemented");
|
||||||
unimplemented!("NS: AuthenticatedLookup not yet implemented");
|
unimplemented!("NS: AuthenticatedLookup not yet implemented");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue