=== modified file 'address_manager.vala' --- address_manager.vala 2012-04-28 10:09:24 +0000 +++ address_manager.vala 2012-07-01 06:01:27 +0000 @@ -21,10 +21,11 @@ namespace Ntk.Core { - /** The class IGSManagerDispatcher will be instantiated in each AddressManager. - * Forward the call to the remotable method got_list_inetgw to the one instance of IGSManager - * only if we are the primary AddressManager. - */ + /** + * The class IGSManagerDispatcher will be instantiated in each AddressManager. + * Forward the call to the remotable method got_list_inetgw to the one instance of IGSManager + * only if we are the primary AddressManager. + */ public class IGSManagerDispatcher : Object { private AddressManager address_manager; @@ -37,7 +38,7 @@ // TODO self.remotable_funcs = [self.got_list_inetgw] } -// TODO +// TODO: write this python snippet in vala /* def got_list_inetgw(self, *args, **kargs): if self.address_manager.is_primary: @@ -544,64 +545,78 @@ return new CoupleAddressManagerFakeRmt(real_bc, pseudo_bc); } - /** This method can be overriden when we want to own an address with which - * we want to be used as a gateway only by certain nodes. - * In its default implementation, we accept any node. - */ + /** + * This method can be overriden when we want to own an address with which + * we want to be used as a gateway only by certain nodes. + * In its default implementation, we accept any node. + * @param nip The netsukuku ip + * @param nodeid the node id (Of the requesting node of this?) + * @param netid The network ID + */ public virtual bool do_i_act_as_gateway_for(NIP nip, int nodeid, NetworkID netid) { if (! operative) return false; // change behaviour when going down. return true; } - /** This method can be overriden when we want to own an address with which - * we do not want to be used as a gateway by other local addresses. - * In its default implementation, we accept them. - */ + /** + * This method can be overriden when we want to own an address with which + * we do not want to be used as a gateway by other local addresses. + * In its default implementation, we accept them. + */ public virtual bool do_i_act_as_gateway_for_local() { return true; } - /** This method can be overriden when we do not want to - * be considered in forming the kernel routing tables. - * In its default implementation returns True. - */ + /** + * This method can be overriden when we do not want to + * be considered in forming the kernel routing tables. + * In its default implementation returns True. + * TODO Implement something here + */ public virtual bool do_i_participate_in_routing_tables() { return true; } - /** My GNode ID list - */ + /** + * My GNode ID list + */ public GNodeID[] get_gid_list() { return maproute.get_gid_list(); } - /** My node ID - */ + /** + * My node ID + */ public int get_my_id() { return maproute.get_my_id(); } - /** The netid of the uppermost level - */ + /** + * The netid of the uppermost level + */ public NetworkID get_main_netid() { return maproute.get_main_netid(); } - /** Is this netid in my network - */ + /** + * Is this netid in my network + * @param netid the network Id + */ public bool is_in_my_network(NetworkID netid) { return maproute.is_in_my_network(netid); } - /** Is this netid preferred over mine - */ + /** + * Is this netid preferred over mine + * @param netid The network Id + */ public bool is_preferred_network(NetworkID netid) { return maproute.is_preferred_network(netid); === modified file 'addresses.vala' --- addresses.vala 2012-04-28 10:09:24 +0000 +++ addresses.vala 2012-07-01 06:04:59 +0000 @@ -38,9 +38,10 @@ } - /** This class is instantiated once in the whole app. Keeps track of all the - * addresses that this node may obtain for itself. - */ + /** + * This class is instantiated once in the whole app. Keeps track of all the + * addresses that this node may obtain for itself. + */ public class Addresses : Object { private static Addresses addresses_instance; @@ -597,30 +598,32 @@ } } - /** Gathers all available paths and places them in instances of CondensedPathChooser - * which makes it easy to find the best path (optionally not passing through a - * neighbour of ours) - */ + /** + * Gathers all available paths and places them in instances of CondensedPathChooser + * which makes it easy to find the best path (optionally not passing through a + * neighbour of ours) + */ public CondensedMapRoute get_condensed_map_route() { - /* Since we have maproutes, that is addresses: - * E.g. we have [4,3,2,1], [7,6,5,2] and [7,8,9,2] - * At level 3 we have ids [1] and [2]; hence we do not have - * to store paths towards 1.* and 2.*. We do have to store - * paths towards 5.* for instance. We have to look for them in all - * the maproutes that we have got. - * At level 2, we have 2 sets of addresses: the first contains the - * addresses prefixed with [1] and the second one contains those prefixed - * with [2]. For instance, in the second set we have 2 ids, [5,2] and [9,2] - * Thus, we do not have to store paths towards [5,2] and [9,2]. We do - * have to store paths towards [8,2] for instance. We have to look for - * them in the maproutes prefixed with [2] - * So, abstracting, at each level from the uppermost to the lowermost, - * for each destination that is not in our own ids, we take all the paths - * available from all the maproutes and populate one "PathChooser". - * Furthermore we do not consider the paths that have as gateway one of - * our own addresses. And we do consider only one path per gateway per destination. - */ + /* + * Since we have maproutes, that is addresses: + * E.g. we have [4,3,2,1], [7,6,5,2] and [7,8,9,2] + * At level 3 we have ids [1] and [2]; hence we do not have + * to store paths towards 1.* and 2.*. We do have to store + * paths towards 5.* for instance. We have to look for them in all + * the maproutes that we have got. + * At level 2, we have 2 sets of addresses: the first contains the + * addresses prefixed with [1] and the second one contains those prefixed + * with [2]. For instance, in the second set we have 2 ids, [5,2] and [9,2] + * Thus, we do not have to store paths towards [5,2] and [9,2]. We do + * have to store paths towards [8,2] for instance. We have to look for + * them in the maproutes prefixed with [2] + * So, abstracting, at each level from the uppermost to the lowermost, + * for each destination that is not in our own ids, we take all the paths + * available from all the maproutes and populate one "PathChooser". + * Furthermore we do not consider the paths that have as gateway one of + * our own addresses. And we do consider only one path per gateway per destination. + */ CondensedMapRoute ret_value = new CondensedMapRoute(); get_structure(ref ret_value); return ret_value; @@ -707,8 +710,9 @@ } } - /** Gathers all available real neighbours in my network - */ + /** + * Gathers all available real neighbours in my network + */ public CondensedNeighbours get_condensed_neighbours() { HashMap neighbours = new HashMap(); @@ -749,8 +753,9 @@ return ret; } - /** Gathers all available real incoming nodes in my network - */ + /** + * Gathers all available real incoming nodes in my network + */ public CondensedIncomingNodeContainer get_condensed_incoming_nodes() { HashMap incomings = new HashMap(); @@ -802,8 +807,9 @@ } } - /** List of paths towards a certain destination. - */ + /** + * List of paths towards a certain destination. + */ public class CondensedPathChooser : Object { public ArrayList paths; @@ -910,9 +916,10 @@ } } - /** A list of all the real neighbours (not my addresses) and for - * each nip just one CondensedNeighbour with all the macs. - */ + /** + * A list of all the real neighbours (not my addresses) and for + * each nip just one CondensedNeighbour with all the macs. + */ public class CondensedNeighbours : Object { public ArrayList neighbours_list; @@ -998,9 +1005,10 @@ } } - /** A list of all the incoming nodes and for - * each nip just one CondensedIncomingNode with all the macs. - */ + /** + * A list of all the incoming nodes and for + * each nip just one CondensedIncomingNode with all the macs. + */ public class CondensedIncomingNodeContainer : Object { public ArrayList nodes_list; === modified file 'aggregated_neighbour.vala' --- aggregated_neighbour.vala 2012-04-28 10:09:24 +0000 +++ aggregated_neighbour.vala 2012-07-01 05:54:30 +0000 @@ -21,10 +21,10 @@ namespace Ntk.Core { - public errordomain AggregatedNeighbourError { - DUPLICATE_INSERT, - MISSING_REMOVE - } + public errordomain AggregatedNeighbourError { + DUPLICATE_INSERT, + MISSING_REMOVE + } struct struct_helper_AggregatedNeighbour_tcp_client_collect { @@ -32,21 +32,25 @@ public TCPClient tcp_client; } - /** This class simply represent a neighbour. - * Each instance of this class represents a neighbour as seen by any number of nics - * of this node associated to a certain address. - */ + /** + * This class simply represent a neighbour. + * Each instance of this class represents a neighbour as seen by any number of nics + * of this node associated to a certain address. + */ public class AggregatedNeighbour : Object { - /** nip: neighbour's nip; - * nodeid: id of the node - * nip + nodeid = unique key. - * levels, gsize, netid: attributes of the network - * interfaces: a dict - * macs: a sequence of string: the MAC of the nics of the neighbour that I can see through my nics "interfaces"; - * there could be more than one. - * rpcdispatcher is valorized for neighbours that represent one of my addresses. it is used to make an instance of PseudoNeighbourClient. - */ + /** + *{{{ + * nip: neighbour's nip; + * nodeid: id of the node + * | nip + nodeid = unique key. + * levels, gsize, netid: attributes of the network + * interfaces: a dict + * macs: a sequence of string: the MAC of the nics of the neighbour that I can see through my nics "interfaces"; + * | there could be more than one. + * rpcdispatcher is valorized for neighbours that represent one of my addresses. it is used to make an instance of PseudoNeighbourClient. + *}}} + */ public int levels; public int gsize; public NIP nip; @@ -183,7 +187,9 @@ catch (RPCError e) {} } - /* Decoration of microfunc */ + /* + * Decoration of microfunc + */ private static void * helper_tcp_client_collect(void *v) throws Error { struct_helper_AggregatedNeighbour_tcp_client_collect *tuple_p = (struct_helper_AggregatedNeighbour_tcp_client_collect *)v; @@ -367,7 +373,9 @@ public signal void aggregated_neighbour_colliding_going_deleted(AggregatedNeighbour aggregated_neighbour); public signal void aggregated_neighbour_colliding_going_rem_chged(AggregatedNeighbour aggregated_neighbour); - /** Radar functions **/ + /** + * Radar functions + **/ public void reply(Object? _rpc_caller, int radar_id, NIP nip, int nodeid, NetworkID netid) throws RPCError { assert(_rpc_caller != null); @@ -420,8 +428,10 @@ } } - /** Inserts this neighbour in our data structures. - */ + /** + * Inserts this neighbour in our data structures. + * @param val The neighbour to insert + */ private void memorize(AggregatedNeighbour val) throws AggregatedNeighbourError { // key = (tuple(val.nip), val.nodeid) @@ -435,8 +445,11 @@ tnip_nodeid_table[skey] = val; } - /** Removes this neighbour in our data structures. - */ + /** + * Removes this neighbour in our data structures. + * ATTENTION: this method MUST NOT pass schedule until the end. + * @param skey pair tuple(nip), nodeid. should be in tnip_nodeid_table. + */ private void unmemorize(string skey) throws AggregatedNeighbourError { // key: pair tuple(nip), nodeid @@ -449,8 +462,11 @@ tnip_nodeid_table.unset(skey); } - /** return a AggregatedNeighbour object from its nip and nodeid - */ + /** + * return a AggregatedNeighbour object from its nip and nodeid + * @param nip The netsukuku address + * @param nodeid The node id. + */ public AggregatedNeighbour? key_to_neighbour(NIP nip, int nodeid) { string skey = tnip_nodeid_key(nip, nodeid); @@ -458,13 +474,18 @@ else return tnip_nodeid_table[skey]; } - /** Returns the list of neighbours. - * If with_this_netid is not None, then returns only nodes - * that are in the network with this netid. - * Else, if in_my_network is not None, then returns only nodes - * that are in my network (compared with all the GID of last level). - * Else all the neighbours are returned. - */ + /** + *{{{ + * Returns the list of neighbours. + * If with_this_netid is not None, then returns only nodes + * | that are in the network with this netid. + * Else, if in_my_network is not None, then returns only nodes + * | that are in my network (compared with all the GID of last level). + * Else all the neighbours are returned. + *}}} + * @param in_my_network return only nodes in my network. + * @param with_this_netid return nodes in that netid, or entire network if null. + */ public Gee.List neighbour_list(bool? in_my_network=null, NetworkID? with_this_netid=null) { ArrayList nlist = new ArrayList((EqualFunc)AggregatedNeighbour.equal_func); @@ -662,9 +683,10 @@ ch.send_async(arg); } - /** Take the list of known neighbours from all the NICs associated and build - * my internal data structures. - */ + /** + * Take the list of known neighbours from all the NICs associated and build + * my internal data structures. + */ public void initialize() { HashMap> map_list_neighbour = new HashMap>(); @@ -732,8 +754,10 @@ store_add_neighbour(key, map_aggregated_neighbour[key]); } - /** A neighbour is going to be added in a nic. - */ + /** + * A neighbour is going to be added in a nic. (TODO Not implemented) + * @param neighbour The neighbour which is going to be added + */ public void nic_going_add_neighbour(Neighbour neighbour) { // This listener, which is not microfunc, is called and executed @@ -742,8 +766,10 @@ // Right now, we don't use it. } - /** A neighbour is going to be rem_chged in a nic. - */ + /** + * A neighbour is going to be rem_chged in a nic.(TODO Not implemented) + * @param neighbour The neighbour which is going to be removed or changed + */ public void nic_going_rem_change_neighbour(Neighbour neighbour) { // This listener, which is not microfunc, is called and executed @@ -752,8 +778,9 @@ // Right now, we don't use it. } - /** A neighbour is going to be deleted in a nic. - */ + /** + * A neighbour is going to be deleted in a nic. + */ public void nic_going_delete_neighbour(Neighbour neighbour) { // This listener, which is not microfunc, is called and executed @@ -762,8 +789,10 @@ // Right now, we don't use it. } - /** A neighbour has been added in a nic. - */ + /** + * A neighbour has been added in a nic. + * @param neighbour the neighbour + */ public void nic_add_neighbour(Neighbour neighbour) { // This listener, which could be a microfunc, is called @@ -808,8 +837,11 @@ } } - /** A neighbour has been rem_chged in a nic. - */ + /** + * A neighbour has been rem_chged in a nic. + * @param neighbour the neighbour which is changed or removed + * @param old_rem ??? + */ public void nic_rem_change_neighbour(Neighbour neighbour, REM old_rem) { // This listener, which could be a microfunc, is called @@ -854,8 +886,10 @@ } } - /** A neighbour has been deleted in a nic. - */ + /** + * A neighbour has been deleted in a nic. + * @param neighbour The neighbour deleted + */ public void nic_delete_neighbour(Neighbour neighbour) { // This listener, which could be a microfunc, is called @@ -886,8 +920,10 @@ } } - /** Emits signal BEFORE a new neighbour. - */ + /** + * Emits signal BEFORE a new neighbour. + * @param aggregated_neighbour The neighbour which is going to be added + */ public void going_add_neighbour(AggregatedNeighbour aggregated_neighbour) { string ipstr = nip_to_str(aggregated_neighbour.levels, aggregated_neighbour.gsize, aggregated_neighbour.nip); @@ -905,8 +941,10 @@ } } - /** Emits signal BEFORE a dead neighbour. - */ + /** + * Emits signal BEFORE a dead neighbour. + * @param aggregated_neighbour The neighbour which is going to be deleted + */ public void going_delete_neighbour(AggregatedNeighbour aggregated_neighbour) { string ipstr = nip_to_str(aggregated_neighbour.levels, aggregated_neighbour.gsize, aggregated_neighbour.nip); @@ -924,8 +962,10 @@ } } - /** Emits signal BEFORE a changed rem neighbour. - */ + /** + * Emits signal BEFORE a changed rem neighbour. + * @param aggregated_neighbour The neighbour which is going to be changed + */ public void going_rem_change_neighbour(AggregatedNeighbour aggregated_neighbour) { string ipstr = nip_to_str(aggregated_neighbour.levels, aggregated_neighbour.gsize, aggregated_neighbour.nip); @@ -943,8 +983,10 @@ } } - /** Emits signal for a new neighbour. - */ + /** + * Emits signal for a new neighbour. + * @param key A tuples (Address and nic?) + */ public void add_neighbour(string key) { AggregatedNeighbour aggregated_neighbour = tnip_nodeid_table[key]; @@ -964,8 +1006,11 @@ } } - /** Emits signal for a dead neighbour. - */ + /** + * Emits signal for a dead neighbour. + * @param key The address and nic pair ? + * @param old_val ??? + */ public void delete_neighbour(string key, AggregatedNeighbour old_val) { AggregatedNeighbour aggregated_neighbour = old_val; @@ -985,8 +1030,11 @@ } } - /** Emits signal for a changed rem neighbour. - */ + /** + * Emits signal for a changed rem neighbour. + * @param key Address and nic + * @param old_rem ??? + */ public void rem_change_neighbour(string key, REM old_rem) { AggregatedNeighbour aggregated_neighbour = tnip_nodeid_table[key]; === modified file 'andna.vala' --- andna.vala 2012-04-28 10:07:10 +0000 +++ andna.vala 2012-06-28 18:53:53 +0000 @@ -25,7 +25,9 @@ { public Andna self; } - + /** + * The Netsukuku dns implementation, see: [[http://netsukuku.freaknet.org/doc/main_doc/andna.pdf]] + */ public class Andna : OptionalPeerToPeer { public static const int mypid = 3; === modified file 'auxiliary.vala' --- auxiliary.vala 2012-03-09 14:52:11 +0000 +++ auxiliary.vala 2012-06-28 03:17:17 +0000 @@ -23,8 +23,9 @@ namespace Ntk.Core { - /** Instance of AddressManager for auxiliary addresses. - */ + /** + * Instance of AddressManager for auxiliary addresses. + */ public class AuxiliaryAddressManager : AddressManager { public weak AddressManager autonomous_address_manager {get; private set;} === modified file 'bnodetunneling.vala' --- bnodetunneling.vala 2012-03-09 14:52:11 +0000 +++ bnodetunneling.vala 2012-06-28 03:14:09 +0000 @@ -23,8 +23,9 @@ namespace Ntk.Core { - /** Instance of AddressManager for BnodeTunneling addresses. - */ + /** + * Instance of AddressManager for BnodeTunneling addresses. + */ public class BnodeTunnelingAddressManager : AuxiliaryAddressManager { public PartialNIP gnode_tunneling {get; private set;} @@ -492,8 +493,9 @@ } } - /** Derivated classes for the pseudo-nic in the autonomous address manager which we are tied to. - */ + /** + * Derivated classes for the pseudo-nic in the autonomous address manager which we are tied to. + */ public class TunneledNetworkInterfaceManager : NetworkInterfaceManager { === modified file 'border_nodes.vala' --- border_nodes.vala 2012-04-28 10:09:24 +0000 +++ border_nodes.vala 2012-07-01 05:31:23 +0000 @@ -22,9 +22,10 @@ namespace Ntk.Core { - /** The return value of the method get_distances - * is a list of tuple (NIP nip, int distance) - */ + /** + * The return value of the method get_distances + * is a list of tuple (NIP nip, int distance) + */ public class PairNipDistance : Object, ISerializable { public NIP nip; @@ -103,8 +104,9 @@ public AuxiliaryAddressManager addr_man; } - /** This class handles things that a border-node has to do - */ + /** + * This class handles things that a border-node has to do + */ public class BorderNodesManager : Object, IBorderNodesManager { public weak AddressManager address_manager {get; private set;} @@ -211,8 +213,9 @@ return ret; } - /** Tasklet to let a Coordinator know if I become a border node. - */ + /** + * Tasklet to let a Coordinator know if I become a border node. + */ protected virtual void impl_run(int level_of_gnode) throws Error { // Override in BnodeTunneling, do nothing @@ -306,9 +309,10 @@ Tasklet.spawn((FunctionDelegate)helper_run, &arg); } - /** Called in a autonomous_address from a Coordinator. - * Get distance from other nodes inside 'gnode' - */ + /** + * Called in a autonomous_address from a Coordinator. + * Get distance from other nodes inside 'gnode' + */ public Gee.List get_distances(Object? _rpc_caller, PartialNIP gnode, Gee.List list_of_nips) throws BorderNodesError { @@ -342,9 +346,13 @@ return ret; } - /** Called in a autonomous_address from a Coordinator. - * Obtain a new address to create a virtual link in order to increase connectivity inside 'gnode' - */ + /** + * Called in a autonomous_address from a Coordinator. + * Obtain a new address to create a virtual link in order to increase connectivity inside 'gnode' + * @param _rpc_caller The caller rpc + * @param gnode The group node + * @param peer_nip the peer netsukuku ip + */ public NIP get_new_address(Object? _rpc_caller, PartialNIP gnode, NIP? peer_nip=null) throws BorderNodesError { assert(_rpc_caller != null); @@ -406,9 +414,12 @@ return new_addr_man.maproute.me; } - /** Called in a autonomous_address from a Coordinator. - * Pass the peer nip to the previously created auxiliary address manager. - */ + /** + * Called in a autonomous_address from a Coordinator. + * Pass the peer nip to the previously created auxiliary address manager. + * @param nip_x_secondary ??? + * @param nip_y_secondary ??? + */ public void assign_peer_nip(NIP nip_x_secondary, NIP nip_y_secondary) { foreach (AddressManager addr_man in address_manager.auxiliary_addresses) @@ -576,8 +587,13 @@ return null; } - /** Called in a autonomous_address from a local auxiliary address to confirm that we got a tunnel - */ + /** + * Called in a autonomous_address from a local auxiliary address to confirm that we got a tunnel + * @param sec_addr_man ??? + * @param peer_addr ??? + * @param nic_name ??? + * @param level_of_gnode ??? + */ public void tunnel_created(AuxiliaryAddressManager sec_addr_man, string peer_addr, string nic_name, int level_of_gnode) { struct_helper_BorderNodesManager_tunnel_created arg = struct_helper_BorderNodesManager_tunnel_created(); @@ -589,17 +605,19 @@ Tasklet.spawn((FunctionDelegate)helper_tunnel_created, &arg); } - /** Called in a autonomous_address to see if it has a auxiliary address doing tunnel - * (or preparing to do) for this gnode - */ + /** + * Called in a autonomous_address to see if it has a auxiliary address doing tunnel + * (or preparing to do) for this gnode + */ public bool has_tunnel(int level_of_gnode) { return running_tunnel.has_key(level_of_gnode) || waiting_tunnel.has_key(level_of_gnode); } - /** Called in a autonomous_address to see if it has a auxiliary address doing tunnel - * (or preparing to do) at any level - */ + /** + * Called in a autonomous_address to see if it has a auxiliary address doing tunnel + * (or preparing to do) at any level + */ public bool has_any_tunnel() { for (int level_of_gnode = 1; level_of_gnode < maproute.levels; level_of_gnode++) @@ -609,8 +627,9 @@ return false; } - /** Called in a autonomous_address to see if it is willing to do tunnel - */ + /** + * Called in a autonomous_address to see if it is willing to do tunnel + */ public bool is_willing() { // If I have already a running tunnel, I refuse. === modified file 'channel.vala' --- channel.vala 2012-05-25 15:50:13 +0000 +++ channel.vala 2012-06-28 01:08:07 +0000 @@ -25,18 +25,19 @@ GENERIC } - /** A Channel object is used for bidirectional communication between tasklets. + /** + * A Channel object is used for bidirectional communication between tasklets. * * Features: - * * an object sent through an instance of Channel can be received only through the same instance of Channel; - * * an instance of Channel can have a name, and can be obtained by that name (static method find); - * * it is possible to send a message without blocking the current tasklet; not even scheduling; - * * it is possible for a tasklet to wait for a message to be received from a Channel; - * it is guaranteed that the order with which several tasklets wait a message is respected in the - * dispatching of messages; it is also possible for the tasklet to specify a timeout when waiting for a message; - * * it is possible to send a message and block the sending tasklet until the message is received; - * * it is possible to know how many messages are in a Channel to be received or - * how many tasklets are waiting to receive in a Channel (property balance) + * | * an object sent through an instance of Channel can be received only through the same instance of Channel; + * | * an instance of Channel can have a name, and can be obtained by that name (static method find); + * | * it is possible to send a message without blocking the current tasklet; not even scheduling; + * | * it is possible for a tasklet to wait for a message to be received from a Channel; + * | it is guaranteed that the order with which several tasklets wait a message is respected in the + * | dispatching of messages; it is also possible for the tasklet to specify a timeout when waiting for a message; + * | * it is possible to send a message and block the sending tasklet until the message is received; + * | * it is possible to know how many messages are in a Channel to be received or + * | how many tasklets are waiting to receive in a Channel (property balance) */ public class Channel:Object { @@ -74,7 +75,8 @@ return null; } - /** A positive value indicates messages waiting to be received. + /** + * A positive value indicates messages waiting to be received. * A negative value indicates tasklets waiting to receive a message. */ public int balance { === modified file 'coord.vala' --- coord.vala 2012-04-28 10:09:24 +0000 +++ coord.vala 2012-07-01 05:24:49 +0000 @@ -38,8 +38,9 @@ public const int COORD_DUPLICATION = 10; public const int MAX_BNODES = 50; - /** Represents a booking for a position in a given level of the map. - */ + /** + * Represents a booking for a position in a given level of the map. + */ public class BookingRecord : Object, ISerializable { public int pos {get; private set;} @@ -82,8 +83,9 @@ } } - /** Collects the bookings of a certain gnode. - */ + /** + * Collects the bookings of a certain gnode. + */ public class Bookings : Object, ISerializable { public PartialNIP gnode {get; private set;} @@ -91,10 +93,11 @@ public Bookings(PartialNIP gnode) { - /* PartialNIP of the gnode, e.g. with 4 levels: [-1,-1,-1,-1] is the whole network - * [-1,-1,2,3] is the gnode 3,2 - * [0,1,2,3] is the node 3,2,1,0 which belongs to the gnode 3,2. - */ + /* + * PartialNIP of the gnode, e.g. with 4 levels: [-1,-1,-1,-1] is the whole network + * [-1,-1,2,3] is the gnode 3,2 + * [0,1,2,3] is the node 3,2,1,0 which belongs to the gnode 3,2. + */ this.gnode = gnode; records = new ArrayList((EqualFunc)BookingRecord.equal_func); } @@ -258,8 +261,9 @@ } } - /** Collects the bookings of a certain gnode. - */ + /** + * Collects the bookings of a certain gnode. + */ public class BnodeList : Object, ISerializable { public PartialNIP gnode {get; private set;} @@ -268,10 +272,11 @@ public BnodeList(PartialNIP gnode) { - /* PartialNIP of the gnode, e.g. with 4 levels: [-1,-1,-1,-1] is the whole network - * [-1,-1,2,3] is the gnode 3,2 - * [0,1,2,3] is the node 3,2,1,0 which belongs to the gnode 3,2. - */ + /* + * PartialNIP of the gnode, e.g. with 4 levels: [-1,-1,-1,-1] is the whole network + * [-1,-1,2,3] is the gnode 3,2 + * [0,1,2,3] is the node 3,2,1,0 which belongs to the gnode 3,2. + */ this.gnode = gnode; max_bnodes = MAX_BNODES; records = new ArrayList((EqualFunc)BnodeRecord.equal_func); @@ -397,9 +402,10 @@ } } - /** An instance of this class contains all the kind of knowledge that - * a Coordinator of a certain gnode may have. - */ + /** + * An instance of this class contains all the kind of knowledge that + * a Coordinator of a certain gnode may have. + */ public class CoordinatorKnowledge : Object, ISerializable { public PartialNIP gnode {get; private set;} @@ -445,8 +451,9 @@ } } - /** A CoordinatorKnowledgeSet is a dictionary - */ + /** + * A CoordinatorKnowledgeSet is a dictionary + */ public class CoordinatorKnowledgeSet : Object, ISerializable { public HashMap dict; @@ -646,9 +653,10 @@ return new RmtCoordPeer(this, key, hIP, aggregated_neighbour); } - /** This method could be called *directly* for a dispatcher that does not need to transform - * an exception into a remotable. - */ + /** + * This method could be called *directly* for a dispatcher that does not need to transform + * an exception into a remotable. + */ public override ISerializable _dispatch(Object? caller, RemoteCall data) throws Error { Logger.ultradebug(@"$(this.get_type().name()): dispatching $data"); @@ -824,17 +832,20 @@ return get_coordinator_for_gnode_at_level(level_of_gnode); } - /** Client-side helpers **/ + /** + * Client-side helpers + **/ public HookReservation? enter_into(int level_of_gnode, NIP nip, AggregatedNeighbour? neighbour_to_contact) { - /** I have a neighbour whose nip is 'nip' (could be - * of a different network with different levels - * and gsize for example) and it said that its gnode of - * level 'level_of_gnode' has some free space. - * I try to get to the coordinator passing through - * neighbour_to_contact (could be another neighbour) - */ + /** + * I have a neighbour whose nip is 'nip' (could be + * of a different network with different levels + * and gsize for example) and it said that its gnode of + * level 'level_of_gnode' has some free space. + * I try to get to the coordinator passing through + * neighbour_to_contact (could be another neighbour) + */ Coord_hkey key = new Coord_hkey(); key.level_of_gnode = level_of_gnode; key.nip = nip; @@ -873,8 +884,9 @@ return coordinator.get_bnode_list(); } - /** Remotables **/ - + /** + * Remotables + **/ public HookReservation? reserve(PartialNIP gnode) throws HookingError { Coordinator coordinator = get_coordinator_for_gnode(gnode); @@ -908,10 +920,13 @@ return coordinator.register_bnode(nip, is_border, has_tunnel, is_willing); } - /** Handling events **/ + /** + * Handling events + **/ - /** A new node in the service - */ + /** + * A new node in the service + */ public void node_joins_maproute(int level_of_nodes, int pos) { int level_of_gnode = level_of_nodes + 1; @@ -962,8 +977,11 @@ Tasklet.spawn((FunctionDelegate)helper_communicate_to_new_coordinator, &arg); } - /** A deleted node in the service - */ + /** + * A deleted node in the service + * @param level_of_nodes The 'distance' or level of the exiting node + * @param pos the node id in it's gnode + */ public void node_exits_maproute(int level_of_nodes, int pos) { int level_of_gnode = level_of_nodes + 1; @@ -971,8 +989,9 @@ coordinator.map_has_changed(); } - /** We now have a valid map, I could have become a coordinator - */ + /** + * We now have a valid map, I could have become a coordinator + */ public void coord_has_valid_map() { for (int level_of_gnode = 1; level_of_gnode < maproute.levels+1; level_of_gnode++) @@ -1184,10 +1203,11 @@ } } - /** A node wants to become a member of our gnode. - * If possible, we add the reservation and return the HookReservation, - * else, we return None. - */ + /** + * A node wants to become a member of our gnode. + * If possible, we add the reservation and return the HookReservation, + * else, we return None. + */ public HookReservation? reserve() { Logger.ultradebug(@"Coord.reserve: gnode = $gnode"); @@ -1303,8 +1323,9 @@ return null; } - /** Communicate to secondary coordinators to free this 'pos'. - */ + /** + * Communicate to secondary coordinators to free this 'pos'. + */ public void forward_free(int pos) { struct_helper_Coordinator_forward_free arg = struct_helper_Coordinator_forward_free(); @@ -1346,8 +1367,11 @@ return null; } - /** Forwards a freed position to another hash node in the bunch. - */ + /** + * Forwards a freed position to another hash node in the bunch. + * @param to_nip The remote Netsukuku ip + * @param pos the node id in it's gnode + */ public void forward_free_to_nip(NIP to_nip, int pos) { struct_helper_Coordinator_forward_free_to_nip arg = struct_helper_Coordinator_forward_free_to_nip(); @@ -1368,8 +1392,10 @@ add_record(booking_record); } - /** Add a record to my bookings, do not forward. - */ + /** + * Add a record to my bookings, do not forward. + * @param booking_record ??? + */ public void add_record(BookingRecord booking_record) { RouteNode node = maproute.node_get(level_of_nodes, booking_record.pos); @@ -1378,8 +1404,10 @@ bookings.force_add(booking_record); } - /** Remove a record from my bookings, do not forward. - */ + /** + * Remove a record from my bookings, do not forward. + * @param pos The node Id to remove from this gnode + */ public void force_remove(int pos) { bookings.force_remove(pos); @@ -1488,7 +1516,7 @@ public void arrange_tunnel(ArrayList candidates) { - // TODO + // TODO: Write this python snippet in vala! /* def arrange_tunnel(self, candidates): # A new tunnel is wanted @@ -1551,8 +1579,9 @@ return null; } - /** Communicate to secondary coordinators all our current knowledge. - */ + /** + * Communicate to secondary coordinators all our current knowledge. + */ public void forward_knowledge() { struct_helper_Coordinator_forward_knowledge arg = struct_helper_Coordinator_forward_knowledge(); @@ -1595,8 +1624,9 @@ return null; } - /** Forwards all current knowledge to a secondary coordinator. - */ + /** + * Forwards all current knowledge to a secondary coordinator. + */ public void forward_knowledge_to_nip(NIP nip) { struct_helper_Coordinator_forward_knowledge_to_nip arg = struct_helper_Coordinator_forward_knowledge_to_nip(); === modified file 'crypto.vala' --- crypto.vala 2012-04-28 10:07:10 +0000 +++ crypto.vala 2012-07-01 05:10:03 +0000 @@ -21,8 +21,9 @@ namespace Ntk.Core { - /** This namespace groups functions related to crypto (libgcrypt) - */ + /** + * This namespace groups functions related to crypto (libgcrypt) + */ namespace Crypto { @@ -30,8 +31,9 @@ FAILED } - /** 32 bit Fowler/Noll/Vo hash - */ + /** + * 32 bit Fowler/Noll/Vo hash + */ public uint32 fnv_32(uchar[] buf) { uint32 hval = (uint32)2166136261; @@ -490,7 +492,8 @@ } /** - */ + * Represents a pair of keys + */ public class KeyPair : Object { private GCrypt.SExp keypair; @@ -562,7 +565,8 @@ } /** - */ + * A PGP public key + */ public class PublicKey : Object, ISerializable { private GCrypt.SExp pkey; === modified file 'hook.vala' --- hook.vala 2012-04-28 10:09:24 +0000 +++ hook.vala 2012-07-01 05:07:35 +0000 @@ -103,9 +103,10 @@ } } - /** The return value of the method list_non_saturated_levels - * is a list of tuple (int lvl, int number_of_free_nodes_at_lvl) - */ + /** + * The return value of the method list_non_saturated_levels + * is a list of tuple (int lvl, int number_of_free_nodes_at_lvl) + */ public class PairLvlNumberOfFreeNodes : Object, ISerializable { public int lvl; @@ -148,9 +149,9 @@ } } - /** Class Hook - * - */ + /** + * Class Hook + */ public class Hook : Object, IHook { private MapRoute maproute; @@ -176,10 +177,12 @@ { return - a.compare_to(b); } - /** The method returns a new valid address. - * It could be in the current network or in another network. - * We try to hook among the given neighbours. - */ + /** + * The method returns a new valid address. + * It could be in the current network or in another network. + * We try to hook among the given neighbours. + * @param neighbour_list A list of neighbours + */ public HookReservation hook(Gee.List neighbour_list) throws HookingError { ArrayList hfn = new ArrayList((EqualFunc)not_impl_equal_func); @@ -237,8 +240,9 @@ throw new HookingError.GENERIC("No good hooking solution."); } - /** Returns a list of (lvl, number_of_free_nodes_at_lvl) - */ + /** + * Returns a list of (lvl, number_of_free_nodes_at_lvl) + */ public Gee.List list_non_saturated_levels() { Gee.List ret = new ArrayList((EqualFunc)PairLvlNumberOfFreeNodes.equal_func); === modified file 'inet_ends.vala' --- inet_ends.vala 2012-05-25 15:50:13 +0000 +++ inet_ends.vala 2012-07-01 05:04:11 +0000 @@ -21,8 +21,9 @@ namespace Ntk.Core { - /** Packs a message of variable size together with the indication of its size - */ + /** + * Packs a message of variable size together with the indication of its size + */ uchar[] data_pack(uchar[] data) { uint data_sz = data.length; @@ -41,8 +42,9 @@ return ser; } - /** Reads from a stream a message of variable size (use with tcp streams) - */ + /** + * Reads from a stream a message of variable size (use with tcp streams) + */ uchar[] data_unpack_from_stream(TaskletUtils.IConnectedStreamSocket socket) { try @@ -87,8 +89,9 @@ } } - /** Reads from a packet a message of variable size (use with udp packets) - */ + /** + * Reads from a packet a message of variable size (use with udp packets) + */ uchar[] data_unpack_from_buffer(uchar[] buffer) { int i; @@ -132,8 +135,9 @@ return null; } - /** Informations about an host that sent us a message. - */ + /** + * Informations about an host that sent us a message. + */ public class CallerInfo : Object { public string? caller_ip; @@ -147,17 +151,26 @@ } } - /** This callback is used to interpret a request. It is called this way: - * rpcdispatcher, data, response = self.callback(caller, data_request) - * where the arguments are: - * caller: a CallerInfo instance. - * data_request: what has been read from socket as a request. - * and the results are: - * rpcdispatcher: if not None, we must do the call to the remotable method: - * rpcdispatcher.marshalled_dispatch(caller, data) - * response: if rpcdispatcher is None and response is not None then send response. - * if rpcdispatcher is None and response is None then do nothing. - */ + /** + * {{{ + * This callback is used to interpret a request. It is called this way: + * | rpcdispatcher, data, response = self.callback(caller, data_request) + * where the arguments are: + * | caller: a CallerInfo instance. + * | data_request: what has been read from socket as a request. + * and the results are: + * | rpcdispatcher: if not None, we must do the call to the remotable method: + * | rpcdispatcher.marshalled_dispatch(caller, data) + * | response: if rpcdispatcher is None and response is not None then send response. + * | if rpcdispatcher is None and response is None then do nothing. + * }}} + * @param caller a CallerInfo instance + * @param tcprequest what has been read from socket as a request. + * @param rpcdispatcher Return value: If not None, need to call rpcdispatcher.marshalled_dispatch(caller, data) + * @param data Return value: the data + * @param response Return value: If rpcdispatcher is None and response is not None send response.if both rpcdispatcher and response are None, do nothing + * + */ [CCode (has_target = false)] public delegate void TCPCallbackDelegate (CallerInfo caller, TCPRequest tcprequest, @@ -174,9 +187,10 @@ public TCPServer self; } - /** An instance of this class is created for the whole application in order - * to listen to TCP requests. - */ + /** + * An instance of this class is created for the whole application in order + * to listen to TCP requests. + */ public class TCPServer : Object { private uint16 port; @@ -190,9 +204,10 @@ listen_handle = null; } - /** This method is executed in a separated tasklet. It handles a connection. We do not know - * a priori if we'll receive 0, 1 or more requests in this connection. - */ + /** + * This method is executed in a separated tasklet. It handles a connection. We do not know + * a priori if we'll receive 0, 1 or more requests in this connection. + */ protected virtual void impl_handle_connection(TaskletUtils.IConnectedStreamSocket sock) throws Error { assert(callback != null); @@ -364,8 +379,9 @@ } } - /** An instance of this class is used when we want to send a message via TCP. - */ + /** + * An instance of this class is used when we want to send a message via TCP. + */ public class TCPClient : AddressManagerFakeRmt { public string dest_addr {get; private set;} @@ -564,9 +580,10 @@ public uint16 rmt_port; } - /** An instance of this class is created for each managed NIC in order - * to listen to UDP requests. - */ + /** + * An instance of this class is created for each managed NIC in order + * to listen to UDP requests. + */ public class UDPServer : Object { private UnicastCallbackDelegate unicast_callback; @@ -578,17 +595,25 @@ private TaskletUtils.ServerDatagramSocket listen_s = null; private ArrayList keeping_alive_list; - /** These callbacks are used to interpret a unicast/broadcast request. - * They are called this way: - * rpcdispatchers, data = this.broadcast_callback(CallerInfo, UDPPayload) - * rpcdispatcher, data, devs_response = this.unicast_callback(CallerInfo, UDPPayload) - * where the results are: - * rpcdispatchers: a list of rpcdispatcher (might be empty) - * rpcdispatcher: a dispatcher (or null) - * data: to be passed to marshalled_dispatch - * devs_response: if null we use a new tasklet and do not send response to the client. - * else, we'll send the response through those devs. - */ + /** + * {{{ + * These callbacks are used to interpret a unicast/broadcast request. + * They are called this way: + * | rpcdispatchers, data = this.broadcast_callback(CallerInfo, UDPPayload) + * | rpcdispatcher, data, devs_response = this.unicast_callback(CallerInfo, UDPPayload) + * where the results are: + * | rpcdispatchers: a list of rpcdispatcher (might be empty) + * | rpcdispatcher: a dispatcher (or null) + * | data: to be passed to marshalled_dispatch + * | devs_response: if null we use a new tasklet and do not send response to the client. + * | else, we'll send the response through those devs. + * }}} + * @param unicast_callback NO IDEA + * @param broadcast_callback NO IDEA + * @param dev Device + * @param port Port + * @param peerport Remote port (I think) + */ public UDPServer(UnicastCallbackDelegate unicast_callback, BroadcastCallbackDelegate broadcast_callback, string dev, uint16? port=null, uint16? peerport=null) @@ -676,8 +701,9 @@ } } - /** This function implement a simple Rpc UDP server - */ + /** + * This function implement a simple Rpc UDP server + */ private void impl_listen() throws Error { try @@ -752,11 +778,12 @@ void hex_dump(uint8[] buf) { - /* dumps buf to stdout. Looks like: - * [0000] 75 6E 6B 6E 6F 77 6E 20 - * 30 FF 00 00 00 00 39 00 unknown 0.....9. - * (in a single line of course) - */ + /* + * dumps buf to stdout. Looks like: + * [0000] 75 6E 6B 6E 6F 77 6E 20 + * | 30 FF 00 00 00 00 39 00 unknown 0.....9. + * (in a single line of course) + */ uchar *p = buf; string addrstr = ""; @@ -931,8 +958,9 @@ } } - /** An instance of a derived of this class is used when we want to send a message via UDP. - */ + /** + * An instance of a derived of this class is used when we want to send a message via UDP. + */ public abstract class UDPRequestClient : AddressManagerFakeRmt { private TaskletUtils.BroadcastClientDatagramSocket[] sockets = null; === modified file 'inet_utils.vala' --- inet_utils.vala 2012-04-11 21:23:15 +0000 +++ inet_utils.vala 2012-07-01 04:44:51 +0000 @@ -69,9 +69,10 @@ return nip_ip_converter.valid_ids(levels, gsize, lvl, partial_nip); } - /** Given this gnode, returns its CIDR. E.g. 10.11.22.0/24 - * returns 2 strings - */ + /** + * Given this gnode, returns its CIDR. E.g. 10.11.22.0/24 + * returns 2 strings + */ public void gnode_to_ip_cidr(PartialNIP gnode, int gsize, out string ipstr, out string bits) { NIP lowestnip = gnode.lowest_nip(); @@ -81,8 +82,9 @@ bits = lvl_to_bits(levels, gsize, given_up_to_level).to_string(); } - /** Inverse of gnode_to_ip_cidr. - */ + /** + * Inverse of gnode_to_ip_cidr. + */ public PartialNIP ip_cidr_to_gnode(int levels, int gsize, string ipstr, string bits) { int lvl = bits_to_lvl(levels, gsize, int.parse(bits)); @@ -92,25 +94,30 @@ public interface NipIpConverter : Object { - /** Returns bits corresponding to 'lvl' - */ + /** + * Returns bits corresponding to 'lvl' + */ public abstract int lvl_to_bits(int levels, int gsize, int lvl); - /** Inverse of lvl_to_bits - */ + /** + * Inverse of lvl_to_bits + */ public abstract int bits_to_lvl(int levels, int gsize, int bits); - /** Converts the given pip to a nip - */ + /** + * Converts the given pip to a nip + */ public abstract NIP pip_to_nip(int levels, int gsize, uchar[] pip); - /** The reverse of pip_to_nip - */ + /** + * The reverse of pip_to_nip + */ public abstract uchar[] nip_to_pip(int levels, int gsize, NIP nip); - /** Returns the list of valid IDs for level lvl, given that IDs for upper - * levels are already choosen in nip. - */ + /** + * Returns the list of valid IDs for level lvl, given that IDs for upper + * levels are already choosen in nip. + */ public abstract ArrayList valid_ids(int levels, int gsize, int lvl, PartialNIP partial_nip); } @@ -143,8 +150,9 @@ } */ - /** Represents class 10.* in IPv4 - */ + /** + * Represents class 10.* in IPv4 + */ public class class10_nip_to_ip : Object, NipIpConverter { private int bitsperlevel(int gsize) === modified file 'krnl_route.vala' --- krnl_route.vala 2012-04-28 10:09:24 +0000 +++ krnl_route.vala 2012-07-01 04:42:30 +0000 @@ -26,8 +26,9 @@ public KrnlRoute self; } - /** Listens to MapRoute generated events, and updates the kernel table - */ + /** + * Listens to MapRoute generated events, and updates the kernel table + */ public class KrnlRoute : Object { private Addresses addresses; @@ -62,6 +63,10 @@ if (multipath) RouteSetter.get_instance().activate_multipath(); } + /** + * Reports status? + * TODO + */ public string report_status() { string ret = "\n"; @@ -77,8 +82,9 @@ return ret; } - /** We have no routes - */ + /** + * We have no routes + */ private void network_reset() { try @@ -104,15 +110,17 @@ } /** - * The rules that this class has to keep satisfied are: - * given that we are x; - * at any time, for any v ∈ V, - * if Bestᵗ (x → v) = xy...v > 0 - * x maintains this RULE: destination = v → gateway = y - * ∀w ∈ x* - * if w ∈ Bestᵗ (x → v) AND Bestᵗ (x → w̃ → v) = xz...v > 0 - * x maintains this RULE: source w, destination = v → gateway = z - */ + * {{{ + * The rules that this class has to keep satisfied are: + * given that we are x; + * at any time, for any v ∈ V, + * if Bestᵗ (x → v) = xy...v > 0 + * x maintains this RULE: destination = v → gateway = y + * ∀w ∈ x* + * if w ∈ Bestᵗ (x → v) AND Bestᵗ (x → w̃ → v) = xz...v > 0 + * x maintains this RULE: source w, destination = v → gateway = z + * }}} + */ private string me_to_ipstr() { === modified file 'libwrappth.vala' --- libwrappth.vala 2012-05-25 15:50:13 +0000 +++ libwrappth.vala 2012-07-01 04:40:01 +0000 @@ -1,4 +1,4 @@ -/* +/** * libwrappth.vala - Vala wrapper for libpth.vapi which is a strict bindings of GNU Pth * Copyright (c) 2011 Luca Dionisi aka lukisi * License: GNU LGPL v3 as published by the Free Software Foundation @@ -360,17 +360,18 @@ return result; } - /** This terminates the current thread. Whether it's immediately - * removed from the system or inserted into the dead queue of the - * scheduler depends on its join type which was specified at - * spawning time. If it has the attribute PTH_ATTR_JOINABLE set to - * FALSE, it's immediately removed and value is ignored. Else the - * thread is inserted into the dead queue and value remembered for - * a subsequent pth_join(3) call by another thread. - * If invoked on the "main" thread this function waits for all - * other threads to terminate, kills the threading system and then - * terminates the process returning the value. - */ + /** + * This terminates the current thread. Whether it's immediately + * removed from the system or inserted into the dead queue of the + * scheduler depends on its join type which was specified at + * spawning time. If it has the attribute PTH_ATTR_JOINABLE set to + * FALSE, it's immediately removed and value is ignored. Else the + * thread is inserted into the dead queue and value remembered for + * a subsequent pth_join(3) call by another thread. + * If invoked on the "main" thread this function waits for all + * other threads to terminate, kills the threading system and then + * terminates the process returning the value. + */ public static void exit(void *exit_val) { Native.LibPth.exit(exit_val); === modified file 'makefile' --- makefile 2012-04-28 10:11:31 +0000 +++ makefile 2012-07-01 06:11:56 +0000 @@ -284,4 +284,7 @@ $(MAKE) -C testsuites clean rm -f $(TEMP_FILES) rm -f $(OUT_FILES) +#doc: + #[[ `which valadoc` ]]&&VALADOC=`which valadoc`|| (echo "Sorry, no valadoc, cannot generate documents"; exit 1) + #valadoc *.vala -o doc/vd --pkg gcrypt --pkg gee-1.0 --pkg gio-2.0 --pkg posix --pkg posix_extras --pkg linux --pkg libpth --vapidir="/usr/share/vala-0.16/vapi/" --vapidir="." --force --verbose === modified file 'map.vala' --- map.vala 2012-04-28 10:11:10 +0000 +++ map.vala 2012-07-01 04:30:51 +0000 @@ -21,9 +21,10 @@ namespace Ntk.Core { - /** A DataClass contains information regarding a node of the map. - * Each Map.node[level, id] entry is a DataClass instance. - */ + /** + * A DataClass contains information regarding a node of the map. + * Each Map.node[level, id] entry is a DataClass instance. + */ public abstract class DataClass : Object { public abstract bool is_free(); @@ -44,8 +45,9 @@ public int pos; } - /** A Map instance represents ... - */ + /** + * A Map instance represents ... + */ public class Map : Object { public signal void node_new(int lvl, int pos); @@ -76,7 +78,12 @@ return _me; } } - + /** + * Constructs a new map + * @param levels How deep to go + * @param gsize How many members in a group-node + * @param me Not sure, a self reference? + */ public Map(int levels, int gsize, NIP me) { this._levels = levels; // Number of levels @@ -143,7 +150,10 @@ // void method, return null return null; } - + /** + * spawns a tasklet which periodically checks all nodes. + * (in this gnode?) + */ public void periodically_check_all_nodes() { struct_helper_Map_periodically_check_all_nodes arg = struct_helper_Map_periodically_check_all_nodes(); @@ -202,6 +212,12 @@ } } + + /** + * Checks a node, this looks similar to a "ping"??? + * @param lvl which level + * @param pos Node id? + */ public void check_node(int lvl, int pos) { // Register (once) the spawnable function that is our dispatcher @@ -217,11 +233,12 @@ ch.send_async(arg); } - /** Returns from the map a node of level `lvl' and id `pos'. - * - * An instance of type T will always be returned: if - * it doesn't exist, it is created. - */ + /** + * Returns from the map a node of level `lvl' and id `pos'. + * + * An instance of type T will always be returned: if + * it doesn't exist, it is created. + */ public virtual T node_get(int lvl, int pos) { if (node[lvl, pos] == null) @@ -246,39 +263,44 @@ return node_get(hc.lvl, hc.pos); } - /** Removes from the map a node of level `lvl' and id `pos'. - */ + /** + * Removes from the map a node of level `lvl' and id `pos'. + */ public void node_remove(int lvl, int pos) { node[lvl, pos] = null; } - /** A node was previously free, and now it is busy. Emit a signal. - */ + /** + * A node was previously free, and now it is busy. Emit a signal. + */ public void node_add(int lvl, int pos) { Logger.debug(@"Map($(this.get_type().name())): emit signal NODE_NEW($(lvl), $(pos))."); node_new(lvl, pos); } - /** A node was previously busy, and now it is free. Emit a signal. - */ + /** + * A node was previously busy, and now it is free. Emit a signal. + */ public void node_del(int lvl, int pos) { Logger.debug(@"Map($(this.get_type().name())): emit signal NODE_DELETED($(lvl), $(pos))."); node_deleted(lvl, pos); } - /** Returns the number of free nodes of level `lvl' - */ + /** + * Returns the number of free nodes of level `lvl' + */ public int free_nodes_nb(int lvl) { int [] x = free_nodes_list(lvl); return x.length; } - /** Returns the list of free nodes of level `lvl' - */ + /** + * Returns the list of free nodes of level `lvl' + */ public int[] free_nodes_list(int lvl) { ArrayList ret = new ArrayList(); @@ -290,16 +312,18 @@ return (int[])ret.to_array(); } - /** Returns the number of busy nodes of level `lvl' - */ + /** + * Returns the number of busy nodes of level `lvl' + */ public int busy_nodes_nb(int lvl) { int [] x = busy_nodes_list(lvl); return x.length; } - /** Returns the list of busy nodes of level `lvl' - */ + /** + * Returns the list of busy nodes of level `lvl' + */ public int[] busy_nodes_list(int lvl) { ArrayList ret = new ArrayList(); @@ -313,8 +337,9 @@ return retval; } - /** Returns a list of the number of busy nodes at every level - */ + /** + * Returns a list of the number of busy nodes at every level + */ public int[] get_all_busy_nodes_nb() { int[] retval = new int[_levels]; @@ -327,26 +352,29 @@ return NIP.nip_cmp(nipA, _me.get_positions()); } - /** Converts a (lvl, pos) pair, referring to this map, to - * its equivalent nip - */ + /** + * Converts a (lvl, pos) pair, referring to this map, to + * its equivalent nip + */ public PartialNIP lvlid_to_nip(HCoord lvlid) { return lvlid.get_partialnip_relative_to(_me); } - /** Finds a (lvl, pos) pair, referring to this map, from - * its equivalent nip - */ + /** + * Finds a (lvl, pos) pair, referring to this map, from + * its equivalent nip + */ public HCoord nip_to_lvlid(PartialNIP nip) { return nip.get_hcoord_relative_to(_me); } - /** Given a list of pairs (lvl, id) received by a neighbour with a - * given nip, returns the list of pairs (lvl, id) representing the same - * list of nodes, as seen from the point of view of this node. - */ + /** + * Given a list of pairs (lvl, id) received by a neighbour with a + * given nip, returns the list of pairs (lvl, id) representing the same + * list of nodes, as seen from the point of view of this node. + */ public Gee.List list_lvl_id_from_nip(Gee.List lvl_ids, NIP sender_nip) { HCoord sender_lvlid = nip_to_lvlid(sender_nip); @@ -371,10 +399,11 @@ return ret_nodups; } - /** Given a list of pairs (lvl, id) being sent to a neighbour with a - * given nip, returns the list of pairs (lvl, id) representing the same - * list of nodes, as seen from the point of view of the neighbour. - */ + /** + * Given a list of pairs (lvl, id) being sent to a neighbour with a + * given nip, returns the list of pairs (lvl, id) representing the same + * list of nodes, as seen from the point of view of the neighbour. + */ public Gee.List list_lvl_id_to_nip(Gee.List lvl_ids, NIP to_nip) { HCoord to_lvlid = nip_to_lvlid(to_nip); === modified file 'maproute.vala' --- maproute.vala 2012-04-28 10:09:24 +0000 +++ maproute.vala 2012-07-01 04:39:06 +0000 @@ -21,22 +21,25 @@ namespace Ntk.Core { - /** A path to a known destination. - * - * An instance of this class represents a path to a known - * destination d. - * The instance members are: - * `gw': the gateway of the route. Our next hop. It is an instance of the - * class AggregatedNeighbour. - * `rem_at_gw': a REM (Route Efficience Measure) of the path from the - * gateway to the destination d. It is an instance of the class - * REM or a derivative. - * `hops': a List of HCoord of the hops represented by this - * path from the gateway gw to the destination d. - * gw and d are not included. - * `gid': a instance of GNodeid, it is the ID of the gnode that this class - * represents, as it is reported by this path. - */ + /** + * {{{ + * A path to a known destination. + * + * An instance of this class represents a path to a known + * destination d. + * The instance members are: + * `gw': the gateway of the route. Our next hop. It is an instance of the + * | class AggregatedNeighbour. + * `rem_at_gw': a REM (Route Efficience Measure) of the path from the + * | gateway to the destination d. It is an instance of the class + * | REM or a derivative. + * `hops': a List of HCoord of the hops represented by this + * | path from the gateway gw to the destination d. + * | gw and d are not included. + * `gid': a instance of GNodeid, it is the ID of the gnode that this class + * | represents, as it is reported by this path. + * }}} + */ public class Route : Object { public weak RouteNode routenode; @@ -92,8 +95,9 @@ } } - /** The route 'this' is better (greater) than 'other' if its rem is better - */ + /** + * The route 'this' is better (greater) than 'other' if its rem is better + */ public static int compare_func(Route a, Route b) { return a.compare_to(b); @@ -103,10 +107,11 @@ return rem.compare_to(other.rem); } - /** Used to test between 2 routes in the same RouteNode - * (e.g. to remove a route from the collection of routes) - * In such a comparison the only member we can check is the gateway. - */ + /** + * Used to test between 2 routes in the same RouteNode + * (e.g. to remove a route from the collection of routes) + * In such a comparison the only member we can check is the gateway. + */ public static bool equal_func_in_routenode(Route a, Route b) { if (a == b) return true; @@ -114,8 +119,9 @@ return a.gw == b.gw; } - /** The path contains a specified hop? - */ + /** + * The path contains a specified hop? + */ public bool contains(HCoord hop) { if (hop.is_equal(dest)) return true; @@ -133,13 +139,14 @@ return oldrem_at_gw; } - /** Returns an instance of CloneRoute that is a copy of the current - * status of this Route. If this Route changes in some way, the cloned - * instance will not. - * The class CloneRoute has some of the methods that Route has, - * those needed to perform the task of choosing the settings to - * impose in the kernel routing tables. - */ + /** + * Returns an instance of CloneRoute that is a copy of the current + * status of this Route. If this Route changes in some way, the cloned + * instance will not. + * The class CloneRoute has some of the methods that Route has, + * those needed to perform the task of choosing the settings to + * impose in the kernel routing tables. + */ public CloneRoute clone() { return new CloneRoute(this); @@ -220,8 +227,9 @@ return @""; } - /** The route 'this' is better (greater) than 'other' if its rem is better - */ + /** + * The route 'this' is better (greater) than 'other' if its rem is better + */ public static int compare_func(CloneRoute a, CloneRoute b) { return a.compare_to(b); @@ -231,8 +239,9 @@ return rem.compare_to(other.rem); } - /** The path contains a specified hop? - */ + /** + * The path contains a specified hop? + */ public bool contains(HCoord hop) { if (hop.is_equal(dest)) return true; @@ -256,14 +265,15 @@ } - /** List of paths to a known destination. - * - * This class is basically a list of Route instances, where the - * destination node and its level are fixed and known. - * - * Note: for each gateway G there's only one route in self.routes, - * which has the same gateway G - */ + /** + * List of paths to a known destination. + * + * This class is basically a list of Route instances, where the + * destination node and its level are fixed and known. + * + * Note: for each gateway G there's only one route in self.routes, + * which has the same gateway G + */ public class RouteNode : DataClass { public weak Map maproute; @@ -283,8 +293,9 @@ routes = new ArrayList((EqualFunc)Route.equal_func_in_routenode); } - /** Returns the route having as gateway `gw' - */ + /** + * Returns the route having as gateway `gw' + */ public Route? route_get_by_gw(AggregatedNeighbour gw) { foreach (Route r in routes) @@ -312,9 +323,10 @@ sort(); } - /** Delete a route. - * Returns 1 if the route has been deleted, otherwise 0 - */ + /** + * Delete a route. + * Returns 1 if the route has been deleted, otherwise 0 + */ public int route_del_by_gw(AggregatedNeighbour gw) { Route? r = route_get_by_gw(gw); @@ -330,10 +342,11 @@ { return - Route.compare_func(a, b); } - /** Order the routes - * Order the routes in decrescent order of efficiency, so that - * routes[0] is the best one - */ + /** + * Order the routes + * Order the routes in decrescent order of efficiency, so that + * routes[0] is the best one + */ public void sort() { routes.sort((CompareFunc)reverse_compare_func); @@ -422,11 +435,12 @@ public int level; } - /** Map of routes, all of a same Rem type. - * - * MapRoute.node[lvl][id] is a RouteNode class, i.e. a list of routes - * having as destination the node (lvl, id) - */ + /** + * Map of routes, all of a same Rem type. + * + * MapRoute.node[lvl][id] is a RouteNode class, i.e. a list of routes + * having as destination the node (lvl, id) + */ public class MapRoute : Map, IMapRoute { public weak AddressManager address_manager {get; private set;} @@ -573,8 +587,9 @@ return ret; } - /** My GNode ID list - */ + /** + * My GNode ID list + */ public GNodeID[] get_gid_list() { GNodeID[] ret = new GNodeID[id_myself.length]; @@ -600,33 +615,35 @@ return id_myself[lvl]; } - /** My node ID - */ + /** + * My node ID + */ public int get_my_id() { return id_myself[0].ident; } - /** This method returns a Networkid. The aim is to be able to - * testify to a neighbour that we already hooked in its same network. - * Since the network could split, and we could detect the change - * moments before our neighbour does, then we must compare not just the - * GID of level 'levels' -- which is the min of GIDs of level 'levels-1' - * but we must compare all the GIDs of level levels-1. - * Add to this, that at the very beginning of our hook when we did not - * receive an etp yet, we do not have in the maproute the necessary - * gids, we just received the main one in self.id_myself[-1] - * Furthermore we have to consider self.id_myself[-2] for our GID at - * level 'levels-1'. - * TODO We still have a weakness here. 2 neighbours that belong to the same - * network but in different gnodes at the uppermost level (eg 1.1.1 and 2.2.2 - * in a network of 3 levels) have in common only the gnodes of level 2, so - * they can compare the GIDs at level 2 and the one GID at level 3 (that is - * the min of GIDs at level 2). If the gsize is quite small (say gsize=4) we - * have very few IDs (4) that we can compare. They exist for the lifespan of - * few single nodes. If all these nodes die quite at the same time, - * then we'll experience a massive rehook. - */ + /** + * This method returns a Networkid. The aim is to be able to + * testify to a neighbour that we already hooked in its same network. + * Since the network could split, and we could detect the change + * moments before our neighbour does, then we must compare not just the + * GID of level 'levels' -- which is the min of GIDs of level 'levels-1' + * but we must compare all the GIDs of level levels-1. + * Add to this, that at the very beginning of our hook when we did not + * receive an etp yet, we do not have in the maproute the necessary + * gids, we just received the main one in self.id_myself[-1] + * Furthermore we have to consider self.id_myself[-2] for our GID at + * level 'levels-1'. + * TODO We still have a weakness here. 2 neighbours that belong to the same + * network but in different gnodes at the uppermost level (eg 1.1.1 and 2.2.2 + * in a network of 3 levels) have in common only the gnodes of level 2, so + * they can compare the GIDs at level 2 and the one GID at level 3 (that is + * the min of GIDs at level 2). If the gsize is quite small (say gsize=4) we + * have very few IDs (4) that we can compare. They exist for the lifespan of + * few single nodes. If all these nodes die quite at the same time, + * then we'll experience a massive rehook. + */ public NetworkID get_main_netid() { ArrayList ret = new ArrayList((EqualFunc)GNodeID.equal_func); @@ -641,24 +658,27 @@ return new NetworkID(ret); } - /** Is this netid in my network - */ + /** + * Is this netid in my network + */ public bool is_in_my_network(NetworkID netid) { return get_main_netid().is_same_network(netid); } - /** Is this netid preferred over mine - */ + /** + * Is this netid preferred over mine + */ public bool is_preferred_network(NetworkID netid) { return netid.is_preferred_over(get_main_netid()); } - /** Verify the validity of the GNode ID. - * This has to be called just once after a ROUTES_UPDATED event, - * to keep updated the GNodeid at various levels. - */ + /** + * Verify the validity of the GNode ID. + * This has to be called just once after a ROUTES_UPDATED event, + * to keep updated the GNodeid at various levels. + */ public void evaluate_changed_netid() { if (! address_manager.is_mature) @@ -694,42 +714,45 @@ } } - /** A node which wants to rest assured that its GID at level lvl is valid will launch handle_check_gid. This - * will start operations (if not already in progress) and make sure that for a certain time - * from now the check will be periodically sent in broadcast until a response (ok or rehook) - * is received or the time expires. - * Note that handle_check_gid is not a microfunc and when it returns we can immediately add an id to its answer_queue. - * When a node receives such a request and it is in the same gnode, it will launch handle_check_gid. Then it adds - * the received request_id to the answer_queue for the level. - * To formulate the request to be sent, a node generates a request_id. It will use this request_id in all messages - * sent until response/expiration. - * When a response is received that is for us and is ok, the same answer is sent again in broadcast to all the id - * that we have in answer_queue. - * When a response is received that is for us and is rehook, the maproute emits a signal that will cause the - * ntkd_node to start a rehook. The signal contains all data needed to reply the same answer after the rehook has - * been completed. The reply will occurr only after the node has is_mature, because, until then, the node will not - * be able to serve a hook request. - * The exact sequence of operations when ntkd_node detects the signal is: - * . (assert the splitted was a primary_address) - * . start rehook from primary_address to [answering_nip] - * . tc=TimeCapsule(xx) - * . while True: - * . if tc.expired(): break - * . if rehook failed: break - * . if addresses.primary_address.is_mature: - * . for queued_id in queue: - * . broadcast_client.maproute.answer_gid( \ - * . addresses.primary_address.maproute.me, \ - * . queued_id, \ - * . actual_gid) - * . break - * . swait a bit - * So, the data needed with the signal 'GNODE_SPLITTED' are: (neighbours=[answering_nip], queue, actual_gid) - * Note_1: An address_manager nom-autonomous will ignore messages request_gid. - * Note_2: An address_manager nom-autonomous that detects a possible gnode split will start handle_check_gid, but if - * it receives a rehook then it just dies. (this check is in ntkd_node) - * Note_3: An address_manager that has not is_mature will ignore messages request_gid. - */ + /** + * {{{ + * A node which wants to rest assured that its GID at level lvl is valid will launch handle_check_gid. This + * will start operations (if not already in progress) and make sure that for a certain time + * from now the check will be periodically sent in broadcast until a response (ok or rehook) + * is received or the time expires. + * Note that handle_check_gid is not a microfunc and when it returns we can immediately add an id to its answer_queue. + * When a node receives such a request and it is in the same gnode, it will launch handle_check_gid. Then it adds + * the received request_id to the answer_queue for the level. + * To formulate the request to be sent, a node generates a request_id. It will use this request_id in all messages + * sent until response/expiration. + * When a response is received that is for us and is ok, the same answer is sent again in broadcast to all the id + * that we have in answer_queue. + * When a response is received that is for us and is rehook, the maproute emits a signal that will cause the + * ntkd_node to start a rehook. The signal contains all data needed to reply the same answer after the rehook has + * been completed. The reply will occurr only after the node has is_mature, because, until then, the node will not + * be able to serve a hook request. + * The exact sequence of operations when ntkd_node detects the signal is: + * | . (assert the splitted was a primary_address) + * | . start rehook from primary_address to [answering_nip] + * | . tc=TimeCapsule(xx) + * | . while True: + * | . if tc.expired(): break + * | . if rehook failed: break + * | . if addresses.primary_address.is_mature: + * | . for queued_id in queue: + * | . broadcast_client.maproute.answer_gid( \ + * | . addresses.primary_address.maproute.me, \ + * | . queued_id, \ + * | . actual_gid) + * | . break + * | . swait a bit + * | So, the data needed with the signal 'GNODE_SPLITTED' are: (neighbours=[answering_nip], queue, actual_gid) + * |Note_1: An address_manager nom-autonomous will ignore messages request_gid. + * |Note_2: An address_manager nom-autonomous that detects a possible gnode split will start handle_check_gid, but if + * | it receives a rehook then it just dies. (this check is in ntkd_node) + * |Note_3: An address_manager that has not is_mature will ignore messages request_gid. + * }}} + */ public void handle_check_gid(int level) { @@ -935,12 +958,15 @@ Logger.debug(@"Maproute for $me : answer_gid: not for me."); } - /** Evaluation methods **/ + /** + * Evaluation methods + **/ - /** Returns the REM of the best path that we have to - * reach a destination which is inside our gnode of level level_of_gnode - * and which has the worst REM among such destinations. - */ + /** + * Returns the REM of the best path that we have to + * reach a destination which is inside our gnode of level level_of_gnode + * and which has the worst REM among such destinations. + */ public REM worst_internal_bestrem(int level_of_gnode) { REM worstrem = new NullREM(); @@ -967,8 +993,9 @@ return worstrem; } - /** Returns minimum distance in number of hops - */ + /** + * Returns minimum distance in number of hops + */ public int? get_distance(int lvl, int pos) { // If destination is me, distance is 0. @@ -989,8 +1016,9 @@ return ret; } - /** Methods that modify routes **/ - + /** + * Methods that modify routes + **/ public void update_route_by_gw(HCoord dest, AggregatedNeighbour nr, REM rem_at_gw, Gee.List hops, GNodeID? gid) { int lvl = dest.lvl; @@ -1048,12 +1076,15 @@ routes_updated(new HCoord(lvl, dst)); } - /** Neighbour stuff **/ + /** + * Neighbour stuff + **/ - /** Delete from the MapRoute all the routes passing from the - * gateway `neighbour' and delete the node `neighbour' itself - * (if present) - */ + /** + * Delete from the MapRoute all the routes passing from the + * gateway `neighbour' and delete the node `neighbour' itself + * (if present) + */ public void delete_routes_via_neighbour(AggregatedNeighbour aggregated_neighbour) { for (int lvl = 0; lvl < levels; lvl++) @@ -1076,8 +1107,9 @@ } } - /** Helpers **/ - + /** + * Helpers + **/ public PartialNIP choose_between(Gee.List choose_from /*TODO args*/) { assert(! choose_from.is_empty); === modified file 'messages.vala' --- messages.vala 2012-04-28 10:09:24 +0000 +++ messages.vala 2012-06-28 01:38:36 +0000 @@ -21,7 +21,8 @@ namespace Ntk.Core { - /** This class represents a call to a remotable procedure. + /** + * This class represents a call to a remotable procedure. * * The string method_name contains something like "property1.property2.method0" * which means that in the remote host the Dispatcher object has a @@ -145,7 +146,8 @@ } } - /** This class represents a RPCError or any other error that is thrown + /** + * This class represents a RPCError or any other error that is thrown * by the remotable method. */ public class RemotableException : Object, ISerializable @@ -180,7 +182,8 @@ } } - /** A message that uses TCP as transport. + /** + * A message that uses TCP as transport. */ public class TCPRequest : Object, ISerializable { @@ -217,7 +220,8 @@ } } - /** A message that uses UDP as transport. + /** + * A message that uses UDP as transport. */ public class UDPMessage : Object, ISerializable { @@ -341,14 +345,16 @@ } } - /** The UDP message is an instance of a derived class of UDPPayload. + /** + * The UDP message is an instance of a derived class of UDPPayload. * The particular derived class has data that the callbacks can inspect * to see whether the message has to be delivered to one of our dispatchers */ public class UDPPayload : Object {} - /** A UDP message containing a RemoteCall to be dispatched to a particular NIP + /** + * A UDP message containing a RemoteCall to be dispatched to a particular NIP */ public class UDPUnicastPayload : UDPPayload, ISerializable { @@ -389,7 +395,8 @@ } } - /** A UDP message containing a RemoteCall to be dispatched to all nodes of a particular Network + /** + * A UDP message containing a RemoteCall to be dispatched to all nodes of a particular Network */ public class UDPBroadcastPayload : UDPPayload, ISerializable { === modified file 'metrics.vala' --- metrics.vala 2011-11-15 20:51:00 +0000 +++ metrics.vala 2012-07-01 04:25:56 +0000 @@ -21,34 +21,38 @@ namespace Ntk.Core { - /** Route Efficiency Measure. - * - * This is a base class for different metrics (rtt, bandwidth, ...) - */ + /** + * Route Efficiency Measure. + * + * This is a base class for different metrics (rtt, bandwidth, ...) + */ public abstract class REM : Object, ISerializable, Comparable { public abstract Variant serialize_to_variant(); public abstract void deserialize_from_variant(Variant v); public abstract string to_string(); - /** The Comparable interface implemented here is useful when we - * have a collection of REM objects and we want to sort them, or - * to find the best or the worst of them. - * - * NOTE: a.compare_to(b) < 0 means a < b - * NOTE: A REM is a measure of efficiency, so a < b means a is less efficient - */ + /** + * The Comparable interface implemented here is useful when we + * have a collection of REM objects and we want to sort them, or + * to find the best or the worst of them. + * + * NOTE: a.compare_to(b) < 0 means a < b + * NOTE: A REM is a measure of efficiency, so a < b means a is less efficient + */ public abstract int compare_to(REM other); - /** This method is used to calculate the efficiency of a path - * x0...xi...xn when we know the efficiency of the path x0...xi - * and the efficiency of the path xi...xn - */ + /** + * This method is used to calculate the efficiency of a path + * x0...xi...xn when we know the efficiency of the path x0...xi + * and the efficiency of the path xi...xn + */ public abstract REM add_segment(REM other); } - /** Infinity. - */ + /** + * Infinity. + */ public class NullREM : REM { public override Variant serialize_to_variant() @@ -77,8 +81,9 @@ } } - /** Zero. - */ + /** + * Zero. + */ public class DeadREM : REM { public override Variant serialize_to_variant() @@ -107,8 +112,9 @@ } } - /** Almost Zero. - */ + /** + * Almost Zero. + */ public class AlmostDeadREM : REM { public override Variant serialize_to_variant() @@ -139,12 +145,13 @@ } } - /** Round Trip Time. - * This is a measure of latency. This class could well be used to - * model the delay of the path from A to B. Instead, the current - * implementation of netsukuku uses it to model the round-trip time - * of a packet from A to B and back to A. - */ + /** + * Round Trip Time. + * This is a measure of latency. This class could well be used to + * model the delay of the path from A to B. Instead, the current + * implementation of netsukuku uses it to model the round-trip time + * of a packet from A to B and back to A. + */ public class RTT : REM { private int _rtt; === modified file 'microfunc.vala' --- microfunc.vala 2012-05-25 15:49:54 +0000 +++ microfunc.vala 2012-06-28 01:10:24 +0000 @@ -16,7 +16,8 @@ * along with Netsukuku. If not, see . */ -/** The tester for this module contains sample code for how to simulate the decoration +/** + * The tester for this module contains sample code for how to simulate the decoration * of functions/methods as microfunc (simple or with dispatcher) */ @@ -29,7 +30,8 @@ public Channel self; } - /** The class TaskletDispatcher is not meant to create instances. + /** + * The class TaskletDispatcher is not meant to create instances. * Its static method get_channel_for_helper is used to register an helper * that will act as a dispatcher for a function/method that we want to be * executed once at a time in a dedicated tasklet. === modified file 'migration.vala' --- migration.vala 2012-04-28 10:09:24 +0000 +++ migration.vala 2012-07-01 04:24:53 +0000 @@ -31,9 +31,10 @@ public MigrationManager self; } - /** Each node periodically evaluates whether it is - * convenient or not to migrate into another gnode. - */ + /** + * Each node periodically evaluates whether it is + * convenient or not to migrate into another gnode. + */ public class MigrationManager : Object { public weak AddressManager address_manager {get; private set;} @@ -61,8 +62,9 @@ } } - /** Called after address_manager is_mature - */ + /** + * Called after address_manager is_mature + */ public virtual void start_operations() { if (address_manager.is_primary) start_primary_evaluate_migration(); === modified file 'neighbour.vala' --- neighbour.vala 2012-04-28 10:09:24 +0000 +++ neighbour.vala 2012-07-01 04:24:09 +0000 @@ -21,14 +21,15 @@ namespace Ntk.Core { - public errordomain NeighbourError { - DUPLICATE_INSERT, - MISSING_REMOVE, - MAX_EXCEED - } + public errordomain NeighbourError { + DUPLICATE_INSERT, + MISSING_REMOVE, + MAX_EXCEED + } - /** Each instance of this class represents a neighbour as seen by a particular nic of this node. - */ + /** + * Each instance of this class represents a neighbour as seen by a particular nic of this node. + */ public class Neighbour : Object { /* @@ -165,7 +166,7 @@ public HashMap detected_neighbours; } - /** By watching the previous statistics, it can deduces if a change occurred or + /* By watching the previous statistics, it can deduces if a change occurred or not. If it is, one of the following events is fired: 'NEIGHBOUR_NEW', 'NEIGHBOUR_DELETED', 'NEIGHBOUR_REM_CHGED' In this way, the other modules of ntk will be noticed. @@ -174,7 +175,7 @@ of the packets. However, more refined way can be used and shall be implemented: first of all consider the number of bouquet packets lost, then see NTK_RFC 0002 http://lab.dyne.org/Ntk_bandwidth_measurement - */ + */ public class NeighbourManager : Object { public Radar radar {get; protected set;} @@ -232,8 +233,9 @@ public signal void neighbour_going_deleted(Neighbour neighbour); public signal void neighbour_going_rem_chged(Neighbour neighbour); - /** Returns the list of neighbours. - */ + /** + * Returns the list of neighbours. + */ public virtual Gee.List neighbour_list() { // ATTENTION: this method MUST NOT pass schedule while @@ -251,8 +253,9 @@ return nlist; } - /** Inserts this neighbour in our data structures. - */ + /** + * Inserts this neighbour in our data structures. + */ private void memorize(Neighbour val) throws NeighbourError { // key = (tuple(val.nip), val.nodeid) @@ -270,8 +273,9 @@ tnip_nodeid_table[skey] = val; } - /** Removes this neighbour in our data structures. - */ + /** + * Removes this neighbour in our data structures. + */ private void unmemorize(string skey) throws NeighbourError { // key: pair tuple(nip), nodeid @@ -284,8 +288,9 @@ tnip_nodeid_table.unset(skey); } - /** return a Neighbour object from its nip and nodeid - */ + /** + * return a Neighbour object from its nip and nodeid + */ public Neighbour? key_to_neighbour(NIP nip, int nodeid) { string skey = tnip_nodeid_key(nip, nodeid); @@ -521,9 +526,10 @@ declared_dead.add(key); } - /** Detects changes in our neighbourhood. Updates internal data structures - * and notify about the changes. - */ + /** + * Detects changes in our neighbourhood. Updates internal data structures + * and notify about the changes. + */ private void impl_store(int bouquet_numb, HashMap detected_neighbours) throws Error { ArrayList _declared_dead; @@ -770,9 +776,10 @@ Tasklet.spawn((FunctionDelegate)helper_store, &arg); } - /** No more radar. Deletes all neighbours. Updates internal data structures - * and notify about the changes. - */ + /** + * No more radar. Deletes all neighbours. Updates internal data structures + * and notify about the changes. + */ public void empty() { // Note: it is not a microfunc, because after the Radar has stopped @@ -783,8 +790,9 @@ store_delete_neighbour(key); } - /** Emits signal BEFORE a new neighbour. - */ + /** + * Emits signal BEFORE a new neighbour. + */ public void going_add(Neighbour neighbour) { string ipstr = nip_to_str(neighbour.levels, neighbour.gsize, neighbour.nip); @@ -793,8 +801,9 @@ neighbour_going_new(neighbour); } - /** Emits signal BEFORE a dead neighbour. - */ + /** + * Emits signal BEFORE a dead neighbour. + */ public void going_delete(Neighbour neighbour) { string ipstr = nip_to_str(neighbour.levels, neighbour.gsize, neighbour.nip); @@ -803,8 +812,9 @@ neighbour_going_deleted(neighbour); } - /** Emits signal BEFORE a changed rem neighbour. - */ + /** + * Emits signal BEFORE a changed rem neighbour. + */ public void going_rem_change(Neighbour neighbour) { string ipstr = nip_to_str(neighbour.levels, neighbour.gsize, neighbour.nip); @@ -813,8 +823,9 @@ neighbour_going_rem_chged(neighbour); } - /** Emits signal for a new neighbour. - */ + /** + * Emits signal for a new neighbour. + */ public void add_neighbour(string key) { Neighbour neighbour = tnip_nodeid_table[key]; @@ -824,8 +835,9 @@ neighbour_new(neighbour); } - /** Emits signal for a dead neighbour. - */ + /** + * Emits signal for a dead neighbour. + */ public void delete_neighbour(string key, Neighbour old_val) { string ipstr = nip_to_str(old_val.levels, old_val.gsize, old_val.nip); @@ -834,8 +846,9 @@ neighbour_deleted(old_val); } - /** Emits signal for a changed rem neighbour. - */ + /** + * Emits signal for a changed rem neighbour. + */ public void rem_change_neighbour(string key, REM old_rem) { Neighbour neighbour = tnip_nodeid_table[key]; === modified file 'network_linux.vala' --- network_linux.vala 2012-05-25 15:51:14 +0000 +++ network_linux.vala 2012-07-01 04:10:08 +0000 @@ -33,9 +33,10 @@ public int exit_status; } - /** Launch a process and block this tasklet till it ends. - * Returns exit status, stdout and stderr. - */ + /** + * Launch a process and block this tasklet till it ends. + * Returns exit status, stdout and stderr. + */ CommandResult exec_command(string cmdline) throws SpawnError { CommandResult com_ret = new CommandResult(); @@ -246,10 +247,11 @@ } } - /** Launch a process and block this tasklet till it ends. - * Makes sure that a previous call (from any other tasklet) has been completed. - * Returns exit status, stdout and stderr. - */ + /** + * Launch a process and block this tasklet till it ends. + * Makes sure that a previous call (from any other tasklet) has been completed. + * Returns exit status, stdout and stderr. + */ public void sequential_command(string cmdline, out string cmdout, out string cmderr, out int exit_status) { // Register (once) the spawnable function that is our dispatcher @@ -270,8 +272,9 @@ GENERIC } - /** An iproute wrapper - */ + /** + * An iproute wrapper + */ public string iproute(string args) throws IPROUTECommandError { string cmd = Ntk.Settings.IPROUTE_PATH; @@ -289,8 +292,9 @@ return cmdout; } - /** An iproute without exceptions - */ + /** + * An iproute without exceptions + */ public void iproute_exp(string args) { try @@ -308,8 +312,9 @@ GENERIC } - /** An iptables wrapper - */ + /** + * An iptables wrapper + */ public string iptables(string args) throws IPTABLESCommandError { string cmd = Ntk.Settings.IPTABLES_PATH; @@ -327,8 +332,9 @@ return cmdout; } - /** An iptables without exceptions - */ + /** + * An iptables without exceptions + */ public void iptables_exp(string args) { try @@ -342,8 +348,9 @@ } - /** Check reachability of an IP - */ + /** + * Check reachability of an IP + */ public bool check_ping(string ipstr) { string cmd = Ntk.Settings.PING_PATH; @@ -485,8 +492,9 @@ int NTK_TABLE = 200; Regex? NTK_IN_RT_TABLE = null; - /** Initialize linux policy routing db. - */ + /** + * Initialize linux policy routing db. + */ void init_prdb() { try @@ -539,10 +547,11 @@ } public static void register() {RouteSetter.register_class("linux", _create);} - /** mac_table[w.upper()] is present (and has value n) - * iff a routing table exists for packets coming from w - * w is a MAC string, eg '6a:b8:1e:cf:1d:4f' - */ + /** + * mac_table[w.upper()] is present (and has value n) + * iff a routing table exists for packets coming from w + * w is a MAC string, eg '6a:b8:1e:cf:1d:4f' + */ private HashMap mac_table; public LinuxRoute() @@ -606,9 +615,10 @@ ch.send_async(arg); } - /** Makes sure that a routing table exists for packets coming from macaddr. - * Returns the number of that table. - */ + /** + * Makes sure that a routing table exists for packets coming from macaddr. + * Returns the number of that table. + */ public int _table_for_macaddr(string _macaddr) throws Error { string macaddr = _macaddr.down(); @@ -631,8 +641,9 @@ return idn; } - /** Removes all routing table created for packets coming from any macaddr - */ + /** + * Removes all routing table created for packets coming from any macaddr + */ public void _table_for_macaddr_remove_all() throws Error { ArrayList all_macs = new ArrayList(); @@ -641,8 +652,9 @@ _table_for_macaddr_remove(k); } - /** Makes sure that a routing table doesn't exist anymore for packets coming from macaddr - */ + /** + * Makes sure that a routing table doesn't exist anymore for packets coming from macaddr + */ public void _table_for_macaddr_remove(string _macaddr) throws Error { string macaddr = _macaddr.down(); @@ -656,8 +668,9 @@ } } - /** Returns proper iproute command arguments to add/change/delete routes - */ + /** + * Returns proper iproute command arguments to add/change/delete routes + */ public string _modify_routes_cmd(string command, string ip, string cidr, RouteSolutions? route_solutions, string? table=null) { string cmd = @"route $command $(ip)/$(cidr)"; @@ -678,8 +691,9 @@ return cmd; } - /** Returns proper iproute command arguments to add/change/delete a neighbour - */ + /** + * Returns proper iproute command arguments to add/change/delete a neighbour + */ public string _modify_neighbour_cmd(string command, string ip, string? dev, string? pref_src) { string cmd = @"route $command $(ip)"; @@ -694,20 +708,22 @@ } - /** Add a route (that was non existent) towards ip/cidr - * for packets generated by this host. - * The gateways are route_solutions - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets generated by this host. + * The gateways are route_solutions + */ protected override void _add_outgoing_route(string ip, string cidr, RouteSolutions route_solutions) { if (cidr == "32" && route_solutions.contains_gw(ip)) return; iproute_exp(_modify_routes_cmd("add", ip, cidr, route_solutions)); } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions + */ protected override void _add_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error { if (cidr == "32" && route_solutions.contains_gw(ip)) return; @@ -715,31 +731,34 @@ iproute_exp(_modify_routes_cmd("add", ip, cidr, route_solutions, idn.to_string())); } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is UNREACHABLE - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is UNREACHABLE + */ protected override void _add_forwarding_route_unreachable(string ip, string cidr, string prev_hop) throws Error { int idn = _table_for_macaddr(prev_hop); iproute_exp(@"route add table $idn unreachable $ip/$cidr"); } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is DROP - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is DROP + */ protected override void _add_forwarding_route_drop(string ip, string cidr, string prev_hop) throws Error { int idn = _table_for_macaddr(prev_hop); iproute_exp(@"route add table $idn blackhole $ip/$cidr"); } - /** Change a route (that was existent) towards ip/cidr - * for packets generated by this host. - * The gateways are route_solutions. - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets generated by this host. + * The gateways are route_solutions. + * The old gateways were old_route_solutions + */ protected override void _change_outgoing_route(string ip, string cidr, RouteSolutions route_solutions, RouteSolutions old_route_solutions) { if (cidr == "32") @@ -771,11 +790,12 @@ iproute_exp(_modify_routes_cmd("change", ip, cidr, route_solutions)); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * The old gateways were old_route_solutions + */ protected override void _change_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions route_solutions, RouteSolutions old_route_solutions) throws Error { @@ -809,11 +829,12 @@ iproute_exp(_modify_routes_cmd("change", ip, cidr, route_solutions, idn.to_string())); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is UNREACHABLE - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is UNREACHABLE + * The old gateways were old_route_solutions + */ protected override void _change_forwarding_route_unreachable(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error { @@ -827,11 +848,12 @@ iproute_exp(@"route change table $idn unreachable $ip/$cidr"); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is DROP - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is DROP + * The old gateways were old_route_solutions + */ protected override void _change_forwarding_route_drop(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error { @@ -845,11 +867,12 @@ iproute_exp(@"route change table $idn blackhole $ip/$cidr"); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * Previously the route was UNREACHABLE - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * Previously the route was UNREACHABLE + */ protected override void _change_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error { @@ -863,11 +886,12 @@ iproute_exp(_modify_routes_cmd("change", ip, cidr, route_solutions, idn.to_string())); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact now this route is DROP - * Previously the route was UNREACHABLE - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact now this route is DROP + * Previously the route was UNREACHABLE + */ protected override void _change_forwarding_route_drop_was_unreachable(string ip, string cidr, string prev_hop) throws Error { @@ -875,11 +899,12 @@ iproute_exp(@"route change table $idn blackhole $ip/$cidr"); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * Previously the route was DROP - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * Previously the route was DROP + */ protected override void _change_forwarding_route_was_drop(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error { @@ -893,11 +918,12 @@ iproute_exp(_modify_routes_cmd("change", ip, cidr, route_solutions, idn.to_string())); } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact now this route is UNREACHABLE - * Previously the route was DROP - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact now this route is UNREACHABLE + * Previously the route was DROP + */ protected override void _change_forwarding_route_unreachable_was_drop(string ip, string cidr, string prev_hop) throws Error { @@ -905,19 +931,21 @@ iproute_exp(@"route change table $idn unreachable $ip/$cidr"); } - /** Remove a route (that was existent) towards ip/cidr - * for packets generated by this host. - * The old gateways were old_route_solutions - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets generated by this host. + * The old gateways were old_route_solutions + */ protected override void _remove_outgoing_route(string ip, string cidr, RouteSolutions old_route_solutions) { iproute_exp(_modify_routes_cmd("del", ip, cidr, null)); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The old gateways were old_route_solutions - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The old gateways were old_route_solutions + */ protected override void _remove_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error { @@ -925,10 +953,11 @@ iproute_exp(_modify_routes_cmd("del", ip, cidr, null, idn.to_string())); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * Previously the route was UNREACHABLE - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * Previously the route was UNREACHABLE + */ protected override void _remove_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop) throws Error { @@ -936,19 +965,21 @@ iproute_exp(_modify_routes_cmd("del", ip, cidr, null, idn.to_string())); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * Previously the route was DROP - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * Previously the route was DROP + */ protected override void _remove_forwarding_route_was_drop(string ip, string cidr, string prev_hop) throws Error { int idn = _table_for_macaddr(prev_hop); iproute_exp(_modify_routes_cmd("del", ip, cidr, null, idn.to_string())); } - /** Stop forwarding (in fact it means delete all rules for...) - * packets coming from MAC prev_hop. - */ + /** + * Stop forwarding (in fact it means delete all rules for...) + * packets coming from MAC prev_hop. + */ protected override void _forward_no_more_from(string _prev_hop) throws Error { string prev_hop = _prev_hop.down(); @@ -970,36 +1001,41 @@ } } - /** Delete all specific rules for any prev_hop. - */ + /** + * Delete all specific rules for any prev_hop. + */ protected override void _forward_no_more() throws Error { _table_for_macaddr_remove_all(); } - /** Adds a new neighbour with corresponding properties. - */ + /** + * Adds a new neighbour with corresponding properties. + */ protected override void _add_neighbour(string ip, string dev, string pref_src) { iproute_exp(_modify_neighbour_cmd("add", ip, dev, pref_src)); } - /** Edits the neighbour with the corresponding properties. - */ + /** + * Edits the neighbour with the corresponding properties. + */ protected override void _change_neighbour(string ip, string dev, string pref_src, string old_dev) { iproute_exp(_modify_neighbour_cmd("change", ip, dev, pref_src)); } - /** Removes the neighbour with the corresponding properties. - */ + /** + * Removes the neighbour with the corresponding properties. + */ protected override void _delete_neighbour(string ip, string old_dev) { iproute_exp(_modify_neighbour_cmd("del", ip, null, null)); } - /** IGS management **/ - + /** + * IGS management + **/ protected void _disable_rp_filter(string nicname) { string path = @"/proc/sys/net/ipv4/conf/$(nicname)/rp_filter"; @@ -1302,8 +1338,9 @@ } } - /** Managing tunnels via tincd in linux - */ + /** + * Managing tunnels via tincd in linux + */ public class LinuxTunnel : BaseTunnel { private static BaseTunnel _create() {return new LinuxTunnel();} === modified file 'networkid.vala' --- networkid.vala 2012-04-28 10:09:24 +0000 +++ networkid.vala 2012-07-01 04:58:20 +0000 @@ -21,16 +21,19 @@ namespace Ntk.Core { - /** GNode I.D. - * An instance is valid when we have all three values: - * #1 (elderliness) is the elderliness of the gnode inside its upper level gnode. - * #2 (eldest_internal_elderliness) is the elderliness of the eldest gnode inside me. - * #3 (eldest_internal_id) is the ID of the eldest gnode inside me. And it's also my gnode's ID. - * - * In more details: - * . for a gnode of level 0, values #2 has no meaning (will always be 0) - * . for a gnode of level 'levels', values #1 and #2 have no meaning. Its value #3 is the netid. - */ + /** + *{{{ + * GNode I.D. + * An instance is valid when we have all three values: + * |#1 (elderliness) is the elderliness of the gnode inside its upper level gnode. + * |#2 (eldest_internal_elderliness) is the elderliness of the eldest gnode inside me. + * |#3 (eldest_internal_id) is the ID of the eldest gnode inside me. And it's also my gnode's ID. + * + * In more details: + * | . for a gnode of level 0, values #2 has no meaning (will always be 0) + * | . for a gnode of level 'levels', values #1 and #2 have no meaning. Its value #3 is the netid. + *}}} + */ public class GNodeID : Object, ISerializable { public int elderliness {get; private set;} @@ -49,9 +52,10 @@ } } - /** The elderliness of a gnode inside its upper level will never change. - * The values #2 and #3 might change. - */ + /** + * The elderliness of a gnode inside its upper level will never change. + * The values #2 and #3 might change. + */ public bool change_values(GNodeID eldest_internal) { var new_eldest_internal_elderliness = eldest_internal.elderliness; @@ -63,19 +67,21 @@ return ret; } - /** This property is used as the key for a comparison when a node recalculates its gids. - * The comparison is between 2 different gnodes of the same level. The one which results lower - * is the elder inside the upper level, so that the first one will pass its values #1 and #3 - * to the upper level as values #2 and #3. - */ + /** + * This property is used as the key for a comparison when a node recalculates its gids. + * The comparison is between 2 different gnodes of the same level. The one which results lower + * is the elder inside the upper level, so that the first one will pass its values #1 and #3 + * to the upper level as values #2 and #3. + */ public int min_will_bubble { get { return elderliness; } } - /** If we just want to know the one that "will bubble" we could do this - */ + /** + * If we just want to know the one that "will bubble" we could do this + */ public GNodeID will_bubble(GNodeID? other) { if (other == null) return this; @@ -83,18 +89,20 @@ return other; } - /** This property is used as the key for a comparison when a node verifies if the gnode has splitted (see route.get_eldest_gid()). - * The comparison is between 2 instances that represent the same gnode. The one which results lower - * is the one which contains the elder gnode inside me, so that the first will not rehook. - */ + /** + * This property is used as the key for a comparison when a node verifies if the gnode has splitted (see route.get_eldest_gid()). + * The comparison is between 2 instances that represent the same gnode. The one which results lower + * is the one which contains the elder gnode inside me, so that the first will not rehook. + */ public int min_will_not_rehook { get { return eldest_internal_elderliness; } } - /** If we just want to know the one that "will not_rehook" we could do this - */ + /** + * If we just want to know the one that "will not_rehook" we could do this + */ public GNodeID will_not_rehook(GNodeID? other) { if (other == null) return this; @@ -153,9 +161,10 @@ } } - /** Network I.D. - * It is a set of GNodeid of uppermost level - */ + /** + * Network I.D. + * It is a set of GNodeid of uppermost level + */ public class NetworkID : Object, ISerializable { private Gee.List gnodeids; @@ -178,10 +187,11 @@ gnodeids = (Gee.List)lst.backed; } - /** Compares two Networkid to see if they belong to the same network. - * True iff some items match. It is not needed to look for the "will_bubble" - * one; that would even be a risk in the early stage of a hook. - */ + /** + * Compares two Networkid to see if they belong to the same network. + * True iff some items match. It is not needed to look for the "will_bubble" + * one; that would even be a risk in the early stage of a hook. + */ public bool is_same_network(NetworkID other) { if (other == null) return false; @@ -192,9 +202,10 @@ return false; } - /** When 2 NetworkID are not on the same network use this method - * to see which one has to be preferred (the other one will rehook) - */ + /** + * When 2 NetworkID are not on the same network use this method + * to see which one has to be preferred (the other one will rehook) + */ public bool is_preferred_over(NetworkID other) { if (other == null) return true; @@ -210,8 +221,9 @@ return bubble_me.ident > bubble_other.ident; } - /** Use to see iff a netid has changed - */ + /** + * Use to see iff a netid has changed + */ public bool is_strictly_equal(NetworkID other) { if (other == null) return false; === modified file 'networkinterfaces.vala' --- networkinterfaces.vala 2011-11-27 17:56:47 +0000 +++ networkinterfaces.vala 2012-06-28 01:59:51 +0000 @@ -21,7 +21,8 @@ namespace Ntk.Core { - /** The collection of NetworkInterfaceManagers handled by this node. + /** + * The collection of NetworkInterfaceManagers handled by this node. */ public class NetworkInterfaces : Object { === modified file 'nic_generic.vala' --- nic_generic.vala 2011-11-15 20:51:00 +0000 +++ nic_generic.vala 2012-07-01 04:02:08 +0000 @@ -44,8 +44,9 @@ addresses = new ArrayList(); } - /** Brings the interface up. - */ + /** + * Brings the interface up. + */ public void up() { // common stuff? @@ -54,8 +55,9 @@ } protected abstract void _up(); - /** Brings the interface down. - */ + /** + * Brings the interface down. + */ public void down() { // common stuff? @@ -64,8 +66,9 @@ } protected abstract void _down(); - /** Add NIC address. - */ + /** + * Add NIC address. + */ public void add_address(string address) { // common stuff? @@ -77,8 +80,9 @@ } protected abstract void _add_address(string address); - /** Remove NIC address. - */ + /** + * Remove NIC address. + */ public void remove_address(string address) { // common stuff? @@ -90,8 +94,9 @@ } protected abstract void _remove_address(string address); - /** Disables filtering. - */ + /** + * Disables filtering. + */ public void disable_filtering() { // common stuff? === modified file 'ntkd.vala' --- ntkd.vala 2012-05-11 15:36:19 +0000 +++ ntkd.vala 2012-07-01 02:48:46 +0000 @@ -16,11 +16,16 @@ * along with Netsukuku. If not, see . */ + + using Gee; using Ntk.Lib; namespace Ntk.Core { + /** + * The Netsukuku daemon, entry point. + */ public class Ntkd { static int verbosity; @@ -33,6 +38,7 @@ public static int main(string[] args) { + /*Handle arguments*/ verbosity = -1; nicreset = false; config_file = ""; @@ -143,7 +149,11 @@ static NtkNode? me; static bool do_me_exit = false; - + /** + * recieved a signal, exit + * Exit all the same on all signals for the time being. + * @param signal The signal code, see: man 7 signal on unix systems + */ public static void safe_exit(int signal) { // We got here because of a signal. @@ -155,11 +165,17 @@ // of a new tasklet. do_me_exit = true; } - + /** + * This reloads andna the netsukuku alternative DNS system + * See:[[http://netsukuku.freaknet.org/doc/main_doc/andna.pdf|andna]] + * + * Not actually implemented yet, an empty function... + * @param signal the recieved signal + */ public static void reload_andna(int signal) { // TODO reload hostnames and restart andna } } + } - === modified file 'peer_to_peer.vala' --- peer_to_peer.vala 2012-04-28 10:09:24 +0000 +++ peer_to_peer.vala 2012-07-01 04:00:56 +0000 @@ -29,9 +29,10 @@ GENERIC } - /** This value is big enough to last forever and - * not big enough to ever produce an overflow. - */ + /** + * This value is big enough to last forever and + * not big enough to ever produce an overflow. + */ public TimeCapsule get_max_elder() { return new TimeCapsule(-999999999); @@ -54,8 +55,9 @@ { } - /** Override the is_free() method of DataClass (see map.vala) - */ + /** + * Override the is_free() method of DataClass (see map.vala) + */ public override bool is_free() { return !participant; @@ -211,9 +213,10 @@ private int pid; private bool participant; - /** levels, gsize, me: the same of Map - * pid: PeerToPeer id of the service associated to this map - */ + /** + * levels, gsize, me: the same of Map + * pid: PeerToPeer id of the service associated to this map + */ public MapPeerToPeer(int levels, int gsize, NIP me, int pid) { base(levels, gsize, me); @@ -226,8 +229,9 @@ participant = false; } - /** Initialize map from a neighbour's data. - */ + /** + * Initialize map from a neighbour's data. + */ public void initialize_from_neighbour(NIP nip, PackedParticipantNodes packed_nodes) { int lvl = nip_cmp(nip.get_positions()); @@ -238,8 +242,9 @@ node[l, pos] = packed_nodes.packednodes.get(l).get(pos); } - /** A new instance is created for a position that represents me. Otherwise, the usual behaviour. - */ + /** + * A new instance is created for a position that represents me. Otherwise, the usual behaviour. + */ public override ParticipantNode node_get(int lvl, int pos) { // The positions that represent myself, have no real data. @@ -302,15 +307,17 @@ Tasklet.spawn((FunctionDelegate)helper_node_dead, &arg); } - /** Set me to be a participant node. - */ + /** + * Set me to be a participant node. + */ public void participate() { participant = true; } - /** Set me to be a non-participant node. - */ + /** + * Set me to be a non-participant node. + */ public void sit_out() { participant = false; @@ -320,8 +327,9 @@ { error("MapPeerToPeer.get_packed_nodes: equal_func not implemented"); } - /** Prepares a packed map_peer_to_peer to be passed to refresh participations - */ + /** + * Prepares a packed map_peer_to_peer to be passed to refresh participations + */ public PackedParticipantNodes get_packed_nodes() { ArrayList> l1 = new ArrayList>((EqualFunc)not_impl_equal_func); @@ -354,19 +362,20 @@ } } - /** Avoid loops, neverending stories, and the like. - * - * When a message is routed through the net by the peer_to_peer module, - * we keep track of the path walked, through an instance of this class. - * There are several functions in module peer_to_peer that try to - * route messages, such as msg_deliver, find_nearest, - * number_of_participants, and so on. Each function receives - * as a parameter a PeerToPeerTracerPacketList instance, - * calls its method execute (passing its own maproute) - * and then passes it to the next hop. - * The first caller instantiate it by passing no parameters or - * can specify the timeout. - */ + /** + * Avoid loops, neverending stories, and the like. + * + * When a message is routed through the net by the peer_to_peer module, + * we keep track of the path walked, through an instance of this class. + * There are several functions in module peer_to_peer that try to + * route messages, such as msg_deliver, find_nearest, + * number_of_participants, and so on. Each function receives + * as a parameter a PeerToPeerTracerPacketList instance, + * calls its method execute (passing its own maproute) + * and then passes it to the next hop. + * The first caller instantiate it by passing no parameters or + * can specify the timeout. + */ public class PeerToPeerTracerPacketList : Object, ISerializable { internal ArrayList>? tpl; @@ -508,10 +517,11 @@ } } - /** This is the class that must be inherited to create a Strict PeerToPeer module - * service. A strict service is a service where all the hosts connected - * to Netsukuku are participant, so the MapPeerToPeer is not used here. - */ + /** + * This is the class that must be inherited to create a Strict PeerToPeer module + * service. A strict service is a service where all the hosts connected + * to Netsukuku are participant, so the MapPeerToPeer is not used here. + */ public class PeerToPeer : RPCDispatcher, IPeerToPeer { public weak MapRoute maproute; @@ -542,47 +552,54 @@ has_valid_map = false; } - /** Called after peer_to_peer_hook. Overridable (eg in OptionalPeerToPeer) - */ + /** + * Called after peer_to_peer_hook. Overridable (eg in OptionalPeerToPeer) + */ public virtual void start_operations() { has_valid_map = true; map_peer_to_peer_validated(); } - /** Called when address is dying. Overridable (eg in OptionalPeerToPeer) - */ + /** + * Called when address is dying. Overridable (eg in OptionalPeerToPeer) + */ public virtual void stop_operations() { string ipstr = nip_to_str(maproute.levels, maproute.gsize, maproute.me); Logger.ultradebug(@"PeerToPeer: stopping operations for $(ipstr)"); } - /** Returns True iff the node lvl,pos is participating - * to the service. For a "strict PeerToPeer" it means iff the node - * exists in maproute. - * An inheriting class could override the function. - */ + /** + * Returns True iff the node lvl,pos is participating + * to the service. For a "strict PeerToPeer" it means iff the node + * exists in maproute. + * An inheriting class could override the function. + */ public virtual bool is_participant(int lvl, int pos) { RouteNode x = maproute.node_get(lvl, pos); return !x.is_free(); } - /** This is the function h:KEY-->hIP. - * - * You should override it with your own mapping function. - */ + /** + * This is the function h:KEY-->hIP. + * + * You should override it with your own mapping function. + */ public virtual NIP h(Object key) { return (NIP)key; } - /** Helper functions for "routed" methods **/ + /** + * Helper functions for "routed" methods + **/ - /** Returns the AggregatedNeighbour instances of the neighbours we can use to reach - * the hash node, in order of efficiency. - */ + /** + * Returns the AggregatedNeighbour instances of the neighbours we can use to reach + * the hash node, in order of efficiency. + */ public Gee.List neighbours_get_from_lvl_pos(int lvl, int pos) { Gee.List routes = maproute.node_get(lvl, pos).all_valid_routes(); @@ -619,10 +636,11 @@ return ret; } - /** Returns the destination in hierarchical coordinates of the best - * approximation of the passed NIP as a participant to the service. - * Returns null iff it's me. - */ + /** + * Returns the destination in hierarchical coordinates of the best + * approximation of the passed NIP as a participant to the service. + * Returns null iff it's me. + */ public HCoord? search_participant(NIP hIP, int path_sign=1) throws PeerToPeerError { int[] H_hIP = new int[maproute.levels]; @@ -668,11 +686,14 @@ return new PartialNIP(positions); } - /** Sending of messages **/ + /** + * Sending of messages + **/ - /** Start a tentative to send a message to a certain - * perfect hip - */ + /** + * Start a tentative to send a message to a certain + * perfect hip + */ public ISerializable msg_send(NIP sender_nip, NIP hip, RemoteCall data) throws Error { PeerToPeerTracerPacketList peer_to_peer_tpl = new PeerToPeerTracerPacketList(); @@ -708,8 +729,9 @@ return ret; } - /** Delivers a msg to the nearest to hip - */ + /** + * Delivers a msg to the nearest to hip + */ public ISerializable msg_deliver(PeerToPeerTracerPacketList peer_to_peer_tpl, NIP sender_nip, NIP hip, RemoteCall data) throws Error { if (! has_valid_map) @@ -785,15 +807,17 @@ return ret; } - /** Execution of a msg - */ + /** + * Execution of a msg + */ public ISerializable msg_exec(NIP sender_nip, RemoteCall data) throws Error { return _dispatch(null, data); } - /** Search functions for registration with replica. Routed. **/ - + /** + * Search functions for registration with replica. Routed. + **/ public Gee.List find_nearest_to_register(NIP hash_nip, int num_dupl, int? inside_gnode_level=null) throws RPCError { // If 'inside_gnode_level' is None the research is network wide. @@ -927,8 +951,9 @@ } } - /** Search functions for hooking phase. Routed. **/ - + /** + * Search functions for hooking phase. Routed. + **/ public int get_number_of_participants(int lvl, int pos, int timeout) throws RPCError { return number_of_participants(new PeerToPeerTracerPacketList(timeout), lvl, pos); @@ -1026,8 +1051,9 @@ } } - /** Helper functions for hooking phase. **/ - + /** + * Helper functions for hooking phase. + **/ public void find_hook_peers(out NIP? ret_nip_to_reach_first_forward, out NIP? ret_nip_to_reach_first_back, out NIP? ret_nip_to_reach_last_back, @@ -1088,9 +1114,10 @@ return; } - /** y is the perfect nip for a particular key. - * If someone asks for y, will he hit me before x? - */ + /** + * y is the perfect nip for a particular key. + * If someone asks for y, will he hit me before x? + */ public bool is_x_after_me_for_y(NIP x, NIP y) { int i = maproute.nip_cmp(x.get_positions()); @@ -1131,8 +1158,9 @@ return hIP; } - /** Overridable. Similar to FakeRmt.rmt() - */ + /** + * Overridable. Similar to FakeRmt.rmt() + */ public virtual ISerializable rmt(RemoteCall data) throws Error { evaluate_hash_nip(); @@ -1174,8 +1202,9 @@ public OptionalPeerToPeer self; } - /** This is the class that must be inherited to create a PeerToPeer module. - */ + /** + * This is the class that must be inherited to create a PeerToPeer module. + */ public class OptionalPeerToPeer : PeerToPeer, IOptionalPeerToPeer { public MapPeerToPeer map_peer_to_peer; @@ -1396,9 +1425,10 @@ Tasklet.spawn((FunctionDelegate)helper_send_refresh_periodically, &arg); } - /** Returns True iff the node lvl, pos is participating - * to the service. - */ + /** + * Returns True iff the node lvl, pos is participating + * to the service. + */ public override bool is_participant(int lvl, int pos) { return map_peer_to_peer.node_get(lvl, pos).participant; @@ -1410,8 +1440,9 @@ } } - /** Become a participant node. - */ + /** + * Become a participant node. + */ public void participate() { try @@ -1429,8 +1460,9 @@ catch (RPCError ne) {} } - /** Go outside and don't participate to the service. - */ + /** + * Go outside and don't participate to the service. + */ public void sit_out() { try @@ -1501,8 +1533,9 @@ public PeerToPeerAll self; } - /** Class of all the registered peer_to_peer services - */ + /** + * Class of all the registered peer_to_peer services + */ public class PeerToPeerAll : Object, IPeerToPeerAll { public AggregatedNeighbourManager aggregated_neighbour_manager {get; private set;} @@ -1590,24 +1623,25 @@ if (service.has_key(pid)) service.unset(pid); } - /** Used to add for the first time a PeerToPeer instance of a module in the - * PeerToPeerAll dictionary. - */ + /** + * Used to add for the first time a PeerToPeer instance of a module in the + * PeerToPeerAll dictionary. + */ public virtual void peer_to_peer_register(PeerToPeer peer_to_peer) throws PeerToPeerError { Logger.ultradebug(@"Called PeerToPeerAll.peer_to_peer_register for $(peer_to_peer.pid)"); - /* + /* * Both PeerToPeer and OptionalPeerToPeer services register themself in PeerToPeerAll, via - * this function. + * this function. * The registration of an OptionalPeerToPeer service might occur after the - * start_operations of PeerToPeerAll has completed. In this case the instance created from - * the class of the new module (here passed in parameter 'peer_to_peer') is - * going to replace a possibly existent instance of base class - * OptionalPeerToPeer. In this case we will replace the member variable - * map_peer_to_peer of the new instance with the one from the old instance. + * start_operations of PeerToPeerAll has completed. In this case the instance created from + * the class of the new module (here passed in parameter 'peer_to_peer') is + * going to replace a possibly existent instance of base class + * OptionalPeerToPeer. In this case we will replace the member variable + * map_peer_to_peer of the new instance with the one from the old instance. * If the inheriting class had to handle its map_peer_to_peer in a different - * manner, it has to consider this, and instantiate it after the - * call of this function. + * manner, it has to consider this, and instantiate it after the + * call of this function. */ if (service.has_key(peer_to_peer.pid)) { @@ -1667,8 +1701,9 @@ return new SetOptionalServiceParticipants(l_osp); } - /** It gets the peer_to_peer maps from our nearest neighbour. - */ + /** + * It gets the peer_to_peer maps from our nearest neighbour. + */ public void retrieve_optional_services_and_participants() { Logger.debug("PeerToPeerAll retrieve_optional_services_and_participants: started"); @@ -1745,8 +1780,9 @@ return ret; } - /** Start operations on various peer_to_peer services. - */ + /** + * Start operations on various peer_to_peer services. + */ private void impl_start_operations() throws Error { // This method il called after IS_MATURE === modified file 'qspn.vala' --- qspn.vala 2012-04-28 10:09:24 +0000 +++ qspn.vala 2012-07-01 03:50:33 +0000 @@ -21,13 +21,15 @@ namespace Ntk.Core { - /** Represents the tracer packet of the path covered until now by an ETP. - * This TP may have covered different levels. In general, TPL - * is a list of blocks. Each block is a (lvl, TP) pair, where lvl is - * the level of the block and TP is the tracer packet composed - * during the transit in the level `lvl'. - * TP is a list of (hop, rem) pairs. - */ + /** + * Represents the tracer packet of the path covered until now by an ETP. + * This TP may have covered different levels. In general, TPL + * is a list of blocks. Each block is a (lvl, TP) pair, where lvl is + * the level of the block and TP is the tracer packet composed + * during the transit in the level `lvl'. + * TP is a list of (hop, rem) pairs. + * See: [[http://netsukuku.freaknet.org/doc/main_doc/qspn.pdf]] + */ public class TracerPacketList : Object, ISerializable { class TraceElement @@ -182,10 +184,11 @@ tpl.peek_head().tp.peek_head().rem = new NullREM(); } - /** Tests if this TPL already contains me. - * The parameter nip has to be the NIP of this very node. - * The TPL is already in the form pertinent to this node. - */ + /** + * Tests if this TPL already contains me. + * The parameter nip has to be the NIP of this very node. + * The TPL is already in the form pertinent to this node. + */ public bool contains(NIP nip) { foreach (Block block in tpl) @@ -245,8 +248,9 @@ } } - /** Represents a route to a given destination in a given level. Serializable. - */ + /** + * Represents a route to a given destination in a given level. Serializable. + */ public class RouteInSet : Object, ISerializable { public REM rem {get; private set;} @@ -332,8 +336,9 @@ } } - /** Useful for serialization of RoutesSetPerLevel - */ + /** + * Useful for serialization of RoutesSetPerLevel + */ public class PositionInRoutesSetPerLevel : Object, ISerializable { public int dst {get; private set;} @@ -363,11 +368,12 @@ } } - /** Contains routes for a given level. - * It is serializable. - * It is iterable and gives the destinations (int). - * When you have a destination you use get_value. - */ + /** + * Contains routes for a given level. + * It is serializable. + * It is iterable and gives the destinations (int). + * When you have a destination you use get_value. + */ public class RoutesSetPerLevel : Object, ISerializable { private HashMap routes; @@ -442,8 +448,9 @@ } } - /** Represents a portion of the map_route of a node. - */ + /** + * Represents a portion of the map_route of a node. + */ public class RoutesSet : Object, ISerializable { public RoutesSetPerLevel[] per_level; @@ -517,8 +524,9 @@ } } - /** The return value of request_etp, contains R, TPL and sequential_number - */ + /** + * The return value of request_etp, contains R, TPL and sequential_number + */ public class ExtendedTracerPacket : Object, ISerializable { public RoutesSet r; @@ -792,10 +800,11 @@ Tasklet.spawn((FunctionDelegate)helper_warn_my_gateways_periodically, &arg); } - /** The caller (nip) is in my network and wants me to act - * as a gateway for him. - * I am told its MACs. - */ + /** + * The caller (nip) is in my network and wants me to act + * as a gateway for him. + * I am told its MACs. + */ public void act_as_gateway(NIP nip_caller, int nodeid_caller, NetworkID netid_caller, Gee.List macs) { // We choose if we want to be a gateway for this nip,netid. @@ -906,8 +915,9 @@ etp_exec(aggregated_neighbour, etp); } - /** This remotable is called to request an ETP - */ + /** + * This remotable is called to request an ETP + */ public ExtendedTracerPacket request_etp(int prev_mod_seq_num, NIP nip_caller, int nodeid_caller, NetworkID netid_caller, Gee.List macs_caller) throws QspnError @@ -1110,15 +1120,17 @@ return ret; } - /** Answer the size of my network. - */ + /** + * Answer the size of my network. + */ public int request_size() { return evaluate_my_size(); } - /** Evaluate the size of my network. - */ + /** + * Evaluate the size of my network. + */ public int evaluate_my_size() { // TODO find a way to estimate real size of the network. @@ -1130,11 +1142,12 @@ public void new_sequence_number(NIP nip_x, int nodeid_x, int seq_num_x) { - /* If we have not x as a neighbour, ignore the message. - * If we have the neighbour, and it is in another network, then decide if we have to rehook. - * If we have the neighbour, but the current modification_sequence_number - * is greater than the one in the current message, ignore the message. - * Otherwise, ask for updates. + /* + * If we have not x as a neighbour, ignore the message. + * If we have the neighbour, and it is in another network, then decide if we have to rehook. + * If we have the neighbour, but the current modification_sequence_number + * is greater than the one in the current message, ignore the message. + * Otherwise, ask for updates. */ Logger.debug(@"new_sequence_number: ($nip_x, $nodeid_x) changes state"); AggregatedNeighbour? aggregated_neighbour = @@ -1357,8 +1370,9 @@ Tasklet.spawn((FunctionDelegate)helper_etp_exec_dispatcher, &arg); } - /** Executes an ETP received from a neighbour which is for sure of my same network. - */ + /** + * Executes an ETP received from a neighbour which is for sure of my same network. + */ public void impl_etp_exec(AggregatedNeighbour aggregated_neighbour, ExtendedTracerPacket etp) throws Error { // Since etp_exec and request_updates are executed in different tasklets, we could get called @@ -1498,8 +1512,9 @@ return null; } - /** Detecting a variation (new link): advertise this modification. - */ + /** + * Detecting a variation (new link): advertise this modification. + */ public void etp_new_link(AggregatedNeighbour aggregated_neighbour) { struct_helper_Etp_etp_new_link arg = struct_helper_Etp_etp_new_link(); @@ -1508,8 +1523,9 @@ Tasklet.spawn((FunctionDelegate)helper_etp_new_link, &arg); } - /** Detecting a variation (changed link): possible hook before really doing the variation. - */ + /** + * Detecting a variation (changed link): possible hook before really doing the variation. + */ public void etp_before_changed_link(AggregatedNeighbour aggregated_neighbour) { } @@ -1553,8 +1569,9 @@ return null; } - /** Detecting a variation (changed link): advertise this modification. - */ + /** + * Detecting a variation (changed link): advertise this modification. + */ public void etp_changed_link(AggregatedNeighbour aggregated_neighbour, REM oldrem) { struct_helper_Etp_etp_changed_link arg = struct_helper_Etp_etp_changed_link(); @@ -1564,8 +1581,9 @@ Tasklet.spawn((FunctionDelegate)helper_etp_changed_link, &arg); } - /** Detecting a variation (dead link): possible hook before really doing the variation. - */ + /** + * Detecting a variation (dead link): possible hook before really doing the variation. + */ public void etp_before_dead_link(AggregatedNeighbour aggregated_neighbour) { } @@ -1596,8 +1614,9 @@ return null; } - /** Detecting a variation (dead link): advertise this modification. - */ + /** + * Detecting a variation (dead link): advertise this modification. + */ public void etp_dead_link(AggregatedNeighbour aggregated_neighbour) { struct_helper_Etp_etp_dead_link arg = struct_helper_Etp_etp_dead_link(); @@ -1641,8 +1660,9 @@ return null; } - /** We are colliding and we are going to rehook. - */ + /** + * We are colliding and we are going to rehook. + */ public void collision_rehook(NetworkID neighbour_netid) { struct_helper_Etp_collision_rehook arg = struct_helper_Etp_collision_rehook(); === modified file 'radar.vala' --- radar.vala 2012-03-09 14:52:11 +0000 +++ radar.vala 2012-07-01 03:44:17 +0000 @@ -21,25 +21,26 @@ namespace Ntk.Core { - public errordomain RadarError { - DUPL - } + public errordomain RadarError { + DUPL + } struct struct_helper_Radar_run { public Radar self; } - /** An instance of Radar uses a certain network interface on behalf of a certain AddressManager. - * The radar sends in broadcast a bouquet of MAX_BOUQUET packets and waits - * for the reply of the alive nodes. It then recollects the replies and builds - * a small statistic. - * Then it reports the detected neighbours to the NeighbourManager(s) interested - * in that network interface. - * - * A radar is fired periodically by Radar.run(), which is started as a - * microfunc. - */ + /** + * An instance of Radar uses a certain network interface on behalf of a certain AddressManager. + * The radar sends in broadcast a bouquet of MAX_BOUQUET packets and waits + * for the reply of the alive nodes. It then recollects the replies and builds + * a small statistic. + * Then it reports the detected neighbours to the NeighbourManager(s) interested + * in that network interface. + * + * A radar is fired periodically by Radar.run(), which is started as a + * microfunc. + */ public class Radar : Object { protected string dev_name; @@ -126,8 +127,9 @@ Tasklet.spawn((FunctionDelegate)helper_run, &arg); } - /** Stop the radar scanner - */ + /** + * Stop the radar scanner + */ public void stop() { if (tasklet != null) @@ -180,16 +182,18 @@ radar_reset(); } - /** Clean the objects needed by radar() - */ + /** + * Clean the objects needed by radar() + */ public void radar_reset() { // Clean some stuff this.gather_rtts = new HashMap>(); } - /** save each node's rtt - */ + /** + * save each node's rtt + */ public virtual void time_register(int radar_id, int levels, int gsize, NIP nip, int nodeid, NetworkID netid, string mac, bool is_primary, bool is_auxiliary) { @@ -228,8 +232,9 @@ } } - /** Calculates the average RTT of the neighbour for the device associated to this radar. - */ + /** + * Calculates the average RTT of the neighbour for the device associated to this radar. + */ public int get_avg_rtt(string key) { ArrayList rtts = gather_rtts[key]; @@ -255,8 +260,9 @@ key_nip = new NIP(pos); } - /** Calculate the average rtt of all the neighbours - */ + /** + * Calculate the average rtt of all the neighbours + */ public virtual HashMap get_all_avg_rtt() { HashMap all_avg = new HashMap(); === modified file 'remotable_interfaces.vala' --- remotable_interfaces.vala 2012-03-09 14:52:11 +0000 +++ remotable_interfaces.vala 2012-06-28 03:15:56 +0000 @@ -23,7 +23,8 @@ { /*** Etp ***/ - /** This is the interface for the remotable methods of the class Etp + /** + * This is the interface for the remotable methods of the class Etp */ public interface IEtp : Object { @@ -38,8 +39,9 @@ /*** TunnelManager ***/ - /** This is the interface for the remotable methods of the class TunnelManager - */ + /** + *This is the interface for the remotable methods of the class TunnelManager + */ public interface ITunnelManager : Object { public abstract string? choose_tunnel_protocol(Gee.List protocols) throws RPCError; @@ -51,7 +53,8 @@ /*** Coord ***/ - /** This is the interface for the remotable methods of the class Coord + /** + * This is the interface for the remotable methods of the class Coord */ public interface ICoord : Object { @@ -64,8 +67,9 @@ /*** PeerToPeer ***/ - /** This is the interface for the remotable methods of the class PeerToPeer - */ + /** + * This is the interface for the remotable methods of the class PeerToPeer + */ public interface IPeerToPeer : Object { public abstract ISerializable msg_deliver(PeerToPeerTracerPacketList peer_to_peer_tpl, NIP sender_nip, NIP hip, RemoteCall data) throws Error; @@ -85,8 +89,9 @@ /*** MapRoute ***/ - /** This is the interface for the remotable methods of the class MapRoute - */ + /** + * This is the interface for the remotable methods of the class MapRoute + */ public interface IMapRoute : Object { public abstract int free_nodes_nb(int lvl) throws RPCError; @@ -97,8 +102,9 @@ /*** AggregatedNeighbourManager ***/ - /** This is the interface for the remotable methods of the class AggregatedNeighbourManager - */ + /** + * This is the interface for the remotable methods of the class AggregatedNeighbourManager + */ public interface IAggregatedNeighbourManager : Object { public abstract void reply(Object? _rpc_caller, int radar_id, NIP nip, int nodeid, NetworkID netid) throws RPCError; @@ -109,8 +115,9 @@ /*** Hook ***/ - /** This is the interface for the remotable methods of the class Hook - */ + /** + * This is the interface for the remotable methods of the class Hook + */ public interface IHook : Object { public abstract Gee.List list_non_saturated_levels() throws RPCError; @@ -118,8 +125,9 @@ /*** BorderNodesManager ***/ - /** This is the interface for the remotable methods of the class BorderNodesManager - */ + /** + * This is the interface for the remotable methods of the class BorderNodesManager + */ public interface IBorderNodesManager : Object { public abstract Gee.List get_distances(Object? _rpc_caller, === modified file 'route_generic.vala' --- route_generic.vala 2012-04-28 10:07:10 +0000 +++ route_generic.vala 2012-07-01 03:42:01 +0000 @@ -20,8 +20,9 @@ namespace Ntk.Core { - /** A solution to reach a destination. - */ + /** + * A solution to reach a destination. + */ public class RouteSolution : Object, Comparable { public string gateway {get; private set;} @@ -66,8 +67,9 @@ internal BaseRouteSolutions() {} } - /** List of possible solutions to reach a destination - */ + /** + * List of possible solutions to reach a destination + */ public class RouteSolutions : BaseRouteSolutions { private TreeSet paths; @@ -119,8 +121,9 @@ } } - /** This class represents a Tunnel. It is used in a ordered list in the abstract base class RouteSetter. - */ + /** + * This class represents a Tunnel. It is used in a ordered list in the abstract base class RouteSetter. + */ public class TunnelItem : Object { public string ipstr {get; private set;} @@ -165,35 +168,44 @@ private BaseRouteSolutions UNREACHABLE; private BaseRouteSolutions DROP; - /** routes_table[(null, v)] is present (and has value y) - * iff a RULE destination = v → gateway = y exists in table - * routes_table[(null, v)] is NOT present - * iff no routes exist for destination = v → host/network is UNREACHABLE - * routes_table[(w, v)] is present (and has value y) - * iff a RULE source w, destination = v → gateway = y exists in table - * routes_table[(w, v)] is present and has value UNREACHABLE - * iff a RULE source w, destination = v → host/network UNREACHABLE exists in table - * routes_table[(w, v)] is present and has value DROP - * iff a RULE source w, destination = v → host/network DROP (blackhole) exists in table - * v is a ip/cidr string, eg '192.168.0.0/16'; - * w is a MAC string, eg '6a:b8:1e:cf:1d:4f'; - * the pair (w,v) is a Variant "(mss)" - * y is a BaseRouteSolutions instance. - */ + /** + * {{{ + * routes_table[(null, v)] is present (and has value y) + * | iff a RULE destination = v → gateway = y exists in table + * routes_table[(null, v)] is NOT present + * | iff no routes exist for destination = v → host/network is UNREACHABLE + * routes_table[(w, v)] is present (and has value y) + * | iff a RULE source w, destination = v → gateway = y exists in table + * routes_table[(w, v)] is present and has value UNREACHABLE + * | iff a RULE source w, destination = v → host/network UNREACHABLE exists in table + * routes_table[(w, v)] is present and has value DROP + * | iff a RULE source w, destination = v → host/network DROP (blackhole) exists in table + * v is a ip/cidr string, eg '192.168.0.0/16'; + * w is a MAC string, eg '6a:b8:1e:cf:1d:4f'; + * the pair (w,v) is a Variant "(mss)" + * y is a BaseRouteSolutions instance. + *}}} + */ private HashMap routes_table; - /** neighbours_table[ip] is present (and has value dev) - * iff a RULE neighbour = ip exists in table - * ip and dev are strings, eg '192.168.1.1', 'eth1' - */ + /** + * {{{ + * neighbours_table[ip] is present (and has value dev) + * iff a RULE neighbour = ip exists in table + * ip and dev are strings, eg '192.168.1.1', 'eth1' + * }}} + */ private HashMap neighbours_table; - /** IGS current status in kernel rules: - * mode in ['NONE', 'SHARE', 'USE', 'BOTH'] - * announce_myself is a boolean - * list_tunnels is a ordered list of TunnelItem - */ - private string mode; + /** + * + * IGS current status in kernel rules: + * mode in ['NONE', 'SHARE', 'USE', 'BOTH'] + * announce_myself is a boolean + * list_tunnels is a ordered list of TunnelItem + * + */ + private string mode; // Could this not be an int? private bool announce_myself; private ArrayList list_tunnels; @@ -211,8 +223,9 @@ list_tunnels = new ArrayList(tunnel_equal_func); } - /** Returns a list of tuple containing str(IP), str(bits) - */ + /** + * Returns a list of tuple containing str(IP), str(bits) + */ public Collection get_known_destinations() { GLib.EqualFunc variant_equal_func = (a, b) => a.equal(b); @@ -232,8 +245,9 @@ return ret; } - /** Returns a copy of the dict {ipstr: dev} of neighbours - */ + /** + * Returns a copy of the dict {ipstr: dev} of neighbours + */ public Gee.Map get_known_neighbours() { HashMap ret = new HashMap(); @@ -241,8 +255,9 @@ return ret; } - /** We have no routes - */ + /** + * We have no routes + */ public void reset_routes(string ip_whole_network, string cidr_whole_network) throws Error { if (_reset_routes(ip_whole_network, cidr_whole_network)) @@ -290,8 +305,9 @@ } } - /** Maintains this default routes for this destination. - */ + /** + * Maintains this default routes for this destination. + */ public void outgoing_routes(string ip, string cidr, RouteSolutions? route_solutions) throws Error { /* @@ -344,9 +360,10 @@ } } - /** Maintains this routes for this destination when prev_hop is the - * gateway from which we received the packet. - */ + /** + * Maintains this routes for this destination when prev_hop is the + * gateway from which we received the packet. + */ public void forwarding_routes(string ip, string cidr, string prev_hop, RouteSolutions? route_solutions) throws Error { /* @@ -398,10 +415,11 @@ Variant tuple_mac_ipcidr = new Variant("(mss)", w, v); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Add a route (that was non existent) towards ip/cidr - * for packets generated by this host. - * The gateways are route_solutions - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets generated by this host. + * The gateways are route_solutions + */ protected abstract void _add_outgoing_route(string ip, string cidr, RouteSolutions route_solutions); void add_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error @@ -412,10 +430,11 @@ Variant tuple_mac_ipcidr = new Variant("(mss)", w, v); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions + */ protected abstract void _add_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error; void add_forwarding_route_unreachable(string ip, string cidr, string prev_hop) throws Error @@ -426,10 +445,11 @@ Variant tuple_mac_ipcidr = new Variant("(mss)", w, v); routes_table[tuple_mac_ipcidr] = UNREACHABLE; } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is UNREACHABLE - */ + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is UNREACHABLE + */ protected abstract void _add_forwarding_route_unreachable(string ip, string cidr, string prev_hop) throws Error; void add_forwarding_route_drop(string ip, string cidr, string prev_hop) throws Error @@ -440,10 +460,12 @@ Variant tuple_mac_ipcidr = new Variant("(mss)", w, v); routes_table[tuple_mac_ipcidr] = DROP; } - /** Add a route (that was non existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is DROP - */ + + /** + * Add a route (that was non existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is DROP + */ protected abstract void _add_forwarding_route_drop(string ip, string cidr, string prev_hop) throws Error; void change_outgoing_route(string ip, string cidr, RouteSolutions route_solutions) @@ -455,11 +477,12 @@ _change_outgoing_route(ip, cidr, route_solutions, old_route_solutions); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Change a route (that was existent) towards ip/cidr - * for packets generated by this host. - * The gateways are route_solutions. - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets generated by this host. + * The gateways are route_solutions. + * The old gateways were old_route_solutions + */ protected abstract void _change_outgoing_route(string ip, string cidr, RouteSolutions route_solutions, RouteSolutions old_route_solutions); void change_forwarding_route_whateverwas(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error @@ -543,11 +566,12 @@ _change_forwarding_route(ip, cidr, prev_hop, route_solutions, old_route_solutions); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * The old gateways were old_route_solutions + */ protected abstract void _change_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions route_solutions, RouteSolutions old_route_solutions) throws Error; void change_forwarding_route_unreachable(string ip, string cidr, string prev_hop) throws Error @@ -559,11 +583,12 @@ _change_forwarding_route_unreachable(ip, cidr, prev_hop, old_route_solutions); routes_table[tuple_mac_ipcidr] = UNREACHABLE; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is UNREACHABLE - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is UNREACHABLE + * The old gateways were old_route_solutions + */ protected abstract void _change_forwarding_route_unreachable(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error; void change_forwarding_route_drop(string ip, string cidr, string prev_hop) throws Error @@ -575,11 +600,12 @@ _change_forwarding_route_drop(ip, cidr, prev_hop, old_route_solutions); routes_table[tuple_mac_ipcidr] = DROP; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact this route is DROP - * The old gateways were old_route_solutions - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact this route is DROP + * The old gateways were old_route_solutions + */ protected abstract void _change_forwarding_route_drop(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error; void change_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error @@ -590,11 +616,12 @@ _change_forwarding_route_was_unreachable(ip, cidr, prev_hop, route_solutions); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * Previously the route was UNREACHABLE - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * Previously the route was UNREACHABLE + */ protected abstract void _change_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error; void change_forwarding_route_drop_was_unreachable(string ip, string cidr, string prev_hop) throws Error @@ -605,11 +632,12 @@ _change_forwarding_route_drop_was_unreachable(ip, cidr, prev_hop); routes_table[tuple_mac_ipcidr] = DROP; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact now this route is DROP - * Previously the route was UNREACHABLE - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact now this route is DROP + * Previously the route was UNREACHABLE + */ protected abstract void _change_forwarding_route_drop_was_unreachable(string ip, string cidr, string prev_hop) throws Error; void change_forwarding_route_was_drop(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error @@ -620,11 +648,12 @@ _change_forwarding_route_was_drop(ip, cidr, prev_hop, route_solutions); routes_table[tuple_mac_ipcidr] = route_solutions; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The gateways are route_solutions. - * Previously the route was DROP - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The gateways are route_solutions. + * Previously the route was DROP + */ protected abstract void _change_forwarding_route_was_drop(string ip, string cidr, string prev_hop, RouteSolutions route_solutions) throws Error; void change_forwarding_route_unreachable_was_drop(string ip, string cidr, string prev_hop) throws Error @@ -635,11 +664,12 @@ _change_forwarding_route_unreachable_was_drop(ip, cidr, prev_hop); routes_table[tuple_mac_ipcidr] = UNREACHABLE; } - /** Change a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * In fact now this route is UNREACHABLE - * Previously the route was DROP - */ + /** + * Change a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * In fact now this route is UNREACHABLE + * Previously the route was DROP + */ protected abstract void _change_forwarding_route_unreachable_was_drop(string ip, string cidr, string prev_hop) throws Error; void remove_outgoing_route(string ip, string cidr) @@ -651,10 +681,11 @@ _remove_outgoing_route(ip, cidr, old_route_solutions); routes_table.unset(tuple_mac_ipcidr); } - /** Remove a route (that was existent) towards ip/cidr - * for packets generated by this host. - * The old gateways were old_route_solutions - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets generated by this host. + * The old gateways were old_route_solutions + */ protected abstract void _remove_outgoing_route(string ip, string cidr, RouteSolutions old_route_solutions); void remove_forwarding_route_whateverwas(string ip, string cidr, string prev_hop) throws Error @@ -690,10 +721,11 @@ _remove_forwarding_route(ip, cidr, prev_hop, old_route_solutions); routes_table.unset(tuple_mac_ipcidr); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * The old gateways were old_route_solutions - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * The old gateways were old_route_solutions + */ protected abstract void _remove_forwarding_route(string ip, string cidr, string prev_hop, RouteSolutions old_route_solutions) throws Error; void remove_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop) throws Error @@ -704,10 +736,11 @@ _remove_forwarding_route_was_unreachable(ip, cidr, prev_hop); routes_table.unset(tuple_mac_ipcidr); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * Previously the route was UNREACHABLE - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * Previously the route was UNREACHABLE + */ protected abstract void _remove_forwarding_route_was_unreachable(string ip, string cidr, string prev_hop) throws Error; void remove_forwarding_route_was_drop(string ip, string cidr, string prev_hop) throws Error @@ -718,10 +751,11 @@ _remove_forwarding_route_was_drop(ip, cidr, prev_hop); routes_table.unset(tuple_mac_ipcidr); } - /** Remove a route (that was existent) towards ip/cidr - * for packets coming from MAC prev_hop. - * Previously the route was DROP - */ + /** + * Remove a route (that was existent) towards ip/cidr + * for packets coming from MAC prev_hop. + * Previously the route was DROP + */ protected abstract void _remove_forwarding_route_was_drop(string ip, string cidr, string prev_hop) throws Error; public void forward_no_more_from(string prev_hop) throws Error @@ -742,9 +776,10 @@ } } } - /** Stop forwarding (in fact it means delete all rules for...) - * packets coming from MAC prev_hop. - */ + /** + * Stop forwarding (in fact it means delete all rules for...) + * packets coming from MAC prev_hop. + */ protected abstract void _forward_no_more_from(string prev_hop) throws Error; public void forward_no_more() throws Error @@ -765,8 +800,9 @@ } } } - /** Delete all specific rules for any prev_hop. - */ + /** + * Delete all specific rules for any prev_hop. + */ protected abstract void _forward_no_more() throws Error; // Neighbour management @@ -776,8 +812,9 @@ _add_neighbour(ip, dev, pref_src); neighbours_table[ip] = dev; } - /** Adds a new neighbour with corresponding properties. - */ + /** + * Adds a new neighbour with corresponding properties. + */ protected abstract void _add_neighbour(string ip, string dev, string pref_src); public void change_neighbour(string ip, string dev, string pref_src) @@ -786,8 +823,9 @@ _change_neighbour(ip, dev, pref_src, old_dev); neighbours_table[ip] = dev; } - /** Edits the neighbour with the corresponding properties. - */ + /** + * Edits the neighbour with the corresponding properties. + */ protected abstract void _change_neighbour(string ip, string dev, string pref_src, string old_dev); public void delete_neighbour(string ip) @@ -796,8 +834,9 @@ _delete_neighbour(ip, old_dev); neighbours_table.unset(ip); } - /** Removes the neighbour with the corresponding properties. - */ + /** + * Removes the neighbour with the corresponding properties. + */ protected abstract void _delete_neighbour(string ip, string old_dev); // IGS management @@ -842,8 +881,9 @@ public delegate RouteSetter CreateRouteSetterDelegate(); - /** A class to retrieve info/statistics about active connections on the host - */ + /** + * A class to retrieve info/statistics about active connections on the host + */ public abstract class Connections : Object { private static CreateConnectionsDelegate? registered_class_linux = null; @@ -866,8 +906,9 @@ return _instance; } - /** Are there active TCP connections on this address? - */ + /** + * Are there active TCP connections on this address? + */ public abstract bool active_tcp_connections(string ip); } === modified file 'rpc.vala' --- rpc.vala 2012-04-28 10:07:10 +0000 +++ rpc.vala 2012-07-01 03:28:27 +0000 @@ -135,21 +135,22 @@ return ret; } - /** This class (and the following classes and interfaces) is used to perform - * RPC call using the following form: - * - * var x = remote_instance.property1.property2.method0(p1, p2, p3); - * - * instead of: - * - * RemoteCall rc = new RemoteCall(); - * rc.method_name = "property1.property2.method0"; - * rc.params = new ISerializable[3]; - * rc.params[0] = p1; - * rc.params[1] = p2; - * rc.params[2] = p3; - * var x = (SerClass)remote_instance.rpc_call(rc); - */ + /** + * {{{ + * This class (and the following classes and interfaces) is used to perform + * RPC call using the following form: + * + * var x = remote_instance.property1.property2.method0(p1, p2, p3); + * instead of: + * RemoteCall rc = new RemoteCall(); + * rc.method_name = "property1.property2.method0"; + * rc.params = new ISerializable[3]; + * rc.params[0] = p1; + * rc.params[1] = p2; + * rc.params[2] = p3; + * var x = (SerClass)remote_instance.rpc_call(rc); + * }}} + */ public abstract class AddressManagerFakeRmt : Object, IAddressManagerRootDispatcher { private RemoteEtp _etp = null; @@ -728,8 +729,9 @@ } - /** This class is used to send a message (usually without waiting for - * a result) to two remote objects. + /** + * This class is used to send a message (usually without waiting for + * a result) to two remote objects. */ public class CoupleAddressManagerFakeRmt : AddressManagerFakeRmt { @@ -749,12 +751,14 @@ } } - /** This class is used on the node that receives a remote procedure call and + /** + * This class is used on the node that receives a remote procedure call and * wants to execute it. */ public abstract class RPCDispatcher : Object { - /** This method receives a message as a stream of bytes from a caller, + /** + * This method receives a message as a stream of bytes from a caller, * translates it to a RemoteCall, * executes the call, * returns the result as a stream of bytes that we can send to the caller. @@ -788,7 +792,8 @@ return ret; } - /** This method adds the feature that an exception is made serializable. + /** + * This method adds the feature that an exception is made serializable. */ public ISerializable dispatch(Object? caller, RemoteCall data) { @@ -904,11 +909,12 @@ } } - /** Override this method for each kind of "root" dispatcher. Eg address_manager, coord_peer, andna_peer... - * - * This method could be called *directly* for a dispatcher that does not need to transform - * an exception into a remotable. - */ + /** + * Override this method for each kind of "root" dispatcher. Eg address_manager, coord_peer, andna_peer... + * + * This method could be called *directly* for a dispatcher that does not need to transform + * an exception into a remotable. + */ public virtual ISerializable _dispatch(Object? caller, RemoteCall data) throws Error { throw new RPCError.FUNCTION_NOT_REMOTABLE("Function %s is not remotable.".printf(data.method_name)); @@ -923,9 +929,10 @@ this.root = root; } - /** This method could be called *directly* for a dispatcher that does not need to transform - * an exception into a remotable. - */ + /** + * This method could be called *directly* for a dispatcher that does not need to transform + * an exception into a remotable. + */ public override ISerializable _dispatch(Object? caller, RemoteCall data) throws Error { Logger.ultradebug(@"$(this.get_type().name()): dispatching $data"); === modified file 'rpc_clients.vala' --- rpc_clients.vala 2012-01-17 00:16:47 +0000 +++ rpc_clients.vala 2012-06-28 01:33:12 +0000 @@ -21,7 +21,8 @@ namespace Ntk.Core { - /** A UDPRequestClient to send a message to a particular NIP. + /** + * A UDPRequestClient to send a message to a particular NIP. * In turn, it is a FakeRmt object. */ public class NeighbourClient : UDPRequestClient @@ -62,7 +63,8 @@ } } - /** A UDPRequestClient to send a message to all nodes of a particular Network. + /** + * A UDPRequestClient to send a message to all nodes of a particular Network. * In turn, it is a FakeRmt object. */ public class BroadcastClient : UDPRequestClient @@ -101,7 +103,8 @@ } } - /** A FakeRmt object to send requests to a local dispatcher. Simulates a NeighbourClient. + /** + * A FakeRmt object to send requests to a local dispatcher. Simulates a NeighbourClient. */ public class PseudoNeighbourClient : AddressManagerFakeRmt { @@ -133,7 +136,8 @@ } } - /** A FakeRmt object to send requests to a local dispatcher. Simulates a BroadcastClient. + /** + * A FakeRmt object to send requests to a local dispatcher. Simulates a BroadcastClient. */ public class PseudoBroadcastClient : AddressManagerFakeRmt { === modified file 'serializer.vala' --- serializer.vala 2012-04-28 10:09:24 +0000 +++ serializer.vala 2012-06-28 01:13:05 +0000 @@ -24,7 +24,8 @@ GENERIC } - /** The interface ISerializable has to be implemented by any + /** + * The interface ISerializable has to be implemented by any * class whose instances we want to be able to serialize and * transmit over the net. * The class that we want to be serializeable needs to know how @@ -127,9 +128,12 @@ } } - /** Serializable classes for basic types **/ + /** + * Serializable classes for basic types + **/ - /** Return value for "void" + /** + * Return value for "void" */ public class SerializableNone : Object, ISerializable { @@ -144,7 +148,8 @@ } } - /** Serializable class for int + /** + * Serializable class for int */ public class SerializableInt : Object, ISerializable { @@ -170,7 +175,8 @@ } } - /** Serializable class for bool + /** + * Serializable class for bool */ public class SerializableBool : Object, ISerializable { @@ -196,7 +202,8 @@ } } - /** Serializable class for string + /** + * Serializable class for string */ public class SerializableString : Object, ISerializable { @@ -222,7 +229,8 @@ } } - /** Serializable class for uint8[] + /** + * Serializable class for uint8[] */ public class SerializableBuffer : Object, ISerializable { @@ -247,7 +255,8 @@ } } - /** Serializable class for List + /** + * Serializable class for List */ public class ListString : Object, ISerializable { @@ -299,22 +308,23 @@ } } - /** Serializable class for List + /** + * Serializable class for List * * This class is used for passing or returning a list of objects, all of the - * same type and that implement ISerializable. + * same type and that implement ISerializable. * With this class, the objects contained in the list are serialized when we - * call "serialize()" on the list, and are deserialized when we call deserialize() - * for the list. + * call "serialize()" on the list, and are deserialized when we call deserialize() + * for the list. * A different approach has to be used if we need to - * § serialize a list of serializable objects, obtaining a - * list of uchar[] - * § put the list of uchar[] in a serializable container - * § serialize the container - * § deserialize the container WITHOUT deserializing the objects + * | § serialize a list of serializable objects, obtaining a + * | list of uchar[] + * | § put the list of uchar[] in a serializable container + * | § serialize the container + * | § deserialize the container WITHOUT deserializing the objects * This situation is needed for remotable methods in optional peer to peer - * services; because we need to pass the arguments to hops that might not - * implement the service and might not have knowledge of the classes involved. + * | services; because we need to pass the arguments to hops that might not + * | implement the service and might not have knowledge of the classes involved. * For this see an example of SerializedList in the serializer_tester_1 module. * Such a class is RemoteCall, in module messages. */ === modified file 'tasklet.vala' --- tasklet.vala 2012-05-25 15:50:13 +0000 +++ tasklet.vala 2012-07-01 03:24:21 +0000 @@ -21,31 +21,34 @@ namespace Ntk.Lib { - /** A Tasklet instance represents a thread that has been spawned to execute a - * certain function. - * In order to spawn a thread to execute a method of an object proceed this way: - * * prepare a function, or a static method, with the signature void *(*)(void *) - * * prepare a struct which will contain: - * * the instance of the class which the method is invoked in, - * * the parameters (simple types or objects) that will be passed. - * * in the function do this: - * * cast the void* to a pointer to your struct - * * if you pass a ref-counted class, assign it to a local variable in order to increase the refcounter - * * if you pass a simple type, assign it to a local variable in order to copy its value - * * call Tasklet.schedule_back() in order to let the caller decide when to start the new thread - * * call the method with the object and parameters that you just copied in local variables - * * when you want to spawn, allocate in the stack a struct of the type - * * populate the struct with data - * * call Tasklet.spawn(function, &my_struct) - * The real function/method will not start immediately, but the struct can be safely freed right now. - * - * Features: - * * method schedule gives a chance to the scheduler to assign the cpu to other threads; - * * method schedule can select a particular tasklet to be scheduled; - * * method schedule_back schedules the previous tasklet; - * * method join waits for a thread to complete and can get a void* from it; - * * ... - */ + /** + * {{{ + * A Tasklet instance represents a thread that has been spawned to execute a + * certain function. + * In order to spawn a thread to execute a method of an object proceed this way: + * * prepare a function, or a static method, with the signature void *(*)(void *) + * * prepare a struct which will contain: + * * * the instance of the class which the method is invoked in, + * * * the parameters (simple types or objects) that will be passed. + * * in the function do this: + * * * cast the void* to a pointer to your struct + * * * if you pass a ref-counted class, assign it to a local variable in order to increase the refcounter + * * * if you pass a simple type, assign it to a local variable in order to copy its value + * * * call Tasklet.schedule_back() in order to let the caller decide when to start the new thread + * * * call the method with the object and parameters that you just copied in local variables + * * when you want to spawn, allocate in the stack a struct of the type + * * populate the struct with data + * * call Tasklet.spawn(function, &my_struct) + * The real function/method will not start immediately, but the struct can be safely freed right now. + * + * Features: + * * method schedule gives a chance to the scheduler to assign the cpu to other threads; + * * method schedule can select a particular tasklet to be scheduled; + * * method schedule_back schedules the previous tasklet; + * * method join waits for a thread to complete and can get a void* from it; + * * ... + * }}} + */ public class Tasklet : Object { public static void tasklet_leaves(string reason="") @@ -85,17 +88,19 @@ return false; } - /** Kills immediately the threading system. - * - * You can call it only from the main thread. - */ + /** + * Kills immediately the threading system. + * + * You can call it only from the main thread. + */ public static bool kill() { return Wrapped.LibPth.kill(); } - /** Exits the current thread. - */ + /** + * Exits the current thread. + */ public static void exit_current_thread(void *val) { assert(! Wrapped.LibPth.PthThread.is_main_thread()); @@ -103,11 +108,12 @@ Wrapped.LibPth.PthThread.exit(val); } - /** Waits for all the threads to complete and then - * kills the threading system and exits the application. - * - * You can call it only from the main thread. - */ + /** + * Waits for all the threads to complete and then + * kills the threading system and exits the application. + * + * You can call it only from the main thread. + */ public static void exit_app(int val) { assert(Wrapped.LibPth.PthThread.is_main_thread()); === modified file 'tasklet_blocking_sockets.vala' --- tasklet_blocking_sockets.vala 2012-05-25 14:31:08 +0000 +++ tasklet_blocking_sockets.vala 2012-06-28 01:16:08 +0000 @@ -16,9 +16,10 @@ * along with Netsukuku. If not, see . */ -/** This module allows the developer to use sockets API with a blocking-like style - * and makes sure that only the intended tasklet becomes blocked, not - * the whole application. +/** + * This module allows the developer to use sockets API with a blocking-like style + * and makes sure that only the intended tasklet becomes blocked, not + * the whole application. */ using Gee; @@ -26,11 +27,12 @@ namespace Ntk.Lib.TaskletUtils { - /** Emulate inet_ntop and pton. In python we have: - >>> socket.inet_ntop(socket.AF_INET,'1234') - '49.50.51.52' - >>> socket.inet_pton(socket.AF_INET,'49.50.51.52') - '1234' + /** + * Emulate inet_ntop and pton. In python we have: + * | >>> socket.inet_ntop(socket.AF_INET,'1234') + * | '49.50.51.52' + * | >>> socket.inet_pton(socket.AF_INET,'49.50.51.52') + * | '1234' * These emulation will work only with IPV4. * For now this is not a problem because IPV6 is currently disabled. */ @@ -74,8 +76,9 @@ return ret; } - /** When you have a socket connected to a server, or when you receive - * a connection, you get an obscure object that implements this API. + /** + * When you have a socket connected to a server, or when you receive + * a connection, you get an obscure object that implements this API. */ public interface IConnectedStreamSocket : Object { @@ -107,7 +110,8 @@ } public abstract unowned string _my_address_getter(); - /** Sends all the bytes. Returns when all the bytes have been reliably sent. + /** + * Sends all the bytes. Returns when all the bytes have been reliably sent. */ public void send(uchar[] data) throws Error { @@ -125,9 +129,10 @@ public abstract void close() throws Error; } - /** Use this class to implement a TCP connection oriented service. + /** + * Use this class to implement a TCP connection oriented service. * In particular, you can wait for a connection without blocking the - * rest of the application. + * rest of the application. */ public class ServerStreamSocket : Object { @@ -144,9 +149,10 @@ s.listen(); } - /** When the method returns, start a new tasklet and pass the - * returned object to handle the request. With this instance, - * instead, call accept again to wait for more clients. + /** + * When the method returns, start a new tasklet and pass the + * returned object to handle the request. With this instance, + * instead, call accept again to wait for more clients. */ public IConnectedStreamSocket accept() throws Error { @@ -167,9 +173,10 @@ } } - /** Use this class to make a connection to a TCP service. + /** + * Use this class to make a connection to a TCP service. * In particular, you can wait for the connect to complete without - * blocking the rest of the application. + * blocking the rest of the application. */ public class ClientStreamSocket : Object { @@ -182,8 +189,9 @@ s.bind(new InetSocketAddress(new InetAddress.from_string(my_addr), 0), false); } - /** When the method returns, use the returned object - * to carry on the communication. Discard this instance, instead. + /** + * When the method returns, use the returned object + * to carry on the communication. Discard this instance, instead. */ public IConnectedStreamSocket socket_connect(string addr, uint16 port) throws Error { @@ -260,12 +268,13 @@ } } - /** Use this class to implement a UDP datagram oriented service. + /** + * Use this class to implement a UDP datagram oriented service. * The call to recvfrom blocks only the current tasklet, not the whole - * application. + * application. * You can use this same object to send a response to the caller. * Or else handle the request on another tasklet and, when necessary, - * use an BroadcastClientDatagramSocket to send a reply. + * use an BroadcastClientDatagramSocket to send a reply. */ public class ServerDatagramSocket : Object { @@ -309,8 +318,9 @@ } } - /** Use this class to send a single UDP datagram in broadcast over - * a particular interface. + /** + * Use this class to send a single UDP datagram in broadcast over + * a particular interface. */ public class BroadcastClientDatagramSocket : Object { === modified file 'time_utils.vala' --- time_utils.vala 2012-04-11 21:25:18 +0000 +++ time_utils.vala 2012-06-28 01:11:00 +0000 @@ -28,7 +28,8 @@ Tasklet.nap(sec, usec); } - /** Class for "timeouts" or "timespans" + /** + * Class for "timeouts" or "timespans" */ public class Timer : Object { @@ -78,7 +79,8 @@ } } - /** Serializable class for "timeouts" or "timespans" + /** + * Serializable class for "timeouts" or "timespans" */ public class TimeCapsule : Ntk.Lib.Timer, ISerializable { === modified file 'topology.vala' --- topology.vala 2012-04-28 10:09:24 +0000 +++ topology.vala 2012-07-01 03:08:40 +0000 @@ -21,10 +21,11 @@ namespace Ntk.Core { - /** A Hierarchical topology Coordinates. - * That is, level and position. - * It is an immutable class. - */ + /** + * A Hierarchical topology Coordinates. + * That is, level and position. + * It is an immutable class. + */ public class HCoord : Object, ISerializable { private int _lvl; @@ -93,10 +94,11 @@ } } - /** A Netsukuku IP address that could be partial. - * That is, the positions at the various levels. - * It is an immutable class. - */ + /** + * A Netsukuku IP address that could be partial. + * That is, the positions at the various levels. + * It is an immutable class. + */ public class PartialNIP : Object, ISerializable { protected int[] _positions; @@ -190,8 +192,9 @@ return new PartialNIP(positions); } - /** This method is useful when this instance represents a g-node. - */ + /** + * This method is useful when this instance represents a g-node. + */ public int level_of_gnode() { for (int i = _positions.length; i > 0; i--) @@ -206,8 +209,9 @@ return gnode.is_equal(get_gnode_at_level(gnode.level_of_gnode())); } - /** When this instance represents a g-node, this method returns a valid random NIP inside it. - */ + /** + * When this instance represents a g-node, this method returns a valid random NIP inside it. + */ public NIP complete_nip(int gsize) { int levels = _positions.length; @@ -223,9 +227,10 @@ return new NIP(full_pos); } - /** When this instance represents a g-node, this method returns the lowest NIP inside it. - * This is useful, for instance, when we need a CIDR notation for a gnode, such as "10.123.0.0/16" - */ + /** + * When this instance represents a g-node, this method returns the lowest NIP inside it. + * This is useful, for instance, when we need a CIDR notation for a gnode, such as "10.123.0.0/16" + */ public NIP lowest_nip() { int levels = _positions.length; @@ -250,10 +255,11 @@ } } - /** A Netsukuku IP address. - * That is, the positions at the various levels. - * It is an immutable class. - */ + /** + * A Netsukuku IP address. + * That is, the positions at the various levels. + * It is an immutable class. + */ public class NIP : PartialNIP, ISerializable { public NIP(int[] positions) @@ -267,8 +273,9 @@ // We can use PartialNIP.equal_func and hash_func with NIP objects. - /** Returns the first level where nipA and nipB differs. The search start from the end of the nip. - */ + /** + * Returns the first level where nipA and nipB differs. The search start from the end of the nip. + */ public static int nip_cmp(int[] nipA, int[] nipB) { assert(nipA.length == nipB.length); === modified file 'tunnel.vala' --- tunnel.vala 2012-04-28 10:07:10 +0000 +++ tunnel.vala 2012-07-01 03:06:06 +0000 @@ -52,32 +52,35 @@ { } - /** Requests a tunnel. - * Usually, the other end (that we call the server) is executing in the meantime - * the method 'serve'. - * The implementor can use the callback functions cb_send(mesg) and cb_recv() to - * communicate with the other end during the phases of establishing the - * tunnel. - * When the method exits, if all goes well, there must exist a new NIC that - * represents the working tunnel. - * The return-value is the name of the new NIC. - */ + /** + * Requests a tunnel. + * Usually, the other end (that we call the server) is executing in the meantime + * the method 'serve'. + * The implementor can use the callback functions cb_send(mesg) and cb_recv() to + * communicate with the other end during the phases of establishing the + * tunnel. + * When the method exits, if all goes well, there must exist a new NIC that + * represents the working tunnel. + * The return-value is the name of the new NIC. + */ public abstract string request(CallbackSendDelegate cb_send, CallbackRecvDelegate cb_recv, string my_address, string dest_address) throws TunnelError, RPCError; - /** Serves a tunnel. - * Usually, the other end (that we call the client) is executing in the meantime - * the method 'request'. - * The implementor can use the callback functions cb_send(mesg) and cb_recv() to - * communicate with the other end during the phases of establishing the - * tunnel. - * When the method exits, if all goes well, there must exist a new NIC that - * represents the working tunnel. - * The return-value is the name of the new NIC. - */ + /** + * Serves a tunnel. + * Usually, the other end (that we call the client) is executing in the meantime + * the method 'request'. + * The implementor can use the callback functions cb_send(mesg) and cb_recv() to + * communicate with the other end during the phases of establishing the + * tunnel. + * When the method exits, if all goes well, there must exist a new NIC that + * represents the working tunnel. + * The return-value is the name of the new NIC. + */ public abstract string serve(CallbackSendDelegate cb_send, CallbackRecvDelegate cb_recv, string my_address, string dest_address) throws TunnelError, RPCError; - /** Closes a tunnel. - */ + /** + * Closes a tunnel. + */ public abstract void close(string nic_name, string my_address, string dest_address) throws TunnelError; } @@ -156,8 +159,9 @@ return null; } - /** Remotable method. Called to instruct a node to serve a tunnel. - */ + /** + * Remotable method. Called to instruct a node to serve a tunnel. + */ public int request_tunnel(Object? _rpc_caller, string protocol, int peer_handler_id) throws TunnelError { assert(_rpc_caller != null); @@ -175,8 +179,9 @@ return my_handler_id; } - /** Executed on a Tasklet to serve a tunnel. - */ + /** + *Executed on a Tasklet to serve a tunnel. + */ private void impl_initiate(string dest_addr, string my_addr, int peer_handler_id, int my_handler_id) throws Error { TCPClient peer_client = new TCPClient(dest_addr, null, my_addr, false); @@ -222,17 +227,19 @@ Tasklet.spawn((FunctionDelegate)helper_initiate, &arg); } - /** Remotable method. Called to pass a message during the handshake phase, - * following a particular protocol (e.g. tinc on linux). - */ + /** + * Remotable method. Called to pass a message during the handshake phase, + * following a particular protocol (e.g. tinc on linux). + */ public void handshake(ISerializable mesg, int handler_id) { if (handlers.has_key(handler_id)) handlers[handler_id].send(mesg); } - /** Remotable method. Called to instruct a node to close a tunnel. - */ + /** + * Remotable method. Called to instruct a node to close a tunnel. + */ public void close_tunnel(Object? _rpc_caller, string nic_name) { assert(_rpc_caller != null); @@ -268,8 +275,9 @@ } } - /** Helper client-side **/ - + /** + * Helper client-side + **/ public string call_request_tunnel(string dest_addr) throws TunnelError, RPCError { Logger.debug(@"TunnelManager: $(my_addr): request a tunnel to $(dest_addr)");