Monday, June 28, 2010

MinGW and DLL

http://wyw.dcweb.cn/dllfaq.htm

A. Assume we have a testdll.h, testdll.c, and testmain.c. In the first case, we will compile testdll.c with MinGW, and let the MSVC-compiled testmain call it. You should use

gcc -shared -o testdll.dll testdll.c \
-Wl,--output-def,testdll.def,--out-implib,libtestdll.a

to produce the DLL and DEF files. MSVC cannot use the MinGW library, but since you have already the DEF file you may easily produce one by the Microsoft LIB tool:

lib /machine:i386 /def:testdll.def

Once you have testdll.lib, it is trivial to produce the executable with MSVC:

cl testmain.c testdll.lib

Now for MinGW programs calling an MSVC DLL. We have two methods. One way is to specify the LIB files directly on the command line after the main program (in newer MinGW versions; MinGW GCC 2.95.2 is reported not to work). For example, after

cl /LD testdll.c

use

gcc -o testmain testmain.c testdll.lib

The other way is to produce the .a files for GCC. For __cdecl functions (in most cases), it is simple: you only need to apply the reimp tool (the original site is unavailable now, but you may download here a version enhanced by José Fonseca):

reimp testdll.lib
gcc -o testmain testmain.c -L. -ltestdll

However, the above method does not work with __stdcall functions. For MSVC will prefix an underscore to __stdcall functions while MinGW will not. The right way is to produce the DEF file using the pexports tool (downloadable here if not found elsewhere) and filter off the first underscore by sed:

pexports testdll.dll | sed "s/^_//" > testdll.def

Then, when using dlltool to produce the import library, add `-U' to the command line:

dlltool -U -d testdll.def -l libtestdll.a

And now, you can proceed in the usual way:

gcc -o testmain testmain.c -L. -ltestdll

Thursday, June 17, 2010

GSM A-interface (BSS - MSC)

1. 基本描述: ts 48.001


2. BSS - MSC 功能划分原则:ts 48.002

2.1 一般来说,用 MSC( Mobile Core Network) 代表核心网的用户面和控制面。有些情况下,MSC被分为两部分MSC-Server(MSC-S)和Media Gateway(MGW).

2.2 Mobility management
All transactions concerning mobility management (as specified in 3GPP TS 44.018) shall take place transparently between the MS and MSC/VLR/HLR, using the protocols described in Technical Specifications 3GPP TS 48.008 and 3GPP TS 48.006. The only exception to this rule is that of paging which is scheduled by the BSS on the appropriate cell.

2.3 Call control 由 MSC/HLR/VLR 负责


3. 信令传输: ts 48.006

3.1 The MTP and the SCCP are used to support signalling messages between the MSC and the BSS

3.2 One user function of the SCCP, called BSS Application Part (BSSAP) is defined. In the case of point-to-point calls the BSSAP uses one signalling connection per active Mobile Station having one or more active transactions for the transfer of layer 3 messages. The BSSAP user function is further subdivided into two separate functions:

3.2.1 he Direct Transfer Application sub-Part (DTAP) is used to transfer messages between the MSC and the MS; the layer-3 information in these messages is not interpreted by the BSS.

3.2.2 he BSS Management Application sub-Part (BSSMAP) supports other procedures between the MSC and the BSS related to the MS (resource management, handover control), or to a cell within the BSS, or to the whole BSS.


4. L3 specifications: ts 48.008

4.1 BSC负责管理本地的无线资源

4.2 CC(call control) 和MM(Mobility Management)消息,BSS使用DTAP协议传递给MSC,不做处理

4.3 从Radio收到的initial L3 message,BSS初步分析后使用BSSMAP的COMPLETE LAYER 3 INFORMATION消息传递给MSC.(eg. CM SERVICE REQUEST, PAGING RESPONSE, CM REESTABLISHMENT REQUEST, LOCATION UPDATING REQUEST, IMSI DETACH, IMMEDIATE SETUP)