示例#1
0
 protected Service(string name, string replyDomain, string regtype)
 {
     Name             = name;
     ReplyDomain      = replyDomain;
     RegType          = regtype;
     address_protocol = AddressProtocol.IPv4;
 }
 protected Service(string name, string replyDomain, string regtype)
 {
     Name = name;
     ReplyDomain = replyDomain;
     RegType = regtype;
     address_protocol = AddressProtocol.IPv4;
 }
示例#3
0
 public void Configure(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     this.interface_index = interfaceIndex;
     this.address_protocol = addressProtocol;
     this.regtype = regtype;
     this.domain = domain;
     
     if(regtype == null) {
         throw new ArgumentNullException("regtype");
     }
 }
示例#4
0
        public void Configure(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
        {
            this.interface_index  = interfaceIndex;
            this.address_protocol = addressProtocol;
            this.regtype          = regtype;
            this.domain           = domain;

            if (regtype == null)
            {
                throw new ArgumentNullException("regtype");
            }
        }
示例#5
0
 public static Protocol FromMzcProtocol(AddressProtocol addressProtocol)
 {
     switch (addressProtocol) {
         case AddressProtocol.IPv4:
             return Protocol.IPv4;
         case AddressProtocol.IPv6:
             return Protocol.IPv6;
         case AddressProtocol.Any:
         default:
             return Protocol.Unspecified;
     }
 }
示例#6
0
        public void Configure(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
        {
            this.interface_index  = interfaceIndex;
            this.address_protocol = addressProtocol;
            this.regtype          = regtype;
            this.domain           = domain;

            if (regtype == null)
            {
                Log.To.Discovery.E(TAG, "regtype cannot be null in Configure, throwing...");
                throw new ArgumentNullException("regtype");
            }
        }
示例#7
0
        public static Protocol FromMzcProtocol(AddressProtocol addressProtocol)
        {
            switch (addressProtocol)
            {
            case AddressProtocol.IPv4:
                return(Protocol.IPv4);

            case AddressProtocol.IPv6:
                return(Protocol.IPv6);

            case AddressProtocol.Any:
            default:
                return(Protocol.Unspecified);
            }
        }
示例#8
0
        public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
        {
            lock (this) {
                Dispose();

                ObjectPath object_path = DBusManager.Server.ServiceBrowserNew(
                    AvahiUtils.FromMzcInterface(interfaceIndex),
                    AvahiUtils.FromMzcProtocol(addressProtocol),
                    regtype ?? String.Empty, domain ?? String.Empty,
                    LookupFlags.None);

                service_browser = DBusManager.GetObject <IAvahiServiceBrowser> (object_path);
            }

            service_browser.ItemNew    += OnItemNew;
            service_browser.ItemRemove += OnItemRemove;
        }
示例#9
0
        public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
        {
            DBusManager.Bus.TrapSignals ();

            lock (this) {
                Dispose ();

                ObjectPath object_path = DBusManager.Server.ServiceBrowserNew (
                    AvahiUtils.FromMzcInterface (interfaceIndex),
                    AvahiUtils.FromMzcProtocol (addressProtocol),
                    regtype ?? String.Empty, domain ?? String.Empty,
                    LookupFlags.None);

                service_browser = DBusManager.GetObject<IAvahiServiceBrowser> (object_path);
            }

            service_browser.ItemNew += OnItemNew;
            service_browser.ItemRemove += OnItemRemove;

            DBusManager.Bus.UntrapSignals ();
        }
示例#10
0
 public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     browser.Browse (interfaceIndex, addressProtocol, regtype, domain ?? "local");
 }
 public void Browse(AddressProtocol addressProtocol, string regtype, string domain)
 {
     Browse(0, addressProtocol, regtype, domain);
 }
 public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     browser.Browse(interfaceIndex, addressProtocol, regtype, domain ?? "local");
 }
 public void Configure(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     this.interface_index = interfaceIndex;
     this.address_protocol = addressProtocol;
     this.regtype = regtype;
     this.domain = domain;
     
     if(regtype == null) {
         Log.To.Discovery.E(TAG, "regtype cannot be null in Configure, throwing...");
         throw new ArgumentNullException("regtype");
     }
 }
