Controller area network received message filtering mechanism
It is very straight-forward: only act when you receive a message you want, and ignore everything else. Simply keep a list of CAN identifiers and then take action based on them. It is a pure software problem.

CAN controllers always have built-in filter registers, but these are almost always too crude to be used in semi-advanced applications, because they use bit masking. The only use of such filters in practice, is when you have a CAN node which should only listen to one or maybe two CAN messages.

EDIT: note that these filters typically use a bitwise NOR of all existing CAN identifiers. Which is why the filters make less and less sense, the more CAN identifiers you need to support. It is a fundamental design mistake in the CAN filter mechanism in most CAN controllers.

The reason why you would want to use such filters is to reduce the work load of the CPU. Yet some of the dumber CAN controllers will still yield an interrupt for message received, even when the message didn't pass the filter.

So my advise for this case is to forget all about hardware filters and do all checks of CAN id in software. 

For a large amount of different CAN ids, you will need to use a sorted table and efficiently search (binary search) through it to see if they received CAN id was valid.

The real question here is if you have a CAN driver for the given MCU or not. Coding a CAN driver yourself is not trivial, it usually takes 1-2 months to develop a fully functional CAN driver, given that you already know CAN and C programming.