upgrade name length to 64 characters

This commit is contained in:
bunnie 2021-01-05 16:53:19 +08:00
parent 0d869870ae
commit 73c4be0457
4 changed files with 18 additions and 11 deletions

View file

@ -356,7 +356,7 @@ fn shell_main() -> ! {
let registration = Registration::new();
let mut sendable_registration = Sendable::new(registration)
.expect("can't create sendable registration structure");
write!(sendable_registration.name, "A test Name!");
write!(sendable_registration.name, "A test Name!").unwrap();
info!("namserver registration input: {:?}", sendable_registration.success);
sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!");
info!("nameserver registration result: {:?}, {:?}", sendable_registration.success, sendable_registration.sid);
@ -367,7 +367,7 @@ fn shell_main() -> ! {
let mut sendable_lookup = Sendable::new(lookup)
.expect("can't create sendable lookup structure");
info!("making a test name");
write!(sendable_lookup.name, "A test Name!");
write!(sendable_lookup.name, "A test Name!").unwrap();
info!("nameserver lookup input: {:?}", sendable_lookup.success);
sendable_lookup.lend_mut(ns_conn, sendable_lookup.mid()).expect("nameserver lookup failure!");
info!("nameserver lookup result: {:?}, {:?}", sendable_lookup.success, sendable_lookup.cid);

View file

@ -1,7 +1,7 @@
#![allow(dead_code)]
use xous::{SID, CID};
use hash32_derive::*;
use hash32::{Hash, Hasher};
use core::cmp::Eq;
@ -13,13 +13,23 @@ pub const AUTHENTICATE_TIMEOUT: usize = 10_000; // time in ms that a process has
//////////////////////// handle throwing strings across IPC boundary with hash comparison
#[derive(Hash32, Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub struct XousServerName {
pub name: [u8; 32],
pub name: [u8; 64],
pub length: usize,
}
impl hash32::Hash for XousServerName {
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
Hash::hash(&self.name[..], state);
Hash::hash(&self.length, state)
}
}
impl XousServerName {
pub fn new() -> Self {
Default::default()
@ -36,7 +46,7 @@ impl XousServerName {
impl Default for XousServerName {
fn default() -> Self {
XousServerName {
name: [0; 32],
name: [0; 64],
length: 0,
}
}

View file

@ -11,9 +11,7 @@ Calls are made using the xous::ipc::Sendable IPC wrapper, for example:
let mut sendable_registration = Sendable::new(registration)
.expect("can't create sendable registration structure");
let test_name = b"A test Name!";
sendable_registration.name[..test_name.len()].clone_from_slice(test_name);
sendable_registration.name_len = test_name.len();
write!(sendable_registration.name, "I'm a server, call me Fred!");
sendable_registration.lend_mut(ns_conn, sendable_registration.mid());

View file

@ -6,8 +6,7 @@ extern crate hash32_derive;
mod api;
use api::*;
use heapless::String;
use heapless::Vec;
// use heapless::String;
use heapless::FnvIndexMap;
use heapless::consts::*;