/*
	Set the protocol level for this new connection.
*/
433510
func (c *Connection) setProtocolLevel(ch, sh Headers) (e error) {
	chw := ch.Value(HK_ACCEPT_VERSION)
	shr := sh.Value(HK_VERSION)

	if chw == shr && Supported(shr) {
		c.protocol = shr
		return nil
	}
	if chw == "" && shr == "" { // Straight up 1.0
		return nil // protocol level defaults to SPL_10
	}
	cv := strings.SplitN(chw, ",", -1) // Client requested versions

	if chw != "" && shr != "" {
		if hasValue(cv, shr) {
			if !Supported(shr) {
				return EBADVERSVR // Client and server agree, but we do not support it
			}
			c.protocol = shr
			return nil
		} else {
			return EBADVERCLI
		}
	}
	if chw != "" && shr == "" { // Client asked for something, server is pure 1.0
		if hasValue(cv, SPL_10) {
			return nil // protocol level defaults to SPL_10
		}
	}

	c.protocol = shr // Could be anything we support
	return nil
}
588513
func (s *CreateTargetGroupInput) SetProtocol(v string) *CreateTargetGroupInput {
	s.Protocol = &v
	return s
}
849056
func SetLevel(level Level) {
	l, err := parseLevel(level)
	if err != nil {
		fmt.Printf("%v", err)
	}

	std.mu.Lock()
	defer std.mu.Unlock()
	std.Level = l
}
891903
func (p *packetConn) SetPromiscuous(b bool) error {
	m := 1
	if !b {
		m = 0
	}

	return syscall.SetBpfPromisc(p.fd, m)
}
645715
func (s *AddOutputRequest) SetProtocol(v string) *AddOutputRequest {
	s.Protocol = &v
	return s
}
659139
func (s *NetworkBinding) SetProtocol(v string) *NetworkBinding {
	s.Protocol = &v
	return s
}
493128
func (l *RgbLedDriver) SetLevel(pin string, level byte) (err error) {
	if writer, ok := l.connection.(PwmWriter); ok {
		return writer.PwmWrite(pin, level)
	}
	return ErrPwmWriteUnsupported
}
701766
func (s *HealthCheckPolicy) SetProtocol(v string) *HealthCheckPolicy {
	s.Protocol = &v
	return s
}
790049
func (c *Conn) SetPromiscuous(b bool) error {
	return c.p.SetPromiscuous(b)
}
1307986
func SetLevel(c context.Context, l Level) context.Context {
	return context.WithValue(c, levelKey, l)
}
454999
func (p *CONNECT) setPayload() {
	// Append the Client Identifier to the payload.
	p.payload = appendLenStr(p.payload, p.clientID)

	// Append the Will Topic and the Will Message to the payload
	// if the Packet has them.
	if p.will() {
		p.payload = appendLenStr(p.payload, p.willTopic)
		p.payload = appendLenStr(p.payload, p.willMessage)
	}

	// Append the User Name to the payload if the Packet has it.
	if len(p.userName) > 0 {
		p.payload = appendLenStr(p.payload, p.userName)
	}

	// Append the Password to the payload if the Packet has it.
	if len(p.password) > 0 {
		p.payload = appendLenStr(p.payload, p.password)
	}
}
311504
func (s *Connection) SetConnectionType(v string) *Connection {
	s.ConnectionType = &v
	return s
}
442547
func (s *Subscription) SetProtocol(v string) *Subscription {
	s.Protocol = &v
	return s
}
707929
func SetLevel(lo Logger, pr Priority) (err error) {
	err = list.SetLevel(lo, pr)
	if err != nil {
		return
	}

	return
}
1174673
func (s *CreateListenerInput) SetProtocol(v string) *CreateListenerInput {
	s.Protocol = &v
	return s
}
917007
func (a *EmulateNetworkConditionsArgs) SetConnectionType(connectionType ConnectionType) *EmulateNetworkConditionsArgs {
	a.ConnectionType = connectionType
	return a
}
1030306
func (s *Listener) SetProtocol(v string) *Listener {
	s.Protocol = &v
	return s
}