In a graph I^, a perfect code is an independent set C with the property that every vertex not in C is adjacent to a unique vertex in C, and a total perfect code is a set C of vertices of I^ such that every vertex of I^ is adjacent to a unique vertex in C. We classify these codes for generalized Petersen graphs.