Can we use ports in driver, inside driver callback method driver's handle?

What exactly is your requirement? It sounds like you want to conditionally write a packet to the driver’s analysis_port. Is there something more?
By the way, if your requirement is to use a callback in the driver, then I’d respectfully suggest that it’s an overly-specified requirement and you may want to rethink it.