home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume28
/
m0
/
part01
/
neighbor.m0
< prev
next >
Wrap
Text File
|
1994-06-05
|
3KB
|
68 lines
# neighbor.m0
# Copyright (c) 1994 Christian F. Tschudin. All rights reserved.
#
# Distributed under the terms of the GNU General Public License
# version 2 of june 1991 as published by the Free Software
# Foundation, Inc.
#
# This file is part of M0.
#
# M0 is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY. No author or distributor accepts responsibility to anyone for
# the consequences of using it or for whether it serves any particular
# purpose or works at all, unless he says so in writing. Refer to the GNU
# General Public License for full details.
#
# Everyone is granted permission to copy, modify and redistribute M0, but
# only under the conditions described in the GNU General Public License.
# A copy of this license is supposed to have been given to you along with
# M0 so you can know your rights and responsibilities. It should be in a
# file named LICENSE. Among other things, the copyright notice and this
# notice must be preserved on all copies.
# neighbor discovery messenger
# to test it:
# start the console with % m0c neighbor.m0
# invoke the test procedure M0> eth_neighbors
# look at the result M(1)> ptop
. 'neighbors { # usage: brcast_proc back_proc neighbors array
; _ 1I D : # get a random key, link in globaldict a new dict to it
3 { P # send three times the discover messenger
2I! # get the broadcast channel
[2I # use the random key for the process queue field
# fill in here the string of the discovery messenger:
#includestring neigh_ex.m0
5I _cte # get an external representation of the back procedure
[ _ 7I G # create an array with all known host ids
{P}L ] _cte # and convert it to an external representation
+ # concat back procedure and array with hostids
] _ctm $ # assemble the discover messenger and broadcast it!
333333 # sleep for 1/3 second
;0I1QX1IXEP0Q # sleep (see the code in the M0 report)
} L
[ _ 2I G # build again the array of found hosts
{P}L ]
X _ X U # undefine the session dictionary
XPXP # pop the two initial arguments and return the array
} : # put the procedure's definition in the current dictionary
# call this procedure to test the exploration messenger via ethernet:
.'eth_neighbors {
{\ffffffffffff\ 0 {} # the three args for creating a local channel
_cha 'ether G '_key G !}
{ _ori2G _ori1G {} # same for remote host, but we obtain the
_cha _ori0G G '_key G !} # address of the source from the _ori field
neighbors # the main procedure call
} :
'printF { P # print a message only if the console is defined
"file `neighbor.m0' loaded\x0a" print
}{}?