  We consider extended $1$-perfect codes in Hamming graphs $H(n,q)$. Such
nontrivial codes are known only when $n=2^k$, $k\geq 1$, $q=2$, or $n=q+2$,
$q=2^m$, $m\geq 1$. Recently, Bespalov proved nonexistence of extended
$1$-perfect codes for $q=3$, $4$, $n>q+2$. In this work, we characterize all
positive integers $n$, $r$ and prime $p$, for which there exist such a code in
$H(n,p^r)$.