示例#14
0
    public static int Main(string [] args)
    {
        string    type      = "_workstation._tcp";
        bool      show_help = false;
        ArrayList services  = new ArrayList();

        services.Add("_http._tcp 80 mysimpleweb");


        for (int i = 0; i < args.Length; i++)
        {
            if (args[i][0] != '-')
            {
                continue;
            }

            switch (args[i])
            {
            case "-t":
            case "--type":
                type = args[++i];
                break;

            case "-r":
            case "--resolve":
                resolve_shares = true;
                break;

            case "-p":
            case "--publish":
                services.Add(args[++i]);
                break;

            case "-i":
            case "--interface":
                if (!UInt32.TryParse(args[++i], out @interface))
                {
                    Console.Error.WriteLine("Invalid interface index, '{0}'", args[i]);
                    show_help = true;
                }
                break;

            case "-a":
            case "--aprotocol":
                string proto = args[++i].ToLower().Trim();
                switch (proto)
                {
                case "ipv4":
                case "4": address_protocol = AddressProtocol.IPv4; break;

                case "ipv6":
                case "6": address_protocol = AddressProtocol.IPv6; break;

                case "any":
                case "all": address_protocol = AddressProtocol.Any; break;

                default:
                    Console.Error.WriteLine("Invalid IP Address Protocol, '{0}'", args[i]);
                    show_help = true;
                    break;
                }
                break;

            case "-d":
            case "--domain":
                domain = args[++i];
                break;

            case "-h":
            case "--help":
                show_help = true;
                break;

            case "-v":
            case "--verbose":
                verbose = true;
                break;
            }
        }

        if (show_help)
        {
            Console.WriteLine("Usage: {0} [-t type] [--resolve] [--publish \"description\"]", app_name);
            Console.WriteLine();
            Console.WriteLine("    -h|--help       shows this help");
            Console.WriteLine("    -v|--verbose    print verbose details of what's happening");
            Console.WriteLine("    -t|--type       uses 'type' as the service type");
            Console.WriteLine("                    (default is '_workstation._tcp')");
            Console.WriteLine("    -r|--resolve    resolve found services to hosts");
            Console.WriteLine("    -d|--domain     which domain to broadcast/listen on");
            Console.WriteLine("    -i|--interface  which network interface index to listen");
            Console.WriteLine("                    on (default is '0', meaning 'all')");
            Console.WriteLine("    -a|--aprotocol  which address protocol to use (Any, IPv4, IPv6)");
            Console.WriteLine("    -p|--publish    publish a service of 'description'");
            Console.WriteLine();
            Console.WriteLine("The -d, -i and -a options are optional. By default {0} will listen", app_name);
            Console.WriteLine("on all network interfaces ('0') on the 'local' domain, and will resolve ");
            Console.WriteLine("all address types, IPv4 and IPv6, as available.");
            Console.WriteLine();
            Console.WriteLine("The service description for publishing has the following syntax.");
            Console.WriteLine("The TXT record is optional.\n");
            Console.WriteLine("    <type> <port> <name> TXT [ <key>='<value>', ... ]\n");
            Console.WriteLine("For example:\n");
            Console.WriteLine("    -p \"_http._tcp 80 Simple Web Server\"");
            Console.WriteLine("    -p \"_daap._tcp 3689 Aaron's Music TXT [ Password='******', \\");
            Console.WriteLine("        Machine Name='Aaron\\'s Box', txtvers='1' ]\"");
            Console.WriteLine();
            return(1);
        }

        if (services.Count > 0)
        {
            foreach (string service_description in services)
            {
                RegisterService(service_description);
            }
        }
        else
        {
            if (verbose)
            {
                Console.WriteLine("Creating a ServiceBrowser with the following settings:");
                Console.WriteLine("  Interface         = {0}", @interface == 0 ? "0 (All)" : @interface.ToString());
                Console.WriteLine("  Address Protocol  = {0}", address_protocol);
                Console.WriteLine("  Domain            = {0}", domain);
                Console.WriteLine("  Registration Type = {0}", type);
                Console.WriteLine("  Resolve Shares    = {0}", resolve_shares);
                Console.WriteLine();
            }

            Console.WriteLine("Hit ^C when you're bored waiting for responses.");
            Console.WriteLine();

            // Listen for events of some service type
            ServiceBrowser browser = new ServiceBrowser();
            browser.ServiceAdded   += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;
            browser.Browse(@interface, address_protocol, type, domain);
        }

        while (true)
        {
            System.Threading.Thread.Sleep(1000);
        }
    }
