void KprZeroconfPlatformStart() { #if KPR_ZEROCONF_EMBEDDED mStatus status; status = mDNS_Init(&mDNSStorage, &PlatformStorage, gRRCache, RR_CACHE_SIZE, mDNS_Init_DontAdvertiseLocalAddresses, mDNS_StatusCallback, mDNS_Init_NoInitCallbackContext); gInterfaceNotifier = FskNetInterfaceAddNotifier(KprZeroconfNetworkInterfaceNotifier, NULL, "KprZeroconfNetworkInterfaceNotifier"); #endif }
/* interface is optional. If NULL, then all interfaces will be used */ FskErr FskHTTPServerCreate(int port, char *interfaceName, FskHTTPServer *server, void *refCon, Boolean ssl) { FskHTTPServer http; FskErr err; FskInstrumentedTypePrintfDebug(&gFskHTTPServerTypeInstrumentation, "httpServerCreate\n"); err = FskMemPtrNewClear(sizeof(FskHTTPServerRecord), (FskMemPtr*)&http); BAIL_IF_ERR(err); sFskHTTPServerUpUse(http); http->stopped = true; http->refCon = refCon; http->port = port; http->keepAliveTimeout = kFskHTTPKeepAliveTimeout; http->defaultBufferSize = kFskHTTPServerDefaultBufferSize; http->owner = FskThreadGetCurrent(); http->ssl = ssl; snprintf(http->name, 64, "%s:%d", interfaceName ? interfaceName : "all", port); FskInstrumentedItemNew(http, http->name, &gFskHTTPServerTypeInstrumentation); if (interfaceName) { err = FskHTTPServerListenerAdd(http, port, interfaceName, NULL); } else { FskNetInterfaceRecord *ifc; int i, numI; http->all = true; numI = FskNetInterfaceEnumerate(); for (i=0; i<numI; i++) { FskErr notErr = FskNetInterfaceDescribe(i, &ifc); if (notErr) continue; if (ifc->status) { notErr = FskHTTPServerListenerAdd(http, port, ifc->name, NULL); if (notErr) err = notErr; } FskNetInterfaceDescriptionDispose(ifc); } } http->interfaceNotifier = FskNetInterfaceAddNotifier(httpServerInterfaceChanged, http, "http server"); bail: *server = http; return err; }