[comp.sys.apollo] Node id from C

ccsmm@gdt.bath.ac.uk (Martin Maclaren) (05/22/91)

What system call returns the node id of current machine?
(or isn't it as simple as that!)

bldt & lcnode seem to call asknode_$info which sounds right but
doesn't appear to be documented anywhere.

Martin

thompson@PAN.SSEC.HONEYWELL.COM (John Thompson) (05/23/91)

> What system call returns the node id of current machine?
> (or isn't it as simple as that!)
It isn't as simple as that.
 
> bldt & lcnode seem to call asknode_$info which sounds right but
> doesn't appear to be documented anywhere.
The asknode_$xxx calls are the magic, undocumented calls that allow Apollos
to exchange so much info.  Just about anything you can think of can be asked
for with them.  Unfortunately, Apollo has seen fit to not provide documentation,
because they want the ability to modify them at will.  (Actually, I think
they just don't want people to build the neatest, greatest tools around -- they
wanted to do it themselves.)   ;-)

-- jt --
John Thompson
Honeywell, SSEC
Plymouth, MN  55441
thompson@pan.ssec.honeywell.com

When in danger, when in doubt --
run in circles, scream and shout.

dbfunk@ICAEN.UIOWA.EDU (David B Funk) (05/23/91)

in posting <1991May22.161837.23276@gdt.bath.ac.uk>, Martin Maclaren asks:

> What system call returns the node id of current machine?
> (or isn't it as simple as that!)

If you want to be safe and stick with released Apollo system calls,
then you can do a "proc2_$who_am_i" to get the Apollo UID of your
process and then munge it around to extract the bottom 20 bits
(which will be your node ID).

However for a quick and simple whack, try:

extern void msg_$get_my_node(
    int *node_id
);

It's not released but it's simple and relatively safe.

The asknode_$xxx calls are complex and powerful but also dangerous.
It is possible to make a mess of your network by misusing them
and they are subject to change from OS release to release. I'd reccomend
staying away from them unless you like to look for trouble (of course
some of us do ;=).

Dave Funk

philip@cel.cummins.com (Philip D. Pokorny) (05/23/91)

Dave Funk mentions:

----------
However for a quick and simple whack, try:

extern void msg_$get_my_node(
    int *node_id
);

It's not released but it's simple and relatively safe.
----------

Another way might be:

   int  node_id ;
   sscanf( getenv( "NODEID" ), "NODEID=%x", &node_id );

Before SR10 NODEID was a "protected" environment variable that
you could count on not to change and to be correct...  At SR10
you *can* change the value of this variable but I wouldn't want
to speculate on what might or might not break...  In short it
should be fairly reliable...

Sincerely,
Philip D. Pokorny
philip@cel.cummins.com
:)

ruben@bcstec.boeing.com (Reuben Wachtfogel) (05/24/91)

Just in case you wanted the node NAME,

name_$get_path_lc for getting the full pathname
to / will return //nodename/.

proc2_$who_am_i is the one for node ID masking
uid.low & 0xfffff and of course sprintf(id,"%x"..

thompson@PAN.SSEC.HONEYWELL.COM (John Thompson) (05/24/91)

> Just in case you wanted the node NAME,
> 
> name_$get_path_lc for getting the full pathname
> to / will return //nodename/.
This will, of course, fail for diskless nodes (return the partner's name).

-- jt --
John Thompson
Honeywell, SSEC
Plymouth, MN  55441
thompson@pan.ssec.honeywell.com

When in danger, when in doubt --
run in circles, scream and shout.