mod_zeroconf
Post on 21-Jan-2016
26 Views
Preview:
DESCRIPTION
TRANSCRIPT
mod_zeroconf
A Zero Configuration Registration Module for Apache 2.0
Sander Temme
sander@temme.net
Agenda
• Technology Overview
• Zeroconf Applications
• mod_zeroconf for Apache 2.0– Design– Demo– Code Walkthrough
• Q&A
What is Zeroconf?
• IETF Working Group– Formed in Sept. 1999
• Usability of TCP/IP
• Enhancements to Existing Protocols
• Not SLP, …
What is Zeroconf?
What is Zeroconf?
• TCP/IP Autoconfiguration
• Network naming
• Service Browsing
Technology Overview
• Link-local addressing
• multicast DNS
• DNS Service-Discovery
Link-local Addressing
• No Central Address Server
• Pick a Random Address– In 169.254.0.0/16 range
• Address Defense
• Can Work With Centrally Assigned Addresses
Link-local Addressing
Printer
Network
169.254.1.219
169.254.4.51
169.254.10.29
169.254.4.51
mDNS
• DNS-like Protocol
• Every Host Runs Responder
• Hosts Pick Own Names
• Communication over IP Multicast
• Link-local
• Resolves to Link-local or Regular Address
Printer169.254.1.219
169.254.4.51
169.254.10.29
169.254.4.51
mDNSPC_BILL
PC_LARRY
lj21569478
Network
Mac_Steve
DNS-SD
• Service Publishing and Browsing
• Uses Existing DNS Record types
• User Sees Only Service Names
• Works With mDNS or Regular DNS
DNS-SD
Bill’s Files
Larry’s Tunes
Laserjet, Closet Under the Stairs
Printer169.254.1.219
169.254.4.51
169.254.10.29
169.254.4.51
PC_BILL
PC_LARRY
lj21569478
Network
Mac_Steve
Steve’s Movies
Applications
• Printer Configuration
• Music/Photo/Document Sharing
• Distributed Compilation
• Network gaming
• … (the sky is the limit)
Peer to Peer Chat
Sharing Tunes
Sharing Sites
Platform support
• MacOSX 10.2 and up
• Linux: several initiatives– Mandrake put it in the distribution– No one else so far
• Windows…– Link-local addressing works– Third-party mDNSResponder
Windows and Rendezvous
Zeroconf on Linux
• May need Link-local address– http://zeroconf.sourceforge.net/?selected=zcip – http://www.zeroconf.org/AVH-IPv4LL.c
• Need mDNSResponder– tmdns or– Apple’s mDNSResponder or
• http://developer.apple.com/darwin/projects/rendezvous/
– zmdns, openmdns (search SourceForge) or– Howl or– Embeddable: mdnsd http://www.dotlocal.org/mdnsd/ – Running Java? Try http://jmdns.sourceforge.net/
Zeroconf and Apache
• Goals– Publish Apache http services
– Work with external mDNSResponder
– Support Apache 2.0
– ASF Licensed
• Existing initiatives– mod_rendezvous: Apache 1.3, Mac only
– mod_rendezvous_apple: ditto
– mdnsmod: No code on SF, in ‘planning stage’
External mDNSResponder
• Apple mDNSResponder– No client libraries
• zmdns– Wrapper around Apple code– Mixed BSD, APSL– Alpha stage
• openmdns, tmdns– GPL
Howl
• Based on Apple code
• Modified BSD license
• At version 0.9.3, API should be stable
• Linux, Windows, MacOSX, …
• Plugin for Windows Internet Explorer
http://www.porchdogsoft.com/products/
Configuration
# En/disable Zeroconf server-wide. Default: offZeroconf {on|off}
# Register main server or virtualhost container. ZeroconfRegister “service name” [/partialpath]
# This is part of the coreServerName hostname:port
Demo
mod_zeroconf Design
Apache 2.0Core
HowlmDNSResponder
mod_zeroconf
Virtual Host Config Info
mDNS Registration
mDNS Callbacks
What Gets Registered?
• Service Name
• SRV information: port, hostname, partial URI
• Hostname/IP (if different)
• Callback function
mod_zeroconf Design
ApacheCore
HowlmDNSResponder
mod_zeroconf
Virtual Host Config Info
mDNS Registration
mDNS CallbacksCallbackProcess
Registration Callbacks
• Network can be very dynamic
• Service name, Hostname conflicts
• Apache needs to respond
• Can’t block parent process: – fork a child
mod_zeroconf.c: post_configstatic int zc_post_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp, server_rec *s){ void *data; const char *userdata_key = "zeroconf_init_module";
apr_pool_userdata_get(&data, userdata_key, s->process->pool); if (!data) { apr_pool_userdata_set((const void *) 1, userdata_key, apr_pool_cleanup_null, s->process->pool); } else { . . . } return OK;}
mod_zeroconf.c: config check/* Check if Zeroconf has been enabled globally. If not, bail here */cfg = our_sconfig(s);if (cfg->enabled == 0) { return OK;}/* Still here? Let's go. */TESTORBAIL(sw_rendezvous_init(&howl_session));
/* Get System Hostname (not shown) */
for (ws = s; ws; ws = ws->next) { cfg = our_sconfig(ws); if (cfg->serviceName) { . . . }}
mod_zeroconf.c: TEXT Record
if (cfg->partialURI) { TESTORBAIL(sw_text_record_init(&text_record)); TESTORBAIL(sw_text_record_add_key_and_string_value(text_record, "path", cfg->partialURI)); pathinfo = sw_text_record_bytes(text_record); pilength = sw_text_record_len(text_record);} else { pathinfo = NULL; pilength = 0;}
serverport = ws->port == 0 ? 80 : ws->port;
if (apr_strnatcasecmp(thehostname, ws->server_hostname) != 0) { zc_register_host(ws);}
mod_zeroconf.c: Publish!howl_result = sw_rendezvous_publish(howl_session, cfg->serviceName, "_http._tcp", NULL, ws->server_hostname, serverport, pathinfo, pilength, NULL, howl_publish_reply, (sw_opaque) ws, &howl_id);
pubidPtr = apr_palloc(s->process->pool, sizeof(sw_rendezvous_publish_id));*pubidPtr = howl_id;apr_pool_userdata_set(howl_id, cfg->serviceName, apr_pool_cleanup_null, ws->process->pool);
mod_zeroconf.c: Fork callback#if APR_HAS_FORKcallbackchild = apr_palloc(s->process->pool, sizeof(apr_proc_t));
switch(forkstatus = apr_proc_fork(callbackchild, s->process->pool)) {case APR_INCHILD: sw_rendezvous_run(howl_session); break; /* Not reached */case APR_INPARENT: apr_pool_note_subprocess(s->process->pool, callbackchild, APR_KILL_AFTER_TIMEOUT); break;default: ap_log_error(APLOG_MARK, APLOG_ERR, forkstatus, s, "Failed to fork callback child"); return HTTP_INTERNAL_SERVER_ERROR;}#endif /* APR_HAS_FORK */
mod_zeroconf: To-Dos
• Learn about https protocol• Learn about DAV, …• Port to MacOSX? Apache 1.3?• Alternative mDNS implementations• IPv6 compatibility• More solid hostname registration• Better callback code• etc…
mod_zeroconf: Where?
• Project home page:– http://www.temme.net/sander/mod_zeroconf/
• Contact:– sander@temme.net
• About Apache server:– http://httpd.apache.org/
• Apache modules:– apache-modules@covalent.net
Conclusion
• Zeroconf is great
• Will make networks more usable
• Platform support needed across vendors
• Applications will follow
• mod_zeroconf is cool– Patches are welcome
Q&A
top related