Take a serious look at Open-X Ad Server. It requires setting up as an independent server (unless you use their service) but it has all of what you are asking for a tons more.
If you are not that ambitious take a look at OIO Publisher Ad Manager plugin for WordPress. I believe it can also handle what you are looking for (please report back if not.)
BTW, don't even consider building your own ad server. My company went down that path back in the late 90s and you would not believe how complicated the logic gets not to mention trying to ensure it is performant. If you are doing anything serious you definitely want to stand on the shoulders of giants on this one.