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

📄 xsupconfwrite.c

📁 Linux上的802.1x 的supplicant的实现。很多supplicant程序都是基于它开发的
💻 C
📖 第 1 页 / 共 5 页
字号:
    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t{\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  if (eapleap->username)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tusername = \"%s\"\n", eapleap->username) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (eapleap->password)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tpassword = \"%s\"\n", eapleap->password) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t}\n\n") < 0)    {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }    return XSUPCONFWRITE_ERRNONE;  }/******************************************************************** * * Write the configuration information for EAP-MSCHAPv2 * ********************************************************************/int xsupconfwrite_eap_mschapv2(FILE *fileid, struct config_eap_method *cur,			       int phase){  struct config_eap_mschapv2 *eapmschapv2;    if (!fileid)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n", 	     xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOFILEHANDLE;    }    if (!cur)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n",	     xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOEAPDATA;    }  eapmschapv2 = (struct config_eap_mschapv2 *)cur->method_data;  if (!eapmschapv2)    {#ifdef DEBUG      printf("The EAP-MSCHAPv2 structure is NULL!\n");#endif      return XSUPCONFWRITE_NOEAPDATA;    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\teap-mschapv2\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t{\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  if (eapmschapv2->username)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tusername = \"%s\"\n", eapmschapv2->username) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (eapmschapv2->password)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0)	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tpassword = \"%s\"\n", eapmschapv2->password) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (eapmschapv2->nthash)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0)	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tntpwdhash = \"%s\"\n", eapmschapv2->nthash) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t}\n\n") < 0)    {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }    return XSUPCONFWRITE_ERRNONE;  }/******************************************************************** * * Write the configuration information for EAP-OTP/GTC * ********************************************************************/int xsupconfwrite_eap_otp(FILE *fileid, struct config_eap_method *cur,			  int phase, int otp){  struct config_eap_otp *eapotp;    if (!fileid)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n", 	     xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOFILEHANDLE;    }    if (!cur)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n",	     xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOEAPDATA;    }  eapotp = (struct config_eap_otp *)cur->method_data;  if (!eapotp)    {#ifdef DEBUG      printf("The EAP-OTP/GTC structure is NULL!\n");#endif      return XSUPCONFWRITE_NOEAPDATA;    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (otp)    {      if (fprintf(fileid, "\teap-otp\n") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    } else {      if (fprintf(fileid, "\teap-gtc\n") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t{\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  /*    // XXX Usernames aren't allowed (yet), so enable this code later.  if (eapotp->username)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) return XSUPCONFWRITE_GENIOERR;	}      if (fprintf(fileid, "\t\tusername = \"%s\"\n", eapotp->username) < 0)	return XSUPCONFWRITE_GENIOERR;    }  */  if (eapotp->password)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tpassword = \"%s\"\n", eapotp->password) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t}\n\n") < 0)    {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }    return XSUPCONFWRITE_ERRNONE;  }/******************************************************************** * * Write the configuration information for EAP-SIM * ********************************************************************/int xsupconfwrite_eap_sim(FILE *fileid, struct config_eap_method *cur,			  int phase){  struct config_eap_sim *eapsim;    if (!fileid)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n", 	     xsupconfwrite_strerr(XSUPCONFWRITE_NOFILEHANDLE),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOFILEHANDLE;    }    if (!cur)    {#ifdef DEBUG      printf("Error : %s, at %s():%d!\n",	     xsupconfwrite_strerr(XSUPCONFWRITE_NOEAPDATA),	     __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_NOEAPDATA;    }  eapsim = (struct config_eap_sim *)cur->method_data;  if (!eapsim)    {#ifdef DEBUG      printf("The EAP-SIM structure is NULL!\n");#endif      return XSUPCONFWRITE_NOEAPDATA;    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\teap-sim\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (fprintf(fileid, "\t{\n") < 0)     {#ifdef DEBUG      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif      return XSUPCONFWRITE_GENIOERR;    }  if (eapsim->username)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tusername = \"%s\"\n", eapsim->username) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (eapsim->password)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tpassword = \"%s\"\n", eapsim->password) < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }  if (eapsim->auto_realm == TRUE)    {      if (phase ==2)	{	  if (fprintf(fileid, "\t") < 0) 	    {#ifdef DEBUG	      printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	      return XSUPCONFWRITE_GENIOERR;	    }	}      if (fprintf(fileid, "\t\tauto_realm = yes\n") < 0)	{#ifdef DEBUG	  printf("Error writing to file @ %s():%d\n", __FUNCTION__, __LINE__);#endif	  return XSUPCONFWRITE_GENIOERR;	}    }   if (phase ==2)    {      if (fprintf(fileid, "\t") < 0) 	{

⌨️ 快捷键说明

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