示例#15
0
    public static int Main(string [] args)
    {
        string type = "_workstation._tcp";
        bool show_help = false;
        ArrayList services = new ArrayList();
        services.Add("_http._tcp 80 mysimpleweb");


        for (int i = 0; i < args.Length; i++) {
            if(args[i][0] != '-') {
                continue;
            }
            
            switch(args[i]) {
                case "-t":
                case "--type":
                    type = args[++i];
                    break;
                case "-r":
                case "--resolve":
                    resolve_shares = true;
                    break;
                case "-p":
                case "--publish":
                    services.Add(args[++i]);
                    break;
                case "-i":
                case "--interface":
                    if (!UInt32.TryParse (args[++i], out @interface)) {
                        Console.Error.WriteLine ("Invalid interface index, '{0}'", args[i]);
                        show_help = true;
                    }
                    break;
                case "-a":
                case "--aprotocol":
                    string proto = args[++i].ToLower ().Trim ();
                    switch (proto) {
                        case "ipv4": case "4": address_protocol = AddressProtocol.IPv4; break;
                        case "ipv6": case "6": address_protocol = AddressProtocol.IPv6; break;
                        case "any": case "all": address_protocol = AddressProtocol.Any; break;
                        default:
                            Console.Error.WriteLine ("Invalid IP Address Protocol, '{0}'", args[i]);
                            show_help = true;
                            break;
                    }
                    break;
                case "-d":
                case "--domain":
                    domain = args[++i];
                    break;
                case "-h":
                case "--help":
                    show_help = true;
                    break;
                case "-v":
                case "--verbose":
                    verbose = true;
                    break;
            }
        }
        
        if(show_help) {
            Console.WriteLine("Usage: {0} [-t type] [--resolve] [--publish \"description\"]", app_name);
            Console.WriteLine();
            Console.WriteLine("    -h|--help       shows this help");
            Console.WriteLine("    -v|--verbose    print verbose details of what's happening");
            Console.WriteLine("    -t|--type       uses 'type' as the service type");
            Console.WriteLine("                    (default is '_workstation._tcp')");
            Console.WriteLine("    -r|--resolve    resolve found services to hosts");
            Console.WriteLine("    -d|--domain     which domain to broadcast/listen on");
            Console.WriteLine("    -i|--interface  which network interface index to listen");
            Console.WriteLine("                    on (default is '0', meaning 'all')");
            Console.WriteLine("    -a|--aprotocol  which address protocol to use (Any, IPv4, IPv6)");
            Console.WriteLine("    -p|--publish    publish a service of 'description'");
            Console.WriteLine();
            Console.WriteLine("The -d, -i and -a options are optional. By default {0} will listen", app_name);
            Console.WriteLine("on all network interfaces ('0') on the 'local' domain, and will resolve ");
            Console.WriteLine("all address types, IPv4 and IPv6, as available.");
            Console.WriteLine();
            Console.WriteLine("The service description for publishing has the following syntax.");
            Console.WriteLine("The TXT record is optional.\n");
            Console.WriteLine("    <type> <port> <name> TXT [ <key>='<value>', ... ]\n");
            Console.WriteLine("For example:\n");
            Console.WriteLine("    -p \"_http._tcp 80 Simple Web Server\"");
            Console.WriteLine("    -p \"_daap._tcp 3689 Aaron's Music TXT [ Password='******', \\");
            Console.WriteLine("        Machine Name='Aaron\\'s Box', txtvers='1' ]\"");
            Console.WriteLine();
            return 1;
        }
        
        if(services.Count > 0) {
            foreach(string service_description in services) {
                RegisterService(service_description);
            }
        } else {
            if (verbose) {
                Console.WriteLine ("Creating a ServiceBrowser with the following settings:");
                Console.WriteLine ("  Interface         = {0}", @interface == 0 ? "0 (All)" : @interface.ToString ());
                Console.WriteLine ("  Address Protocol  = {0}", address_protocol);
                Console.WriteLine ("  Domain            = {0}", domain);
                Console.WriteLine ("  Registration Type = {0}", type);
                Console.WriteLine ("  Resolve Shares    = {0}", resolve_shares);
                Console.WriteLine ();
            }
        
            Console.WriteLine("Hit ^C when you're bored waiting for responses.");
            Console.WriteLine();
            
            // Listen for events of some service type
            ServiceBrowser browser = new ServiceBrowser();
            browser.ServiceAdded += OnServiceAdded;
            browser.ServiceRemoved += OnServiceRemoved;
            browser.Browse (@interface, address_protocol, type, domain);
        }
       
        while(true) {
            System.Threading.Thread.Sleep(1000);
        }
    }
示例#16
0
 public void Browse(AddressProtocol addressProtocol, string regtype, string domain)
 {
     Browse (0, addressProtocol, regtype, domain);
 }
示例#17
0
 public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     Configure(interfaceIndex, addressProtocol, regtype, domain);
     StartAsync();
 }
示例#18
0
 public void Browse(uint interfaceIndex, AddressProtocol addressProtocol, string regtype, string domain)
 {
     Configure(interfaceIndex, addressProtocol, regtype, domain);
     StartAsync();
 }