Merge branch 'develop' into moreremo
Conflicts: conman.c
This commit is contained in:
12
conman.c
12
conman.c
@ -1138,7 +1138,7 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
WriteToCommandLogId(NULL, self->sockHandle, buffer);
|
WriteToCommandLogId(NULL, self->sockHandle, buffer);
|
||||||
SetSendingConnection(NULL);
|
SetSendingConnection(NULL);
|
||||||
|
|
||||||
if(self->iProtocolID == 4) { /* act */
|
if(self->iProtocolID == PROTACT) { /* act */
|
||||||
if (strlen(buffer) + 30 > 1024) {
|
if (strlen(buffer) + 30 > 1024) {
|
||||||
pPtr = (char *) malloc((strlen(buffer) + 30) * sizeof(char));
|
pPtr = (char *) malloc((strlen(buffer) + 30) * sizeof(char));
|
||||||
memset(pPtr, 0, strlen(buffer) + 20);
|
memset(pPtr, 0, strlen(buffer) + 20);
|
||||||
@ -1150,7 +1150,7 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
if(pPtr != pBueffel){
|
if(pPtr != pBueffel){
|
||||||
free(pPtr);
|
free(pPtr);
|
||||||
}
|
}
|
||||||
} else if(self->iProtocolID == 2) { /* withcode */
|
} else if(self->iProtocolID == PROTCODE) { /* withcode */
|
||||||
if (strlen(buffer) + 30 > 1024) {
|
if (strlen(buffer) + 30 > 1024) {
|
||||||
pPtr = (char *) malloc((strlen(buffer) + 30) * sizeof(char));
|
pPtr = (char *) malloc((strlen(buffer) + 30) * sizeof(char));
|
||||||
memset(pPtr, 0, strlen(buffer) + 20);
|
memset(pPtr, 0, strlen(buffer) + 20);
|
||||||
@ -1162,7 +1162,7 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
if(pPtr != pBueffel){
|
if(pPtr != pBueffel){
|
||||||
free(pPtr);
|
free(pPtr);
|
||||||
}
|
}
|
||||||
} else if(self->iProtocolID == 3) { /* json */
|
} else if(self->iProtocolID == PROTJSON) { /* json */
|
||||||
myJson = mkJSON_Object(self,buffer,iOut);
|
myJson = mkJSON_Object(self,buffer,iOut);
|
||||||
if(myJson != NULL){
|
if(myJson != NULL){
|
||||||
SCDoSockWrite(self,(char *)json_object_to_json_string(myJson));
|
SCDoSockWrite(self,(char *)json_object_to_json_string(myJson));
|
||||||
@ -1348,7 +1348,7 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData,
|
|||||||
memset(outBuf, 0, 65536);
|
memset(outBuf, 0, 65536);
|
||||||
|
|
||||||
protocolID = GetProtocolID(self);
|
protocolID = GetProtocolID(self);
|
||||||
if (protocolID == 4) {
|
if (protocolID == PROTACT) {
|
||||||
cc = SCGetContext(self);
|
cc = SCGetContext(self);
|
||||||
sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName,
|
sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName,
|
||||||
compressedLength, cc.transID);
|
compressedLength, cc.transID);
|
||||||
@ -1423,7 +1423,7 @@ int SCWriteBinary(SConnection * self, char *pName, void *pData,
|
|||||||
memset(outBuf, 0, 65536);
|
memset(outBuf, 0, 65536);
|
||||||
|
|
||||||
protocolID = GetProtocolID(self);
|
protocolID = GetProtocolID(self);
|
||||||
if (protocolID == 4) {
|
if (protocolID == PROTACT) {
|
||||||
cc = SCGetContext(self);
|
cc = SCGetContext(self);
|
||||||
sprintf(outBuf, "SICSBIN BIN %s %d %d\r\n", pName,
|
sprintf(outBuf, "SICSBIN BIN %s %d %d\r\n", pName,
|
||||||
iDataLen, cc.transID);
|
iDataLen, cc.transID);
|
||||||
@ -1529,7 +1529,7 @@ int SCWriteZippedOld(SConnection * self, char *pName, void *pData,
|
|||||||
memset(outBuf, 0, 65536);
|
memset(outBuf, 0, 65536);
|
||||||
|
|
||||||
protocolID = GetProtocolID(self);
|
protocolID = GetProtocolID(self);
|
||||||
if (protocolID == 4) {
|
if (protocolID == PROTACT) {
|
||||||
cc = SCGetContext(self);
|
cc = SCGetContext(self);
|
||||||
sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName,
|
sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName,
|
||||||
compressedLength, cc.transID);
|
compressedLength, cc.transID);
|
||||||
|
12
nread.c
12
nread.c
@ -42,6 +42,8 @@
|
|||||||
#include "commandlog.h"
|
#include "commandlog.h"
|
||||||
#include "uselect.h"
|
#include "uselect.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
#include "protocol.h"
|
||||||
|
|
||||||
|
|
||||||
extern pServer pServ;
|
extern pServer pServ;
|
||||||
extern int VerifyChannel(mkChannel * self); /* defined in network.c */
|
extern int VerifyChannel(mkChannel * self); /* defined in network.c */
|
||||||
@ -296,7 +298,7 @@ static int NetReadRead(pNetRead self, pNetItem pItem)
|
|||||||
if (strlen(pItem->pHold) > 0) {
|
if (strlen(pItem->pHold) > 0) {
|
||||||
strlcat(pItem->pHold, pPtr, 511);
|
strlcat(pItem->pHold, pPtr, 511);
|
||||||
/* DFC locking for protocol zero only */
|
/* DFC locking for protocol zero only */
|
||||||
if (pItem->pCon->iProtocolID == 0 &&
|
if (pItem->pCon->iProtocolID == PROTSICS &&
|
||||||
CostaLocked(pItem->pCon->pStack))
|
CostaLocked(pItem->pCon->pStack))
|
||||||
iStat = 0;
|
iStat = 0;
|
||||||
else
|
else
|
||||||
@ -308,7 +310,7 @@ static int NetReadRead(pNetRead self, pNetItem pItem)
|
|||||||
} else {
|
} else {
|
||||||
/* no, normal command */
|
/* no, normal command */
|
||||||
/* DFC locking for protocol zero only */
|
/* DFC locking for protocol zero only */
|
||||||
if (pItem->pCon->iProtocolID == 0 &&
|
if (pItem->pCon->iProtocolID == PROTSICS &&
|
||||||
CostaLocked(pItem->pCon->pStack))
|
CostaLocked(pItem->pCon->pStack))
|
||||||
iStat = 0;
|
iStat = 0;
|
||||||
else
|
else
|
||||||
@ -498,7 +500,7 @@ static int TelnetRead(pNetRead self, pNetItem pItem)
|
|||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
/* DFC locking for protocol zero only */
|
/* DFC locking for protocol zero only */
|
||||||
if (pItem->pCon->iProtocolID == 0 &&
|
if (pItem->pCon->iProtocolID == PROTSICS &&
|
||||||
CostaLocked(pItem->pCon->pStack))
|
CostaLocked(pItem->pCon->pStack))
|
||||||
iStat = 0;
|
iStat = 0;
|
||||||
else
|
else
|
||||||
@ -1076,7 +1078,7 @@ static int CommandDataCB(int handle, void *userData)
|
|||||||
if (pPtr[i] == '\r' || pPtr[i] == '\n') {
|
if (pPtr[i] == '\r' || pPtr[i] == '\n') {
|
||||||
self->state = SKIPTERM;
|
self->state = SKIPTERM;
|
||||||
if (!testAndInvokeInterrupt(self, handle)) {
|
if (!testAndInvokeInterrupt(self, handle)) {
|
||||||
if (self->pCon->iProtocolID == 0 && CostaLocked(self->pCon->pStack))
|
if (self->pCon->iProtocolID == PROTSICS && CostaLocked(self->pCon->pStack))
|
||||||
status = 0;
|
status = 0;
|
||||||
else
|
else
|
||||||
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
||||||
@ -1180,7 +1182,7 @@ static int ANETTelnetProcess(int handle, void *usData)
|
|||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
if (!testAndInvokeInterrupt(self, handle)) {
|
if (!testAndInvokeInterrupt(self, handle)) {
|
||||||
if (self->pCon->iProtocolID == 0 && CostaLocked(self->pCon->pStack))
|
if (self->pCon->iProtocolID == PROTSICS && CostaLocked(self->pCon->pStack))
|
||||||
status = 0;
|
status = 0;
|
||||||
else
|
else
|
||||||
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
status = CostaTop(self->pCon->pStack, GetCharArray(self->command));
|
||||||
|
43
protocol.c
43
protocol.c
@ -32,6 +32,10 @@ typedef struct __Protocol {
|
|||||||
int isDefaultSet;
|
int isDefaultSet;
|
||||||
char *pProList[PROLISTLEN]; /* list of valid protocols? */
|
char *pProList[PROLISTLEN]; /* list of valid protocols? */
|
||||||
} Protocol;
|
} Protocol;
|
||||||
|
/*================================================================================================
|
||||||
|
WARNING: These two char arrays may replicate things defined elsewhere. They may be out of
|
||||||
|
sync with the rest of SIS. Keep in mind.....
|
||||||
|
==================================================================================================*/
|
||||||
|
|
||||||
char *pEventType[] = {
|
char *pEventType[] = {
|
||||||
"VALUECHANGE", /* 0 */
|
"VALUECHANGE", /* 0 */
|
||||||
@ -277,29 +281,29 @@ static int ProtocolSet(SConnection * pCon, Protocol * pPro, char *pProName)
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* normal (connection start default) */
|
case PROTNORM: /* normal (connection start default) */
|
||||||
SCSetWriteFunc(pMaster, SCNormalWrite);
|
SCSetWriteFunc(pMaster, SCNormalWrite);
|
||||||
SCSetWriteFunc(pCon, SCNormalWrite);
|
SCSetWriteFunc(pCon, SCNormalWrite);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* outcodes */
|
case PROTCODE: /* outcodes */
|
||||||
SCSetWriteFunc(pMaster, SCWriteWithOutcode);
|
SCSetWriteFunc(pMaster, SCWriteWithOutcode);
|
||||||
SCSetWriteFunc(pCon, SCWriteWithOutcode);
|
SCSetWriteFunc(pCon, SCWriteWithOutcode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /* json */
|
case PROTJSON: /* json */
|
||||||
SCSetWriteFunc(pCon, SCWriteJSON_String);
|
SCSetWriteFunc(pCon, SCWriteJSON_String);
|
||||||
SCSetWriteFunc(pMaster, SCWriteJSON_String);
|
SCSetWriteFunc(pMaster, SCWriteJSON_String);
|
||||||
break;
|
break;
|
||||||
case 4: /* ACT */
|
case PROTACT: /* ACT */
|
||||||
SCSetWriteFunc(pMaster, SCACTWrite);
|
SCSetWriteFunc(pMaster, SCACTWrite);
|
||||||
SCSetWriteFunc(pCon, SCACTWrite);
|
SCSetWriteFunc(pCon, SCACTWrite);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case PROTALL:
|
||||||
SCSetWriteFunc(pMaster, SCAllWrite);
|
SCSetWriteFunc(pMaster, SCAllWrite);
|
||||||
SCSetWriteFunc(pCon, SCAllWrite);
|
SCSetWriteFunc(pCon, SCAllWrite);
|
||||||
break;
|
break;
|
||||||
case 0: /* default = psi_sics */
|
case PROTSICS: /* default = psi_sics */
|
||||||
default:
|
default:
|
||||||
SCSetWriteFunc(pMaster, pPro->defaultWriter);
|
SCSetWriteFunc(pMaster, pPro->defaultWriter);
|
||||||
SCSetWriteFunc(pCon, pPro->defaultWriter);
|
SCSetWriteFunc(pCon, pPro->defaultWriter);
|
||||||
@ -338,11 +342,11 @@ int ProtocolGet(SConnection * pCon, void *pData, char *pProName, int len)
|
|||||||
|
|
||||||
/* check list of protocols for valid name */
|
/* check list of protocols for valid name */
|
||||||
switch (Index) {
|
switch (Index) {
|
||||||
case 0: /* default = psi_sics */
|
case PROTSICS: /* default = psi_sics */
|
||||||
case 1: /* normal (connection start default) */
|
case PROTNORM: /* normal (connection start default) */
|
||||||
case 2: /* outcodes */
|
case PROTCODE: /* outcodes */
|
||||||
case 3: /* json */
|
case PROTJSON: /* json */
|
||||||
case 4: /* act */
|
case PROTACT: /* act */
|
||||||
pProName = pPro->pProList[Index];
|
pProName = pPro->pProList[Index];
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
@ -447,7 +451,7 @@ static int InitDefaultProtocol(SConnection * pCon, Protocol * pPro)
|
|||||||
if (0 == pPro->isDefaultSet) {
|
if (0 == pPro->isDefaultSet) {
|
||||||
pPro->defaultWriter = SCGetWriteFunc(pCon);
|
pPro->defaultWriter = SCGetWriteFunc(pCon);
|
||||||
pPro->isDefaultSet = 1;
|
pPro->isDefaultSet = 1;
|
||||||
pCon->iProtocolID = 0;
|
pCon->iProtocolID = PROTSICS;
|
||||||
}
|
}
|
||||||
return pPro->isDefaultSet;
|
return pPro->isDefaultSet;
|
||||||
}
|
}
|
||||||
@ -634,10 +638,11 @@ char *GetProtocolName(SConnection * pCon)
|
|||||||
|
|
||||||
/* check list of protocols for valid name */
|
/* check list of protocols for valid name */
|
||||||
switch (pCon->iProtocolID) {
|
switch (pCon->iProtocolID) {
|
||||||
case 0: /* default = psi_sics */
|
case PROTSICS: /* default = psi_sics */
|
||||||
case 1: /* normal (connection start default) */
|
case PROTNORM: /* normal (connection start default) */
|
||||||
case 2: /* outcodes */
|
case PROTCODE: /* outcodes */
|
||||||
case 3: /* json */
|
case PROTJSON: /* json */
|
||||||
|
case PROTACT: /* act */
|
||||||
return strdup(pPro->pProList[pCon->iProtocolID]);
|
return strdup(pPro->pProList[pCon->iProtocolID]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -660,13 +665,13 @@ writeFunc GetProtocolWriteFunc(SConnection * pCon)
|
|||||||
{
|
{
|
||||||
if (pCon != NULL) {
|
if (pCon != NULL) {
|
||||||
switch (pCon->iProtocolID) {
|
switch (pCon->iProtocolID) {
|
||||||
case 2: /* outcodes */
|
case PROTCODE: /* outcodes */
|
||||||
return SCWriteWithOutcode;
|
return SCWriteWithOutcode;
|
||||||
break;
|
break;
|
||||||
case 3: /* json */
|
case PROTJSON: /* json */
|
||||||
return SCWriteJSON_String;
|
return SCWriteJSON_String;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case PROTACT:
|
||||||
return SCACTWrite;
|
return SCACTWrite;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -15,6 +15,14 @@ static char *pProTags[3] = {
|
|||||||
#define esStart -1
|
#define esStart -1
|
||||||
#define esFinish -2
|
#define esFinish -2
|
||||||
|
|
||||||
|
/*---------------------- protocol defines -------------------------------*/
|
||||||
|
#define PROTSICS 0
|
||||||
|
#define PROTNORM 1
|
||||||
|
#define PROTCODE 2
|
||||||
|
#define PROTJSON 3
|
||||||
|
#define PROTACT 4
|
||||||
|
#define PROTALL 5
|
||||||
|
|
||||||
/*--------------------- lifecycle -------------------------------------- */
|
/*--------------------- lifecycle -------------------------------------- */
|
||||||
int InstallProtocol(SConnection * pCon, SicsInterp * pSics, void *pData,
|
int InstallProtocol(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||||
int argc, char *argv[]);
|
int argc, char *argv[]);
|
||||||
|
Reference in New Issue
Block a user