0

Hello!

I'm having an problem.. while compiling one of the sources.

ERROR =

Error 5 error LNK2019: unresolved external symbol "int __stdcall WSPConnect(unsigned int,struct sockaddr const *,int,struct _WSABUF *,struct _WSABUF *,struct _QualityOfService *,struct _QualityOfService *,int *)" (?WSPConnect@@YGHIPBUsockaddr@@HPAU_WSABUF@@1PAU_QualityOfService@@2PAH@Z) referenced in function _WSPStartup@76 spi.obj ifslsp

Thank You for your help.

int WSPAPI 
WSPConnect(
        SOCKET                s,
        struct sockaddr FAR * name,
        int                   namelen,
        LPWSABUF              lpCallerData,
        LPWSABUF              lpCalleeData,
        LPQOS                 lpSQOS,
        LPQOS                 lpGQOS,
        LPINT                 lpErrno)
{
    SOCKET_CONTEXT *sockContext = NULL;
    SOCKADDR       *proxyAddr = NULL;
    int             proxyLen = 0,
                    rc = SOCKET_ERROR;

    //////////////////////////////////////////////////////////////////////////
    char rulesFile[MAX_PATH] = "";

    // "l2.exe"   98.76.54.32   127.0.0.1 # Route to L2Net
    char ruleLine[1024] = "";

    char progName[MAX_PATH] = "L2.exe";   // L2.exe
    char addrSource[MAX_PATH] = "83.171.11.25"; // 23.23.23.23 / h2.lr.bfdr.eu
    char addrDest[MAX_PATH] = "127.0.0.1";   // 127.0.0.1 / localhost

    if ( name->sa_family == AF_INET )
    {
      GetModuleFileName((HMODULE)&__ImageBase, rulesFile, MAX_PATH);
      int i = lstrlen(rulesFile);
      for(;rulesFile[i] != '\\'; i--) rulesFile[i] = 0x0;
      lstrcat(rulesFile, "rules.cfg");

      FILE *fp;
      fp = fopen(rulesFile, "r");

      if(fp) // Sucessful opening
      {
        while (!feof(fp))
        {
          if( fgets(ruleLine, sizeof(ruleLine), fp) != NULL )
          {
            ZeroMemory(progName, sizeof(progName));
            ZeroMemory(addrSource, sizeof(addrSource));
            ZeroMemory(addrDest, sizeof(addrDest));
            ParseLine(ruleLine, progName, addrSource, addrDest);
            if (!lstrlen(progName) || !lstrlen(addrSource) || !lstrlen(addrDest))
            { // If one of string args is wrong... clean all
              ZeroMemory(progName, sizeof(progName));
              ZeroMemory(addrSource, sizeof(addrSource));
              ZeroMemory(addrDest, sizeof(addrDest));
            }
            else
            {
              // DO REDIRECTION STUFF HERE
              char exePath[MAX_PATH] = "";
              char exeName[MAX_PATH] = "";
              GetModuleFileName(NULL, exePath, sizeof(exePath));
              int i = lstrlen(exePath);
              for(;exePath[i] != '\\'; i--); i++;
              for(int j = 0; exePath[i] != 0; i++, j++) exeName[j] = exePath[i];

              if(!lstrcmpi(exeName, progName))
              { // Equal... so rule is for current process

                // Redirect one destination to another
                LPCH ReqAddr = inet_ntoa(((SOCKADDR_IN*)name)->sin_addr);
                if ( !lstrcmpi(ReqAddr, addrSource) ) // if Equal
                {
                  // replace with NEW
                  ((SOCKADDR_IN*)name)->sin_addr.s_addr = inet_addr(addrDest);
                  // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< replasing goes here
                }

                //hostent* d_addr = gethostbyname(addrSource);
                //mbEx("H_ADDR of host(%s): '%u.%u.%u.%u'", addrSource,
                //  d_addr->h_addr_list[0][0], d_addr->h_addr_list[0][1], d_addr->h_addr_list[0][2], d_addr->h_addr_list[0][3]);

                //mbEx("exeName: \"%s\"\nprogName: \"%s\"\n\naddrSource: \"%s\"\naddrDest: \"%s\"",
                //  exeName, progName, addrSource, addrDest);
              }
            }

            ZeroMemory(ruleLine, sizeof(ruleLine));
          }
        }

        fclose(fp);
      }
    }
3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by bbinesh
0

include the proper header files.which all header files you are using?

#include "lspdef.h"
#include <fstream>

Just those two.

0

lspdef.h -

#ifndef _PSDK_BLD
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#endif

#include <ws2spi.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <mstcpip.h>

#ifndef _PSDK_BLD
#include <lspcommon.h>
#else
#include "..\common\lspcommon.h"
#endif
0

Its a linker error you are getting.If the main function cant find the original module for the called function compiler show this error.

Look into this.

0

Check the paramaters passed in by the caller - they dont seem to match with the definition for WSPConnect - if using C++ that would mean attempt to resolve to different fn - which it wont find
There should be a compile warning to "cant find function WSPConnect ...." assuming ...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.