package ssdp

import 

type config struct {
	multicastConfig
	advertiseConfig
}

func opts2config( []Option) ( config,  error) {
	for ,  := range  {
		 := .apply(&)
		if  != nil {
			return config{}, 
		}
	}
	return , nil
}

type multicastConfig struct {
	ttl   int
	sysIf bool
}

func ( multicastConfig) () ( []multicast.ConnOption) {
	if .ttl > 0 {
		 = append(, multicast.ConnTTL(.ttl))
	}
	if .sysIf {
		 = append(, multicast.ConnSystemAssginedInterface())
	}
	return 
}

type advertiseConfig struct {
	addHost bool
}

// Option is option set for SSDP API.
type Option interface {
	apply(c *config) error
}

type optionFunc func(*config) error

func ( optionFunc) ( *config) error {
	return ()
}

// TTL returns as Option that set TTL for multicast packets.
func ( int) Option {
	return optionFunc(func( *config) error {
		.ttl = 
		return nil
	})
}

// OnlySystemInterface returns as Option that using only a system assigned
// multicast interface.
func () Option {
	return optionFunc(func( *config) error {
		.sysIf = true
		return nil
	})
}

// AdvertiseHost returns as Option that add HOST header to response for
// M-SEARCH requests.
// This option works with Advertise() function only.
// This is added to support SmartThings.
// See https://github.com/koron/go-ssdp/issues/30 for details.
func () Option {
	return optionFunc(func( *config) error {
		.addHost = true
		return nil
	})
}