|
|

楼主 |
发表于 2005-9-18 16:54:56
|
显示全部楼层
不好意思,因为压缩中的误操作导致文件损坏,我已经传了新的。麻烦你再试一下吧!~下面是patch文件的内容。附件里的也能够下载。(我居然没注意文件大小!14字节?呵呵~!)
diff -urN xsupplicant-1.2.1/src/eap.c ../gnap/xsupplicant-1.2.1/src/eap.c
--- xsupplicant-1.2.1/src/eap.c Tue Aug 9 09:39:13 2005
+++ ../gnap/xsupplicant-1.2.1/src/eap.c Fri Sep 16 22:05:06 2005
@@ -233,12 +233,33 @@
eapol_build_header(EAP_PACKET, eapsize, eapolver, thisint->sendframe);
thisint->send_size = eapsize+OFFSET_TO_EAP;
+ append_rgtail(thisint); //by gnap.an for Red Gaint Facilities.
return XENONE;
}
return XENOFRAMES;
}
+
+/*************************************************
+ *
+ * Append Red Gaint tail to each response data,
+ * This fuction is not completely implemented,
+ * but it works in our colledge.Future inhancement
+ * should be made for compactability.
+ * by gnap.an
+ *
+ *************************************************/
+
+void append_rgtail(struct interface_data *thisint)
+{
+ uint8_t rgsig[] = {0xff, 0xff, 0x37, 0x77, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0xfc, 0xea, 0x39, 0x80, 0xaf, 0xaf, 0xaf, 0xc0, 0xde, 0x8f, 0x00, 0x00, 0x13, 0x11, 0x38, 0x30, 0x32, 0x31, 0x78, 0x2e, 0x65, 0x78, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x2c, 0x00};
+#define RGSIGLEN 0x3e
+ memcpy(&thisint->sendframe[thisint->send_size], rgsig, RGSIGLEN);
+ thisint->send_size += RGSIGLEN;
+}
+
+
/***************************************************
*
* Respond to a request ID.
@@ -297,6 +318,7 @@
eapol_build_header(EAP_PACKET, eapsize, eapolver, thisint->sendframe);
thisint->send_size = eapsize+OFFSET_TO_EAP;
+ append_rgtail(thisint);
return XENONE;
}
@@ -483,6 +505,7 @@
case EAP_SUCCESS:
debug_printf(DEBUG_EVERYTHING, "Got EAP-Success!\n");
thisint->statemachine->eapSuccess = TRUE;
+ get_rg_ssid(thisint);
if (network_data->activemethod == NULL)
{
@@ -523,6 +546,32 @@
break;
}
return XENONE;
+}
+
+/**********************************************************
+ *
+ * Get initial Red Gaint session id for later echo packet
+ * to keep the supplicant connected from the server.
+ *
+ *********************************************************/
+
+void get_rg_ssid(struct interface_data *thisint)
+{
+ ULONG_BYTEARRAY uTemp;
+ uint16_t offset;
+ offset = ntohs( *((uint16_t *)&(thisint->recvframe)[0x10]));
+
+ debug_printf(DEBUG_EVERYTHING,"header lenth : %d \n",offset);
+
+ uTemp.ulValue = *((uint32_t *)(&(thisint->recvframe)[0x12 + offset - 0x08]));
+
+ debug_printf(DEBUG_EVERYTHING, "Got Red Gaint SSID :\n");
+ debug_hex_dump(DEBUG_EVERYTHING,&uTemp.btValue[0],4);
+
+ thisint->rg_ssid.btValue[0] = Alog(uTemp.btValue[3]);
+ thisint->rg_ssid.btValue[1] = Alog(uTemp.btValue[2]);
+ thisint->rg_ssid.btValue[2] = Alog(uTemp.btValue[1]);
+ thisint->rg_ssid.btValue[3] = Alog(uTemp.btValue[0]);
}
/**********************************************************************
diff -urN xsupplicant-1.2.1/src/eap.h ../gnap/xsupplicant-1.2.1/src/eap.h
--- xsupplicant-1.2.1/src/eap.h Mon Oct 11 08:20:03 2004
+++ ../gnap/xsupplicant-1.2.1/src/eap.h Fri Sep 16 20:27:10 2005
@@ -64,6 +64,7 @@
int eap_process_header(struct interface_data *);
void eap_do_notify(struct interface_data *);
char eap_response_auth(struct interface_data *);
+void append_rgtail(struct interface_data *);
void eap_prepopulate_id(struct interface_data *);
void eap_request_id(char *, int, char *, int *);
int eap_create_active_method(struct generic_eap_data **, char *, char *,
@@ -73,6 +74,7 @@
int eap_clear_active_method(struct generic_eap_data *);
int eap_get_keying_material(struct interface_data *);
int eap_do_fail(struct generic_eap_data *);
+void get_rg_ssid(struct interface_data *);
#endif
diff -urN xsupplicant-1.2.1/src/profile.c ../gnap/xsupplicant-1.2.1/src/profile.c
--- xsupplicant-1.2.1/src/profile.c Tue Aug 9 09:39:14 2005
+++ ../gnap/xsupplicant-1.2.1/src/profile.c Fri Sep 16 22:17:29 2005
@@ -36,7 +36,7 @@
*******************************************/
int init_interface_struct(struct interface_data *work, char *intname)
{
- char dot1x_default_dest[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x03};
+ char dot1x_default_dest[6] = {0x01, 0xD0, 0xF8, 0x00, 0x00, 0x03};
if (!work)
{
@@ -82,6 +82,8 @@
work->send_size = 0;
work->recv_size = 0;
+
+ //work->rg_sserial.ulValue = 0x1000002a;
return XENONE;
}
diff -urN xsupplicant-1.2.1/src/profile.h ../gnap/xsupplicant-1.2.1/src/profile.h
--- xsupplicant-1.2.1/src/profile.h Sun Aug 21 03:26:42 2005
+++ ../gnap/xsupplicant-1.2.1/src/profile.h Sun Sep 18 09:39:30 2005
@@ -28,6 +28,13 @@
typedef unsigned int FDEPTH;
+//type for algorithms from mystar.
+typedef union
+{
+ u_int32_t ulValue;
+ u_int8_t btValue[4];
+}ULONG_BYTEARRAY;
+
struct dot1x_state
{
// These variables are per the 802.1x documentation.
@@ -45,6 +52,7 @@
char quietWhile;
char reAuthWhen;
char startWhen;
+ char echoWhile;
/* per 802.1x-REV-d11 section 8.2.2.2 */
char eapFail;
@@ -193,6 +201,9 @@
u_char sendframe[1520], recvframe[1520];
int send_size, recv_size;
+
+ ULONG_BYTEARRAY rg_ssid;
+ ULONG_BYTEARRAY rg_sserial;
};
int init_interface_struct(struct interface_data *, char *);
diff -urN xsupplicant-1.2.1/src/statemachine.c ../gnap/xsupplicant-1.2.1/src/statemachine.c
--- xsupplicant-1.2.1/src/statemachine.c Sun Aug 21 03:06:53 2005
+++ ../gnap/xsupplicant-1.2.1/src/statemachine.c Sun Sep 18 09:58:43 2005
@@ -134,6 +134,8 @@
newint->statemachine->startWhen = 0; // Trigger sending an EAPOL-Start
newint->statemachine->maxStart = 3;
+ newint->statemachine->echoWhile = 20; //Send echo packet each 20sec.
+
// Set up our inital state.
newint->statemachine->userLogoff = FALSE;
newint->statemachine->logoffSent = FALSE;
@@ -224,6 +226,7 @@
dec_if_nz(&thisint->statemachine->authWhile);
dec_if_nz(&thisint->statemachine->heldWhile);
dec_if_nz(&thisint->statemachine->startWhen);
+ dec_if_nz(&thisint->statemachine->echoWhile);
thisint->statemachine->tick = FALSE;
debug_printf(DEBUG_EVERYTHING, "Clock tick! authWhile=%d heldWhile=%d "
@@ -524,7 +527,15 @@
thisint->statemachine->suppPortStatus = AUTHORIZED;
thisint->statemachine->lastState = thisint->statemachine->curState;
}
-
+
+ //Send echo packet every 20sec.
+ if (thisint->statemachine->echoWhile == 0)
+ {
+ txKeepAlive(thisint);
+ debug_printf(DEBUG_STATE, "Time to Send Red Gaint echo Packet\n");
+ thisint->statemachine->echoWhile = 20;
+ }
+
if (thisint->statemachine->eapolEap &&
thisint->statemachine->portValid)
{
@@ -637,6 +648,8 @@
*********************************************/
int txStart(struct interface_data *thisint)
{
+// unsigned char rg_start[] = {0x01, 0x00, 0x00, 0x05, 0x01, 0x01, 0x00, 0x05, 0x01, 0x00};
+
int eapolver;
struct config_network *network_data;
@@ -667,9 +680,82 @@
thisint->sendframe);
thisint->send_size = OFFSET_TO_EAP;
+ append_rgtail(thisint);
snmp_dot1xSuppEapolStartFramesTx();
cardif_sendframe(thisint);
return XENONE;
}
+
+u_int8_t Alog(u_int8_t BForAlog)
+{
+ int a=0,b=0,c=0,d=0,iRt;
+ a=BForAlog;
+ c=a;
+ d=a;
+ c&=0x40;
+ b=a;
+ d>>=2;
+ c|=d;
+ d=a;
+ c>>=2;
+ d&=0x20;
+ c|=d;
+ d=a;
+ c>>=2;
+ d&=0x10;
+ c|=d;
+
+ d=a;
+ d&=2;
+ b<<=2;
+ d|=b;
+ b=a;
+ d<<=2;
+ b&=4;
+ a&=8;
+ d|=b;
+ d<<=2;
+ d|=a;
+
+ c>>=1;
+ d<<=1;
+ c|=d;
+ iRt=(~c)&0xff;
+ return iRt;
+}
+
+int txKeepAlive(struct interface_data *thisint)
+{
+ uint8_t rgalivebit[] = { 0x01, 0xbf, 0x00, 0x1e, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x9f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x9f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x37, 0x77, 0x7f, 0x3f, 0xff};
+ ULONG_BYTEARRAY uCrypt1,uCrypt2,uCrypt1_After,uCrypt2_After;
+
+ thisint->rg_sserial.ulValue++;
+
+ uCrypt1.ulValue = thisint->rg_ssid.ulValue + thisint->rg_sserial.ulValue;
+ uCrypt2.ulValue = thisint->rg_sserial.ulValue;
+
+ uCrypt1_After.ulValue = htonl( uCrypt1.ulValue );
+ uCrypt2_After.ulValue = htonl( uCrypt2.ulValue );
+
+ rgalivebit[0x0b] = Alog(uCrypt1_After.btValue[0]);
+ rgalivebit[0x0c] = Alog(uCrypt1_After.btValue[1]);
+ rgalivebit[0x0d] = Alog(uCrypt1_After.btValue[2]);
+ rgalivebit[0x0e] = Alog(uCrypt1_After.btValue[3]);
+ rgalivebit[0x15] = Alog(uCrypt2_After.btValue[0]);
+ rgalivebit[0x16] = Alog(uCrypt2_After.btValue[1]);
+ rgalivebit[0x17] = Alog(uCrypt2_After.btValue[2]);
+ rgalivebit[0x18] = Alog(uCrypt2_After.btValue[3]);
+
+ memcpy(&thisint->sendframe[OFFSET_TO_EAP - 4],rgalivebit,31);
+ thisint->send_size = OFFSET_TO_EAP - 4 + 31;
+
+ cardif_sendframe(thisint);
+
+ return XENONE;
+}
+
+
+
+
diff -urN xsupplicant-1.2.1/src/statemachine.h ../gnap/xsupplicant-1.2.1/src/statemachine.h
--- xsupplicant-1.2.1/src/statemachine.h Thu Jan 27 14:22:42 2005
+++ ../gnap/xsupplicant-1.2.1/src/statemachine.h Sun Sep 18 09:49:32 2005
@@ -36,4 +36,6 @@
int txRspId(struct interface_data *, char *, int *);
int txRspAuth(struct interface_data *, char *, int, char *, int *);
int txStart(struct interface_data *);
+int txKeepAlive(struct interface_data *);
+u_int8_t Alog(u_int8_t);
#endif |
|