code: func buildEndpointInfo(networkSettings *internalnetwork.Settings, n libnetwork.Network, ep libnetwork.Endpoint) error {
  	if ep == nil {
  		return errors.New("endpoint cannot be nil")
  	}
  
  	if networkSettings == nil {
  		return errors.New("network cannot be nil")
  	}
  
  	epInfo := ep.Info()
  	if epInfo == nil {
  		// It is not an error to get an empty endpoint info
  		return nil
  	}
  
  	if _, ok := networkSettings.Networks[n.Name()]; !ok {
  		networkSettings.Networks[n.Name()] = &internalnetwork.EndpointSettings{
  			EndpointSettings: &network.EndpointSettings{},
  		}
  	}
  	networkSettings.Networks[n.Name()].NetworkID = n.ID()
  	networkSettings.Networks[n.Name()].EndpointID = ep.ID()
  
  	iface := epInfo.Iface()
  	if iface == nil {
  		return nil
  	}
  
  	if iface.MacAddress() != nil {
  		networkSettings.Networks[n.Name()].MacAddress = iface.MacAddress().String()
  	}
  
  	if iface.Address() != nil {
  		ones, _ := iface.Address().Mask.Size()
  		networkSettings.Networks[n.Name()].IPAddress = iface.Address().IP.String()
  		networkSettings.Networks[n.Name()].IPPrefixLen = ones
  	}
  
  	if iface.AddressIPv6() != nil && iface.AddressIPv6().IP.To16() != nil {
  		onesv6, _ := iface.AddressIPv6().Mask.Size()
  		networkSettings.Networks[n.Name()].GlobalIPv6Address = iface.AddressIPv6().IP.String()
  		networkSettings.Networks[n.Name()].GlobalIPv6PrefixLen = onesv6
  	}
  
  	return nil
  }
docs: // buildEndpointInfo sets endpoint-related fields on container.NetworkSettings based on the provided network and endpoint.