Implement the beforenm/afternm calls at the NIF layer.