osnetwork.c

来自「osal for Vxworks,c code」· C语言 代码 · 共 108 行

C
108
字号
/*** File   : osnetwork.c** Author : *//****************************************************************************************                                    INCLUDE FILES****************************************************************************************/#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "hostLib.h"#include "common_types.h"#include "osapi.h"/****************************************************************************************                                     DEFINES****************************************************************************************//****************************************************************************************                                   GLOBAL DATA****************************************************************************************//****************************************************************************************                                INITIALIZATION FUNCTION****************************************************************************************//****************************************************************************************                                    Network API****************************************************************************************//*--------------------------------------------------------------------------------------    Name: OS_NetworkGetID        Purpose: Gets the ID of the current Network     Returns: OS_ERROR if the  host id could not be found             a 32 bit host id if success---------------------------------------------------------------------------------------*/int32 OS_NetworkGetID             (void){  int    retval;  int    host_id;  uint32 name_len = 35;  char   host_name [name_len];    retval = gethostname( host_name, name_len);      if ( retval == -1 )         return OS_ERROR;    host_id = hostGetByName(host_name);   if (host_id == -1)       return OS_ERROR;       return (host_id);    }/* end OS_NetworkGetID *//*--------------------------------------------------------------------------------------    Name: OS_NetworkGetHostName        Purpose: Gets the name of the current host    Returns: OS_ERROR if the  host name could not be found             OS_SUCCESS if the name was copied to host_name successfully---------------------------------------------------------------------------------------*/int32 OS_NetworkGetHostName       (char *host_name, uint32 name_len){   int    retval;   uint32 return_code;      if ( host_name == NULL)   {      return_code = OS_INVALID_POINTER;   }   else if ( name_len == 0 )   {      return_code = OS_ERROR;   }   else   {      retval = gethostname( host_name, name_len);      if ( retval == -1 )      {               return_code = OS_ERROR;      }      else      {         return_code = OS_SUCCESS;      }   }   return(return_code);}/* end OS_NetworkGetHostName */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?