Change function prototype to use endpoint_t instead of int