Skip to content

Commit

Permalink
2009-03-30 Aaron Bockover <[email protected]>
Browse files Browse the repository at this point in the history
    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/Service.cs:
    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs:
    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/RegisterService.cs:
    * src/Mono.Zeroconf/Mono.Zeroconf/IRegisterService.cs:
    * src/Mono.Zeroconf/Mono.Zeroconf/RegisterService.cs:
    * src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/RegisterService.cs:
    Use ushort internally for the port value, add new UPort property on 
    IRegisterService so an unchecked cast is not necessary for port values that
    overflow Int16 (http://mono-project.com/Mono.Zeroconf#Known_Workarounds)


svn path=/trunk/Mono.Zeroconf/; revision=130586
  • Loading branch information
abock committed Mar 30, 2009
1 parent dd08db6 commit 81b39b8
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
14 changes: 13 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
2009-03-30 Aaron Bockover <[email protected]>
2009-03-30 Aaron Bockover <[email protected]>

* src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/Service.cs:
* src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs:
* src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/RegisterService.cs:
* src/Mono.Zeroconf/Mono.Zeroconf/IRegisterService.cs:
* src/Mono.Zeroconf/Mono.Zeroconf/RegisterService.cs:
* src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/RegisterService.cs:
Use ushort internally for the port value, add new UPort property on
IRegisterService so an unchecked cast is not necessary for port values that
overflow Int16 (http://mono-project.com/Mono.Zeroconf#Known_Workarounds)

2009-03-30 Aaron Bockover <[email protected]>

* src/Mono.Zeroconf.Providers.AvahiDBus/Mono.Zeroconf.Providers.AvahiDBus/Service.cs:
Set the interface to unspecified by default, fixing a bug reported on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Mono.Zeroconf.Providers.AvahiDBus
{
public class RegisterService : Service, IRegisterService
{
private short port;
private ushort port;
private IAvahiEntryGroup entry_group;

public event RegisterServiceEventHandler Response;
Expand All @@ -58,7 +58,7 @@ public void Register ()

entry_group.AddService (AvahiInterface, AvahiProtocol, PublishFlags.None,
Name ?? String.Empty, RegType ?? String.Empty, ReplyDomain ?? String.Empty,
String.Empty, (ushort)port, txt_record);
String.Empty, port, txt_record);

entry_group.Commit ();
}
Expand Down Expand Up @@ -142,6 +142,11 @@ public void Dispose ()
}

public short Port {
get { return (short)UPort; }
set { UPort = (ushort)value; }
}

public ushort UPort {
get { return port; }
set { port = value; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void OnResolveReply(ServiceRef sdRef, ServiceFlags flags, uint interface

InterfaceIndex = interfaceIndex;
FullName = fullname;
this.port = (short)port;
this.port = port;
TxtRecord = new TxtRecord(txtLen, txtRecord);

sdRef.Deallocate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void ProcessRegister()

ServiceError error = Native.DNSServiceRegister(out sd_ref,
auto_rename ? ServiceFlags.None : ServiceFlags.NoAutoRename, InterfaceIndex,
Name, RegType, ReplyDomain, HostTarget, (ushort)port, txt_rec_length, txt_rec,
Name, RegType, ReplyDomain, HostTarget, port, txt_rec_length, txt_rec,
register_reply_handler, IntPtr.Zero);

if(error != ServiceError.NoError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class Service : IService
protected ITxtRecord txt_record;
protected string fullname;
protected string hosttarget;
protected short port;
protected ushort port;
protected IPHostEntry hostentry;

public Service()
Expand Down Expand Up @@ -126,10 +126,15 @@ public IPHostEntry HostEntry {
public uint NetworkInterface {
get { return interface_index; }
}

public short Port {
get { return IPAddress.NetworkToHostOrder(port); }
set { port = IPAddress.HostToNetworkOrder(value); }
get { return (short)UPort; }
set { UPort = (ushort)value; }
}

public ushort UPort {
get { return (ushort)IPAddress.NetworkToHostOrder((int)port); }
set { port = (ushort)IPAddress.HostToNetworkOrder((int)value); }
}
}
}
1 change: 1 addition & 0 deletions src/Mono.Zeroconf/Mono.Zeroconf/IRegisterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ public interface IRegisterService : IService, IDisposable
new string ReplyDomain { get; set; }

short Port { get; set; }
ushort UPort { get; set; }
}
}
5 changes: 5 additions & 0 deletions src/Mono.Zeroconf/Mono.Zeroconf/RegisterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ public short Port {
get { return register_service.Port; }
set { register_service.Port = value; }
}

public ushort UPort {
get { return register_service.UPort; }
set { register_service.UPort = value; }
}
}
}

0 comments on commit 81b39b8

Please sign in to comment.