/* File Temp.c Does temporary stuff. */ #include "..\\error.h" #include #include #include #include #include #include #include #include #define MPR50 1 #include #include #include #include // Error reporting void PrintErr(DWORD err); // [pmay] This will be removed when the router is modified to use MprInfo api's typedef RTR_INFO_BLOCK_HEADER IPX_INFO_BLOCK_HEADER, *PIPX_INFO_BLOCK_HEADER; typedef RTR_TOC_ENTRY IPX_TOC_ENTRY, *PIPX_TOC_ENTRY; // Prototypes of functions that may be temporarily used for test.exe void FixFwd(); DWORD DispPorts(); DWORD EnumGroups (); DWORD Service(); void Crash(); // Return true if you want this function to implement test.exe BOOL TempFunc(int argc, char ** argv) { //Service(); //return TRUE; return FALSE; } // Display ports DWORD DispPorts() { DWORD dwErr; HANDLE hRouterAdmin; if ((dwErr = MprAdminServerConnect(NULL, &hRouterAdmin)) != NO_ERROR) return dwErr; } PIPX_TOC_ENTRY GetIPXTocEntry ( IN PIPX_INFO_BLOCK_HEADER pInterfaceInfo, IN ULONG InfoEntryType ) { UINT i; PIPX_TOC_ENTRY pTocEntry; for (i=0, pTocEntry = pInterfaceInfo->TocEntry; iTocEntriesCount; i++, pTocEntry++) { if (pTocEntry->InfoType == InfoEntryType) { return pTocEntry; } } SetLastError (ERROR_FILE_NOT_FOUND); return NULL; } DWORD GetNbIpxClientIf (LPTSTR InterfaceName, UINT msg) { DWORD rc, sz; LPBYTE pClBlock; HANDLE hTrCfg, hRouterAdmin; if ((rc = MprAdminServerConnect(NULL, &hRouterAdmin)) != NO_ERROR) return rc; hTrCfg = NULL; rc = MprAdminTransportGetInfo ( hRouterAdmin, PID_IPX, NULL, NULL, &pClBlock, &sz); if (rc==NO_ERROR) { PIPX_TOC_ENTRY pIpxToc, pSapToc, pRipToc; // Netbios pIpxToc = GetIPXTocEntry ((PIPX_INFO_BLOCK_HEADER)pClBlock, IPX_INTERFACE_INFO_TYPE); if (pIpxToc!=NULL) { PIPX_IF_INFO pIpxInfo; pIpxInfo = (PIPX_IF_INFO)(pClBlock+pIpxToc->Offset); printf("\nDial-in\n"); printf("Accept = %d\n", pIpxInfo->NetbiosAccept); printf("Deliver = %d\n\n", pIpxInfo->NetbiosDeliver); pIpxInfo->NetbiosDeliver = 1; } // rip pRipToc = GetIPXTocEntry ((PIPX_INFO_BLOCK_HEADER)pClBlock,IPX_PROTOCOL_RIP); if (pIpxToc!=NULL) { PRIP_IF_CONFIG pRipCfg; pRipCfg = (PRIP_IF_CONFIG)(pClBlock+pRipToc->Offset); printf("\nDial-in\n"); printf("Rip = %d\n", pRipCfg->RipIfInfo.UpdateMode); pRipCfg->RipIfInfo.UpdateMode = 2; } // sap pSapToc = GetIPXTocEntry ((PIPX_INFO_BLOCK_HEADER)pClBlock,IPX_PROTOCOL_SAP); if (pIpxToc!=NULL) { PSAP_IF_CONFIG pSapCfg; pSapCfg = (PSAP_IF_CONFIG)(pClBlock+pSapToc->Offset); printf("\nDial-in\n"); printf("Sap Mode = %d\n\n\n", pSapCfg->SapIfInfo.UpdateMode); pSapCfg->SapIfInfo.UpdateMode = 2; } MprAdminTransportSetInfo( hRouterAdmin, PID_IPX, (LPBYTE)NULL, 0, pClBlock, sz); MprAdminBufferFree (pClBlock); } return rc; } void FixFwd() { GetNbIpxClientIf(NULL, 0); GetNbIpxClientIf(NULL, 0); } // Enumerates the local groups on the local machine DWORD EnumGroups () { NET_API_STATUS nStatus; GROUP_INFO_0 * buf; DWORD i, dwMax = 2000000, dwTot, dwRead=0; nStatus = NetLocalGroupEnum(NULL, 0, (LPBYTE*)&buf, dwMax, &dwRead, &dwTot, NULL); if (nStatus != NERR_Success) { switch (nStatus) { case ERROR_ACCESS_DENIED: return ERROR_ACCESS_DENIED; case NERR_UserExists: return ERROR_USER_EXISTS; case NERR_PasswordTooShort: return ERROR_INVALID_PASSWORDNAME; case NERR_InvalidComputer: // These should never happen because case NERR_NotPrimary: // we deal with local user database case NERR_GroupExists: default: return ERROR_CAN_NOT_COMPLETE; } } for (i=0; i