⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osnetwork.c

📁 osal for Vxworks,c code
💻 C
字号:
/*** 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -