WASHINGTON (Reuters) - U.S. Senator Lindsey Graham said on Sunday he was optimistic that Republicans, Democrats and President Donald Trump could reach a deal to end a government shutdown that includes border wall funding and legal status for some illegal immigrants.

Graham, a Republican, told reporters after meeting Trump for lunch at the White House that Trump was receptive to Graham’s idea of a deal that might provide work permits to so-called Dreamers, people brought illegally to the United States as children, in exchange for money for physical border barriers.

“The president was upbeat, he was in a very good mood, and I think he’s receptive to making a deal,” Graham said, adding that Trump found the potential Dreamer concession “interesting.”

But the senator said there would never be a government spending deal that did not include money for a wall or other physical barriers on the U.S.-Mexico border. The wall was one of the central promises of Trump’s presidential campaign.

“I don’t see Democrats giving us more money unless they get something. So, the one thing we talked about is making deals,” Graham said.

“After lunch I’ve never been more encouraged that if we can get people talking we can find our way out of this mess and that would include around $5 billion for border security, slash wall, slash fencing whatever you want to call it in areas that make sense,” he added.

Trump later made clear on Twitter that he regarded a wall as necessary.

Slideshow ( 2 images )

“President and Mrs. Obama built/has a ten foot Wall around their D.C. mansion/compound. I agree, totally necessary for their safety and security,” Trump wrote. “The U.S. needs the same thing, slightly larger version!”

Earlier, on CNN’s “State of the Union” program, Graham floated the idea of giving Democrats a version of stalled legislation to protect Dreamers from deportation in exchange for wall funding.

The Trump administration in 2017 announced plans to phase out the Deferred Action for Childhood Arrivals program, begun under former President Barack Obama to shield Dreamers from deportation. But Trump’s DACA phase-out has been delayed by court rulings against it.

With the partial government shutdown in its ninth day on Sunday, some other lawmakers were less upbeat about prospects for a deal to restore spending authority.

Republican Senator Richard Shelby warned on CBS’ “Face the Nation” that negotiations were at an impasse and the shutdown “could last a long, long time.”

Democratic U.S. Representative Hakeem Jeffries said the country needed comprehensive immigration reform and border security.

“We are not willing to pay $2.5 billion or $5 billion and wasting taxpayer dollars on a ransom note because Donald Trump decided that he was going to shut down the government and hold the American people hostage,” Jeffries said on ABC.

Democrats take control of the U.S. House of Representatives this week, following November’s congressional elections.