Reading the IP/TCP routing tables from memory
David L. Kashtan
kashtan at sri-iu.UUCP
Wed Nov 21 18:20:30 AEST 1984
Under EUNICE, nlist() will indeed read the ETC:INET.STB symbol table.
Since the network data structures in the kernel may contain sensitive
information, they are specifically kept KERNEL-MODE access only. The
following routines implement klseek()/klread() which act like lseek/read
on /dev/kmem.
David
/*
* /dev/kmem seek/read
*/
static char *current_addr = 0; /* Our current Seek address */
klseek(dummy,addr,whence)
char *addr;
{
current_addr = addr; /* Just stash the desired address */
}
static char *klread_buffer; /* User buffer to read into */
static int klread_size; /* User buffer size */
klread(dummy,buffer,size)
char *buffer;
{
extern klread_krnl();
/*
* Fill in arguments to the kernel mode code
*/
klread_buffer = buffer;
klread_size = size;
/*
* Fetch the kernel data in kernel mode
*/
sys$cmkrnl(klread_krnl,0);
/*
* Return the given size (just to be consistent with read)
*/
return(size);
}
/*
* This is executed in kernel mode
* (since network data structures are protected from casual user access)
*/
static klread_krnl()
{
register char *cp,*cp1;
register int i;
cp1 = klread_buffer;
cp = current_addr;
i = klread_size;
while(i > 0) {
if (kl_prober(cp)) *cp1++ = *cp++;
current_addr++;
i--;
}
return;
}
static kl_prober(cp)
{
/*
* Change our previous mode to KERNEL so that the probe
* will check for kernel read access -- construct a new
* PSL/PC on the stack and REI to it
*/
asm(" clrl -(sp)");
asm(" movab 1f,-(sp)");
asm(" rei");
/*
* Now check for read access
*/
asm("1: prober $0,$4,*4(ap)");
asm(" bneq 2f");
asm(" clrl r0");
asm(" ret");
asm("2: movl $1,r0");
asm(" ret");
}
--
David Kashtan, Artificial Intelligence Center, SRI International
ARPA: Kashtan at SRI-IU or Kashtan at SRI-AI
UUCP: {lbl-csam, sri-unix, cmcl2} !sri-iu!kashtan
More information about the Comp.os.eunice
mailing list