diff --git a/meta/templates/sai_rpc_server_functions.tt b/meta/templates/sai_rpc_server_functions.tt index de154d7de..42b6febb0 100644 --- a/meta/templates/sai_rpc_server_functions.tt +++ b/meta/templates/sai_rpc_server_functions.tt @@ -28,6 +28,16 @@ [% END -%] [%- END -%] +[%- BLOCK check_sai_function -%] +[% name = function.name; UNLESS methods.$name %] +[% END -%] +if ([% api %]_api->[% name = function.name; GET methods.$name %] == (void *)0) { + std::cerr << "NULL ptr: [% api %]_api->[% name = function.name; GET methods.$name %]" << std::endl; + [%- PROCESS throw_null_api_exception %] + } + +[%- END -%] + [%- ######################################################################## -%] [%- ######################################################################## -%] @@ -133,6 +143,14 @@ [% indent %]throw e; [%- END -%] +[%- BLOCK throw_null_api_exception -%] + [%- indentation = indentation || 2; tab = 2; indent = ' '; indent = indent.repeat(tab*indentation) %] + +[% indent %]sai_thrift_exception e; +[% indent %]e.status = SAI_STATUS_NOT_IMPLEMENTED; +[% indent %]throw e; +[%- END -%] + [%- ######################################################################## -%] [%- ######################################################################## -%] @@ -351,6 +369,9 @@ [%- PROCESS preprocess_arguments %] + [%- # Ensure function ptr not NULL -%] + [% name = function.name; UNLESS methods.$name %]//[% END %][% PROCESS check_sai_function -%] + [%- # Now just call the function -%] [% name = function.name; UNLESS methods.$name %]//[% END %]status = [% PROCESS call_sai_function -%]