本文整理汇总了C#中Brunet.Address类的典型用法代码示例。如果您正苦于以下问题:C# Address类的具体用法?C# Address怎么用?C# Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Address类属于Brunet命名空间,在下文中一共展示了Address类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TargetSelectorCallback
protected void TargetSelectorCallback(Address start, SortedList score_table, Address current) {
Assert.IsTrue(score_table.Count > 0);
if (current == null) {
Address min_target = (Address) score_table.GetByIndex(0);
Assert.AreEqual(_addr_list[_idx++], min_target);
}
}
开发者ID:xujyan,项目名称:brunet,代码行数:7,代码来源:TargetSelector.cs
示例2: RequestState
public RequestState(Address start, int range, TargetSelectorDelegate cb, Address current) {
Start = start;
Range = range;
Callback = cb;
Current = current;
ResultTable = new Hashtable();
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:7,代码来源:VivaldiTargetSelector.cs
示例3: AHHeader
public AHHeader(short hops, short ttl, Address source, Address dest, ushort options) {
//Make the header part:
byte[] header = new byte[ LENGTH ];
int offset = 0;
//Write hops:
NumberSerializer.WriteShort(hops, header, offset);
Hops = hops;
offset += 2;
NumberSerializer.WriteShort(ttl, header, offset);
Ttl = ttl;
offset += 2;
_src = source;
offset += source.CopyTo(header, offset);
_dest = dest;
offset += dest.CopyTo(header, offset);
Opts = options;
NumberSerializer.WriteShort((short)options, header, offset);
offset += 2;
_data = MemBlock.Reference(header, 0, offset);
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:25,代码来源:AHSender.cs
示例4: SendMessage
/// <summary>This methods send some ICopyable data to the remote address.
/// </summary>
/// <param name="remote_addr">Remote Nodes are referenced by their P2P
/// Address, typically of type AHAddress.</param>
/// <param name="data">This is an ICopyable object which contains the data
/// to send.</param>
public void SendMessage(Address remote_addr, ICopyable data) {
// This instantiates a multi-use method to sending to the remote node,
// though we will only use it once. It is VERY similar to UDP.
AHExactSender sender = new AHExactSender(_app_node.Node, remote_addr);
// This is the process of actually sending the data.
sender.Send(new CopyList(HW, data));
}
开发者ID:pstjuste,项目名称:brunet,代码行数:13,代码来源:HelloWorldNodeDataHandler.cs
示例5: AddressInSubjectAltName
///<summary>Verify the edge by comparing the address in the certificate to
///the one provided in the overlay.</summary>
public static bool AddressInSubjectAltName(Node node, Edge e, Address addr) {
SecureEdge se = e as SecureEdge;
if(se == null) {
throw new Exception("Invalid edge type!");
}
return se.SA.VerifyCertificateBySubjectAltName(addr.ToString());
}
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:10,代码来源:EdgeVerification.cs
示例6: ComputeCandidates
/**
* Selects an optimal target given a start address, the range starting at that address, and the current address (could be null).
* If the current address is not null, it is returned as optimal, or else start address is returned.
* @param start start address of the range.
* @param range number of candidates
* @param callback callback function into the caller
* @param current currently selected optimal
*/
public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate callback, Address current) {
SortedList sorted = new SortedList();
if (current != null) {
sorted[1.0] = (Address) current;
} else {
sorted[1.0] = start;
}
callback(start, sorted, current);
}
开发者ID:xujyan,项目名称:brunet,代码行数:17,代码来源:TargetSelector.cs
示例7: SimulatorCache
/// Simulator != thread-safe!
protected static Address SimulatorCache(Address a) {
int idx = NumberSerializer.ReadInt(a.ToMemBlock(), 0);
Address tmp = _cache.GetValue(idx);
if(a.Equals(tmp)) {
return tmp;
}
_cache.Replace(idx, a);
return a;
}
开发者ID:pstjuste,项目名称:brunet,代码行数:10,代码来源:AddressParser.cs
示例8: Connection
/**
* Prefered constructor for a Connection
*/
public Connection(Edge e, Address a,
string connectiontype,
StatusMessage sm, LinkMessage peerlm)
{
_e = e;
_a = a;
_ct = String.Intern(connectiontype);
_stat = sm;
_lm = peerlm;
_creation_time = DateTime.UtcNow;
MainType = StringToMainType(_ct);
}
开发者ID:xujyan,项目名称:brunet,代码行数:15,代码来源:Connection.cs
示例9: Connection
/**
* Prefered constructor for a Connection
*/
public Connection(Edge e, Address a,
string connectiontype,
StatusMessage sm, LinkMessage peerlm)
{
_e = e;
_a = a;
_ct = String.Intern(connectiontype);
_stat = sm;
_lm = peerlm;
_creation_time = DateTime.UtcNow;
MainType = StringToMainType(_ct);
_as_dict = new WriteOnce<ListDictionary>();
_sub_type = new WriteOnce<string>();
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:17,代码来源:Connection.cs
示例10: AHHeader
public AHHeader(short hops, short ttl, Address source, Address dest, ushort options) {
//Make the header part:
byte[] header = new byte[ AHPacket.HeaderLength ];
int offset = 0;
//Write hops:
NumberSerializer.WriteShort(hops, header, offset);
offset += 2;
NumberSerializer.WriteShort(ttl, header, offset);
offset += 2;
offset += source.CopyTo(header, offset);
offset += dest.CopyTo(header, offset);
NumberSerializer.WriteShort((short)options, header, offset);
offset += 2;
_data = MemBlock.Reference(header, 0, offset);
}
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:15,代码来源:AHSender.cs
示例11: CreateInstance
/**
* Factory method to reduce memory allocations by caching
* commonly used NodeInfo objects
*/
public static NodeInfo CreateInstance(Address a) {
//Read some of the least significant bytes out,
//AHAddress all have last bit 0, so we skip the last byte which
//will have less entropy
MemBlock mb = a.ToMemBlock();
ushort idx = (ushort)NumberSerializer.ReadShort(mb, Address.MemSize - 3);
NodeInfo ni = _mb_cache[idx];
if( ni != null ) {
if (a.Equals(ni._address)) {
return ni;
}
}
ni = new NodeInfo(a);
_mb_cache[idx] = ni;
return ni;
}
开发者ID:xujyan,项目名称:brunet,代码行数:20,代码来源:NodeInfo.cs
示例12: GetString
private static string GetString(Address target, IEnumerable forwarders) {
var sb = new System.Text.StringBuilder();
sb.Append("brunet.tunnel://");
sb.Append(target.ToString().Substring(12));
sb.Append("/");
foreach(object forwarder in forwarders) {
Address addr = forwarder as Address;
if(addr == null) {
addr = (forwarder as Brunet.Connections.Connection).Address;
}
sb.Append(addr.ToString().Substring(12,8));
sb.Append("+");
}
if(sb[sb.Length - 1] == '+') {
sb.Remove(sb.Length - 1, 1);
}
return sb.ToString();
}
开发者ID:hseom,项目名称:hseom_brunet,代码行数:18,代码来源:TunnelTransportAddress.cs
示例13: TunnelTransportAddress
public TunnelTransportAddress(string s) : base(s) {
/** String representing the tunnel TA is as follows: brunet.tunnel://A/X1+X2+X3
* A: target address
* X1, X2, X3: forwarders, each X1, X2 and X3 is actually a slice of the initial few bytes of the address.
*/
int k = s.IndexOf(":") + 3;
int k1 = s.IndexOf("/", k);
byte []addr_t = Base32.Decode(s.Substring(k, k1 - k));
_target = AddressParser.Parse( MemBlock.Reference(addr_t) );
k = k1 + 1;
_forwarders = new List<MemBlock>();
while (k < s.Length) {
byte [] addr_prefix = Base32.Decode(s.Substring(k, 8));
_forwarders.Add(MemBlock.Reference(addr_prefix));
//jump over the 8 characters and the + sign
k = k + 9;
}
_forwarders.Sort();
}
开发者ID:hseom,项目名称:hseom_brunet,代码行数:19,代码来源:TunnelTransportAddress.cs
示例14: PacketForwarder
public PacketForwarder(Node local)
{
_n = local;
_local = _n.Address;
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:5,代码来源:PacketForwarder.cs
示例15: ComputeCandidates
/**
* Compute candidate scores for a shortcut connection.
* @param start address computed by the SCO.
* @param range nunber of candidate nodes.
* @param cb callback function when candidate scores are available.
* @param current current selection of the optimal in the provided range.
*/
public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate cb, Address current) {
Channel q = null;
RequestState rs = null;
lock(_sync) {
#if VTS_DEBUG
Console.Error.WriteLine("VTS local: {0}, start: {1}, range: {2}, count: {3}", _node.Address, start, range, _num_requests);
#endif
if (_num_requests == MAX_REQUESTS) {
return; //do nothing and return;
}
_num_requests++;
q = new Channel();
rs = new RequestState(start, range, cb, current);
_channel_to_state[q] = rs;
}
//create a new request state
ISender s = new ForwardingSender(_node,
start,
AHHeader.Options.Greedy,
new DirectionalAddress(DirectionalAddress.Direction.Left),
(short) range,
AHHeader.Options.Path
);
q.EnqueueEvent += new EventHandler(EnqueueHandler);
q.CloseEvent += new EventHandler(CloseHandler);
RpcManager rpc = _node.Rpc;
rpc.Invoke(s, q, "ncserver.EchoVivaldiState", new object[]{});
}
开发者ID:hseom,项目名称:brunet,代码行数:37,代码来源:VivaldiTargetSelector.cs
示例16: AllowLockTransfer
/**
* Note that a LinkProtocolState only gets a lock *AFTER* it has
* received a LinkMessageReply. Prior to that, the Linker that
* created it holds the lock (if the _linker.Target is not null).
*
* So, given that we are being asked to transfer a lock, we must
* have already gotten our LinkMessageReply set, or we wouldn't
* hold the lock in the first place.
*
* So, we only transfer locks to other Linkers when we are finished
* since us holding a lock means we have already head some
* communication from the other side.
*
* Since the CT.Lock and CT.Unlock methods can't be called when this
* is being called, we know that _target_lock won't change during
* this method.
*/
public bool AllowLockTransfer(Address a, string contype, ILinkLocker l)
{
bool hold_lock = (a.Equals( _target_lock ) && contype == _contype);
if( false == hold_lock ) {
//This is a bug.
throw new Exception(String.Format("We don't hold the lock: {0}", a));
}
if( (l is Linker) && IsFinished ) {
return true;
}
return false;
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:29,代码来源:LinkProtocolState.cs
示例17: LinkProtocolState
public LinkProtocolState(Linker l, TransportAddress ta, Edge e) {
_linker = l;
_node = l.LocalNode;
_contype = l.ConType;
_target_lock = null;
_lm_reply = new WriteOnce<LinkMessage>();
_x = new WriteOnce<Exception>();
_con = new WriteOnce<Connection>();
_ta = ta;
_is_finished = 0;
//Setup the edge:
_e = e;
_result = Result.None;
}
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:14,代码来源:LinkProtocolState.cs
示例18: node
/**
<summary>This is called whenever there is a disconnect or a connect, the
idea is to determine if there is a new left or right node, if there is and
here is a pre-existing transfer, we must interupt it, and start a new
transfer.</summary>
<remarks>The possible scenarios where this would be active:
- no change on left
- new left node with no previous node (from disc or new node)
- left disconnect and new left ready
- left disconnect and no one ready
- no change on right
- new right node with no previous node (from disc or new node)
- right disconnect and new right ready
- right disconnect and no one ready
</remarks>
<param name="o">Unimportant</param>
<param name="eargs">Contains the ConnectionEventArgs, which lets us know
if this was a Structured Connection change and if it is, we should check
the state of the system to see if we have a new left or right neighbor.
</param>
*/
protected void ConnectionHandler(object o, EventArgs eargs) {
if(!_online) {
return;
}
ConnectionEventArgs cargs = eargs as ConnectionEventArgs;
Connection old_con = cargs.Connection;
//first make sure that it is a new StructuredConnection
if (old_con.MainType != ConnectionType.Structured) {
return;
}
lock(_transfer_sync) {
if(!_online) {
return;
}
ConnectionTable tab = _node.ConnectionTable;
Connection lc = null, rc = null;
try {
lc = tab.GetLeftStructuredNeighborOf((AHAddress) _node.Address);
}
catch(Exception) {}
try {
rc = tab.GetRightStructuredNeighborOf((AHAddress) _node.Address);
}
catch(Exception) {}
if(lc != null) {
if(lc.Address != _left_addr) {
if(_left_transfer_state != null) {
_left_transfer_state.Interrupt();
_left_transfer_state = null;
}
_left_addr = lc.Address;
if(Count > 0) {
_left_transfer_state = new TransferState(lc, this);
}
}
}
else if(_left_addr != null) {
if(_left_transfer_state != null) {
_left_transfer_state.Interrupt();
_left_transfer_state = null;
}
_left_addr = null;
}
if(rc != null) {
if(rc.Address != _right_addr) {
if(_right_transfer_state != null) {
_right_transfer_state.Interrupt();
_right_transfer_state = null;
}
_right_addr = rc.Address;
if(Count > 0) {
_right_transfer_state = new TransferState(rc, this);
}
}
}
else if(_right_addr != null) {
if(_right_transfer_state != null) {
_right_transfer_state.Interrupt();
_right_transfer_state = null;
}
_right_addr = null;
}
}
}
开发者ID:johnynek,项目名称:brunet,代码行数:89,代码来源:TableServer.cs
示例19: Check
/// <summary>Is the right person sending me this packet?</summary>
/// <param name="ip">The IP source.</param>
/// <param name="addr">The Brunet.Address source.</summary>
public bool Check(MemBlock ip, Address addr)
{
// Check current results
Address stored_addr = null;
lock(_sync) {
_results.TryGetValue(ip, out stored_addr);
}
if(addr.Equals(stored_addr)) {
// Match!
return true;
} else if(stored_addr == null) {
// No entry, check previous contents
lock(_sync) {
_last_results.TryGetValue(ip, out stored_addr);
}
if(Miss(ip)) {
IncrementMisses(ip);
}
return addr.Equals(stored_addr);
} else {
// Bad mapping
Miss(ip);
throw new AddressResolutionException(String.Format(
"IP:Address mismatch, expected: {0}, got: {1}",
addr, stored_addr), AddressResolutionException.Issues.Mismatch);
}
}
开发者ID:reith2004,项目名称:ipop,代码行数:31,代码来源:DhtAddressResolver.cs
示例20: GetCurrentMethod
/*private static readonly log4net.ILog _log =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.
GetCurrentMethod().DeclaringType);*/
public DirectionalRouter(Address a)
{
_local = a;
}
开发者ID:xujyan,项目名称:brunet,代码行数:8,代码来源:DirectionalRouter.cs
注:本文中的Brunet.Address类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论