// Dec function use to decrement an ip
7328
func Dec(ip net.IP) {
	for j := len(ip) - 1; j >= 0; j-- {
		ip[j]--
		if ip[j] == 255 {
			continue
		}
		if ip[j] > 0 {
			break
		}
	}
}
1073140
func (n *Net) Delete(r *net.IPNet) (value interface{}, ok bool, err error) {
	var ip net.IP
	if ip, _, err = netValidateIPNet(r); err == nil {
		value, ok = n.trie.Delete(netIPNetToKey(ip, r.Mask))
	}
	return
}
372981
func (session *Session) Decr(column string, arg ...interface{}) *Session {
	session.Statement.Decr(column, arg...)
	return session
}
667593
func (met *Metrics) Dec(name string) {
	atomic.AddInt64(met.get(name), -1)
}
552715
func (s *IPSet) Del(entry string) error {
	out, err := exec.Command(ipsetPath, "del", s.Name, entry, "-exist").CombinedOutput()
	if err != nil {
		return fmt.Errorf("error deleting entry %s: %v (%s)", entry, err, out)
	}
	return nil
}
1223356
func (l *Conn) Del(delRequest *DelRequest) error {
	packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
	packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
	packet.AppendChild(delRequest.encode())
	if delRequest.Controls != nil {
		packet.AppendChild(encodeControls(delRequest.Controls))
	}

	l.Debug.PrintPacket(packet)

	msgCtx, err := l.sendMessage(packet)
	if err != nil {
		return err
	}
	defer l.finishMessage(msgCtx)

	l.Debug.Printf("%d: waiting for response", msgCtx.id)
	packetResponse, ok := <-msgCtx.responses
	if !ok {
		return NewError(ErrorNetwork, errors.New("ldap: response channel closed"))
	}
	packet, err = packetResponse.ReadPacket()
	l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
	if err != nil {
		return err
	}

	if l.Debug {
		if err := addLDAPDescriptions(packet); err != nil {
			return err
		}
		ber.PrintPacket(packet)
	}

	if packet.Children[1].Tag == ApplicationDelResponse {
		resultCode, resultDescription := getLDAPResultCode(packet)
		if resultCode != 0 {
			return NewError(resultCode, errors.New(resultDescription))
		}
	} else {
		log.Printf("Unexpected Response: %d", packet.Children[1].Tag)
	}

	l.Debug.Printf("%d: returning", msgCtx.id)
	return nil
}
1183574
func (arr SortedIPs) Less(i, j int) bool {
	return lessAdrr(arr[i], arr[j])
}
233630
func IP4ToInt(ip net.IP) uint32 {
	ip = ip.To4()
	if ip == nil {
		return 0
	}
	return binary.BigEndian.Uint32(ip)
}
276213
func Inc(IP net.IP) net.IP {
	IP = checkIPv4(IP)
	incIP := make([]byte, len(IP))
	copy(incIP, IP)
	for j := len(incIP) - 1; j >= 0; j-- {
		incIP[j]++
		if incIP[j] > 0 {
			break
		}
	}
	return incIP
}
791018
func (e ErrPortAlreadyAllocated) IPPort() string {
	return fmt.Sprintf("%s:%d", e.ip, e.port)
}
1345326
func (c *MemcacheCacher) Decr(key string) error {
	_, err := c.c.Decrement(key, 1)
	return err
}
1372075
func (c *Client) Del(vb uint16, key string) (*gomemcached.MCResponse, error) {
	return c.Send(&gomemcached.MCRequest{
		Opcode:  gomemcached.DELETE,
		VBucket: vb,
		Key:     []byte(key)})
}
283976
func (r refCount) Decrement(key string) int {
	val := r[key]
	if val <= 1 {
		delete(r, key)
		return 0
	}
	r[key]--
	return r[key]
}
1092610
func (c *Client) DecrBy(name string, value int) error {
	return c.Increment(name, -value, 1)
}
1299784
func (c *Client) Del(key string) (err error) {
	return c.DelCAS(key, 0)
}
491489
func (s *secureSession) Decrypt(r io.Reader) (io.Reader, error) {
	var buf bytes.Buffer
	for {
		var length uint16
		if err := binary.Read(r, binary.LittleEndian, &length); err != nil {
			if err == io.EOF {
				break
			}
			return nil, err
		}

		if length > PacketLengthMax {
			return nil, fmt.Errorf("Packet size too big %d", length)
		}

		var b = make([]byte, length)
		if err := binary.Read(r, binary.LittleEndian, &b); err != nil {
			return nil, err
		}

		var mac [16]byte
		if err := binary.Read(r, binary.LittleEndian, &mac); err != nil {
			return nil, err
		}

		var nonce [8]byte
		binary.LittleEndian.PutUint64(nonce[:], s.decryptCount)
		s.decryptCount++

		lengthBytes := make([]byte, 2)
		binary.LittleEndian.PutUint16(lengthBytes, uint16(length))

		decrypted, err := chacha20poly1305.DecryptAndVerify(s.decryptKey[:], nonce[:], b, mac, lengthBytes)

		if err != nil {
			return nil, fmt.Errorf("Data encryption failed %s", err)
		}

		buf.Write(decrypted)

		// Finish when all bytes fit in b
		if length < PacketLengthMax {
			break
		}
	}

	return &buf, nil
}
42632
func DeleteIP(conn client.Connection, req IPRequest) error {
	logger := plog.WithFields(log.Fields{
		"hostid":    req.HostID,
		"ipaddress": req.IPAddress,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	t := conn.NewTransaction()

	// Delete the pool ip
	ppth := path.Join(basepth, "/ips", req.IPID())
	if ok, err := conn.Exists(ppth); err != nil {
		logger.WithError(err).Debug("Could not look up pool ip")
		// TODO: error
		return err
	} else if ok {
		t.Delete(ppth)
	} else {
		logger.Debug("No ip to delete on the pool")
	}

	// Delete the host ip
	hpth := path.Join(basepth, "/hosts", req.HostID, "/ips", req.IPID())
	if ok, err := conn.Exists(hpth); err != nil {
		logger.WithError(err).Debug("Could not look up host ip")
		// TODO: error
		return err
	} else if ok {
		t.Delete(hpth)
	} else {
		logger.Debug("No ip to delete on the host")
	}

	if err := t.Commit(); err != nil {
		logger.WithError(err).Debug("Could not commit transaction")
		// TODO: error
		return err
	}
	logger.Debug("Deleted ip")
	return nil
}