1. A hardware-based method for policing traffic in a network node, the method comprising: receiving a programming input that defines a relationship between condition primitives and action primitives, wherein the condition primitives and the action primitives are used to implement a policing algorithm, each condition primitive including a series of bits that indicates an incoming color of a packet, whether enough credits are available to forward the packet, and whether a credit bucket is full, and each action primitive including a series of bits that indicates the outgoing color of a packet, whether a credit bucket should be decremented to account for a forwarded packet, whether a packet should be dropped, and whether the credit bucket should be refreshed; storing a set of indexed action primitives according to the defined relationship, wherein the stored set of indexed action primitives comprises multiple index and action primitive pairs, wherein each action primitive is specific to the policing algorithm and includes a series of bits that indicates the outgoing color of a packet, whether a credit bucket should be decremented to account for a forwarded packet, whether a packet should be dropped, and whether the credit bucket should be refreshed; identifying a condition primitive in response to a datagram that is received at the network node; generating an index from the condition primitive; using the index to select an action primitive from the stored set of indexed action primitives; and performing a policing action related to the datagram in response to the selected action primitive; wherein the stored set of indexed action primitives includes a decrement primitive that indicates whether or not credit should be decremented from a corresponding credit bucket and an increment primitive that indicates whether or not the corresponding credit bucket should be refreshed with credits according to a corresponding refresh rate; and wherein performing the policing action comprises at least one of decrementing credit from the corresponding credit bucket and refreshing credits of the corresponding credit bucket according to the corresponding refresh rate.