> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_30aba3d9bf6279a25d84abe4015711f7/dir_f7a957c8f5c8e80b5a8d4b37f193d419/dir_e8da2933844aa72825eccee783cf08f3/ci_a_d_k_8c.md).

# ciADK.c

[Macros](#define-members) | [Functions](#func-members) | [Variables](#var-members)

`#include <errno.h>` `#include <fcntl.h>` `#include <libgen.h>` `#include <memory.h>` `#include <pthread.h>` `#include <signal.h>` `#include <syslog.h>` `#include <sys/time.h>` `#include <sys/wait.h>` `#include <ucontext.h>` `#include <unistd.h>` `#include <stdarg.h>` `#include <stdio.h>` `#include <stdlib.h>` `#include <svc.h>` `#include "EventScheduler.h"` `#include "VHQTypes.h"` `#include "VHQDebug.h"` `#include "VHQFileNames.h"` `#include "com/libcom.h"` `#include "curl/curl.h"` `#include "VHQConfig.h"` `#include "ComIntf.h"` `#include "VHQIo.h"` `#include "log/logapi_common.h"`

Include dependency graph for ciADK.c:

![](/files/unimKYMxWLZph1arlqVy)

|         |                                                                                    |
| ------- | ---------------------------------------------------------------------------------- |
| Macros  |                                                                                    |
| #define | [ARRAY\_SIZEOF](#a083b03c5af4ad6035a7b2879c523150c)(x)   (sizeof(x)/sizeof(x\[0])) |
| #define | [CURL\_SOCKOPT\_ALREADY\_CONNECTED](#ab8ca8814344440cc2b4c774d5ef656d1)   2        |
| #define | [INFOSVC\_TAG](#aaa30870a8a4867cfda99e92e171e35ae)   "infosvc@"                    |
| #define | [COM\_EVENT\_NETWORK\_ATTACH](#a771d52401f2de7f0c44045381b86c657)   26             |
| #define | [COM\_EVENT\_NETWORK\_DETACH](#a0e00f1bff0429e1111910edf1fabfd74)   27             |

|               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| void          | [CheckAndInitLog](#a4dd68818b6d7d663ab24c7b866f6d52a) (void)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| int           | [InitVXComms](#a63a54b0dd95a1b95c327144de73f8e0b) (bool NWIF\_start)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| void          | [StartNetwork](#a14218cafcf8cb7b241304a53c65c98a9) (void)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| void          | [StartCommEngine](#a4e9cf7d5bfbf9b781773b0f768525a5d) (void)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| int           | [internal\_GetMACAddress](#a07cc05691d9ade5eac44bf6759c347fb) (char \*pszMACAddress, int iMACAddressBufLen)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| int           | [internal\_GetIPAddress](#afb24d619e9278eec2d27a3c03376d1c3) (char \*pszIPAddress, int iIPAddressBufLen)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| bool          | [GetRestartStatus](#a99d56462c3eb0a7f9c7d42ed9ad494a0) ()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| const char \* | [GetCommErrWrapper](#a88578bc5651d04ba6474943c963cb3e0) (enum [com\_ErrorCodes](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#a332bd39910a20de262a2321a456e4a58) com\_errno\_in)                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| com\_type\_t  | [get\_comtype\_by\_interface](#a264684fe3e10e9debdcc560c286a7cbf) (enum [com\_Interfaces](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#af5a039e966328fc65a4de3506050898e) interface)                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| const char \* | [get\_NetworkEvent\_description](#addc371761c51a05059a5cc567640ff4b) (enum [com\_NetworkEvent](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#a0496cb54a878b5e873baabcb337f3b67) nwEvent)                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| void          | [DirectADK\_statuscallback](#a53c99ee269bb7c9949f3695cdbbf0884) (enum [com\_ConnectionEvent](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#a8239249db998e4aac1b0477ec2e1b40f) event, enum [com\_ConnectionType](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#ad8ed41376d7876324c9101abf3cdd75c) type, const void \*data, void \*priv, enum [com\_ErrorCodes](/adk-5.0-programmers-guide/readme/files/dir_33381b8c0566c9eb2048a95e4cccf925/dir_e4c66e267a8c8e9ea5ad4dbe1baeabc7/libcom_8h.md#a332bd39910a20de262a2321a456e4a58) com\_errno) |
| void          | [ConfigureConnectionProfile](#a9b04009d734df35bae738326dd9f1594) (char \*pszDefaultPath)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| int           | [DirectADK\_init](#a9100e3514092f49bb9cbbb2234758f04) (char \*pszSettings1, char \*pszSettings2, char \*pszSettings3, char \*pszSettings4)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| int           | [DirectADK\_deinit](#a4c8b1447f733dfc68b995e9b0ad8753e) (void)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| int           | [closesocket\_callback](#a1750ae75de0cf41c067a0365f1b26b93) (void \*clientp, curl\_socket\_t item)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| int           | [DirectADK\_open](#ad15c47f904402af998ce91aa083afcd3) (CommOpenData \*pData)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| int           | [DirectADK\_close](#ac1c1c2a9496ccf9554346f4f71745c92) (CommOpenData \*pData)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| int           | [DirectADK\_status](#a0d66b33a0e606847049f08dee7403773) (void \*pData, bool \*bUp, char \*pszIpAddress, char \*pszMacAddr)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| int           | [DirectADK\_NetConn](#a2bd3df1a2e07d3c471b2f8446f44be95) (void)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| int           | [DirectADK\_NetDisconn](#a61cff86bb8cb19df0bf3a906755c0e12) (bool bForceDisconnect)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| const char \* | [DirectADK\_ErrString](#a143341710d3e44104487f08b113e1bc1) (int err)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

|           |                                                                |
| --------- | -------------------------------------------------------------- |
| Variables |                                                                |
| int       | [g\_iRefCount](#ac84b53de20ee2dea29d1cc5c43880c5e) = 0         |
| char \*   | [pszConnectionFile](#a5d847c4bab1b1a9108829112298d746f) = NULL |
| const int | [netFieldLen](#a76079c39f1616f2ed37830b98d25cf54) = 9          |

### DetailedDescription <a href="#detailed-description" id="detailed-description"></a>

Main ADK connectivity related file.

### MacroDefinition Documentation <a href="#macro-definition-documentation" id="macro-definition-documentation"></a>

### ARRAY\_SIZEOF <a href="#a083b03c5af4ad6035a7b2879c523150c" id="a083b03c5af4ad6035a7b2879c523150c"></a>

\#define ARRAY\_SIZEOF

### COM\_EVENT\_NETWORK\_ATTACH <a href="#a771d52401f2de7f0c44045381b86c657" id="a771d52401f2de7f0c44045381b86c657"></a>

\#define COM\_EVENT\_NETWORK\_ATTACH   26

### COM\_EVENT\_NETWORK\_DETACH <a href="#a0e00f1bff0429e1111910edf1fabfd74" id="a0e00f1bff0429e1111910edf1fabfd74"></a>

\#define COM\_EVENT\_NETWORK\_DETACH   27

### CURL\_SOCKOPT\_ALREADY\_CONNECTED <a href="#ab8ca8814344440cc2b4c774d5ef656d1" id="ab8ca8814344440cc2b4c774d5ef656d1"></a>

\#define CURL\_SOCKOPT\_ALREADY\_CONNECTED   2

### INFOSVC\_TAG <a href="#aaa30870a8a4867cfda99e92e171e35ae" id="aaa30870a8a4867cfda99e92e171e35ae"></a>

\#define INFOSVC\_TAG   \\"infosvc@\\"

### FunctionDocumentation <a href="#function-documentation" id="function-documentation"></a>

### CheckAndInitLog() <a href="#a4dd68818b6d7d663ab24c7b866f6d52a" id="a4dd68818b6d7d663ab24c7b866f6d52a"></a>

void CheckAndInitLog

### closesocket\_callback() <a href="#a1750ae75de0cf41c067a0365f1b26b93" id="a1750ae75de0cf41c067a0365f1b26b93"></a>

int closesocket\_callback

This callback function gets called by libcurl when sockets are closed.

**Parameters**

\[out] **clientp** = socket descriptor set with CURLOPT\_CLOSESOCKETDATA. \[out] **item** = item is the socket libcurl wants to be closed.

#### Returns

int 0, if socket closed.

### ConfigureConnectionProfile() <a href="#a9b04009d734df35bae738326dd9f1594" id="a9b04009d734df35bae738326dd9f1594"></a>

void ConfigureConnectionProfile

This function configures the connection profile to establish a connection with the help of ADK COM. It checks for multiple locations for connection profiles and update the current connection profile g\_szCurrentConnectionProfile.

**Parameters**

\[in] **pszDefaultPath** = pointer to connection profile.

#### Returns

void

### DirectADK\_close() <a href="#ac1c1c2a9496ccf9554346f4f71745c92" id="ac1c1c2a9496ccf9554346f4f71745c92"></a>

int DirectADK\_close

This function closes the connection using ADK functions and displays error message returned if any.

**Parameters**

\[in] **pData** = pointer to curl details.

#### Returns

int 0, if connection closed

### DirectADK\_deinit() <a href="#a4c8b1447f733dfc68b995e9b0ad8753e" id="a4c8b1447f733dfc68b995e9b0ad8753e"></a>

int DirectADK\_deinit

### DirectADK\_ErrString() <a href="#a143341710d3e44104487f08b113e1bc1" id="a143341710d3e44104487f08b113e1bc1"></a>

const char\\\* DirectADK\_ErrString

### DirectADK\_init() <a href="#a9100e3514092f49bb9cbbb2234758f04" id="a9100e3514092f49bb9cbbb2234758f04"></a>

int DirectADK\_init

This function initializes the ADK COM connections.

**Parameters**

\[in] **pszSettings1** \[in] **pszSettings2** \[in] **pszSettings3** \[in] **pszSettings4**

#### Returns

int 0, if initialization success

### DirectADK\_NetConn() <a href="#a2bd3df1a2e07d3c471b2f8446f44be95" id="a2bd3df1a2e07d3c471b2f8446f44be95"></a>

int DirectADK\_NetConn

This function establishes connection to network if operating mode is ADK.It calls ADK function to connect the network.

#### Returns

0, if network connect is successful.

### DirectADK\_NetDisconn() <a href="#a61cff86bb8cb19df0bf3a906755c0e12" id="a61cff86bb8cb19df0bf3a906755c0e12"></a>

int DirectADK\_NetDisconn

This function is the disconnect from network if operating mode is ADK.It calls ADK function to disconnect the network.

**Parameters**

\[in] **bForceDisconnect** =TRUE, if force disconnect is active

#### Returns

0, if network disconnect is successful.

### DirectADK\_open() <a href="#ad15c47f904402af998ce91aa083afcd3" id="ad15c47f904402af998ce91aa083afcd3"></a>

int DirectADK\_open

This function opens the connection using ADK functions and displays error message returned if any.

**Parameters**

\[in] **pData** = pointer to curl details.

#### Returns

int -1, if error

### DirectADK\_status() <a href="#a0d66b33a0e606847049f08dee7403773" id="a0d66b33a0e606847049f08dee7403773"></a>

int DirectADK\_status

This function returns the IP address and Mac address if connection status is active

**Parameters**

\[in] **pData** = pointer to curl details. \[out] **bUp** = to store status, TRUE if active/IP address is present \[out] **pszIpAddress** = to store IP Address \[out] **pszMacAddr** = to store Mac address

#### Returns

int -1, if not attached; 0, if connection attached

### DirectADK\_statuscallback() <a href="#a53c99ee269bb7c9949f3695cdbbf0884" id="a53c99ee269bb7c9949f3695cdbbf0884"></a>

void DirectADK\_statuscallback

This is a callback function that will be called by ADK COM when an event is generated.

**Parameters**

\[out] **event** = event thrown by the network layer \[out] **type** = type of connection \[out] **data** = data \[out] **priv** = network profile \[out] **com\_errno** = ADK COM error code returned.

#### Returns

void

### get\_comtype\_by\_interface() <a href="#a264684fe3e10e9debdcc560c286a7cbf" id="a264684fe3e10e9debdcc560c286a7cbf"></a>

com\_type\_t get\_comtype\_by\_interface

This function sets the enum value corresponding to the network type we got from ADK COM.

**Parameters**

\[in] **interface** = Available communication interfaces in the system

#### Returns

com\_type\_t

### get\_NetworkEvent\_description() <a href="#addc371761c51a05059a5cc567640ff4b" id="addc371761c51a05059a5cc567640ff4b"></a>

const char\\\* get\_NetworkEvent\_description

### GetCommErrWrapper() <a href="#a88578bc5651d04ba6474943c963cb3e0" id="a88578bc5651d04ba6474943c963cb3e0"></a>

const char\\\* GetCommErrWrapper

This function returns a zero-terminated string with a description matching the input com\_errno by using ADK COM functions and displays the error if any.

**Parameters**

\[in] **com\_errno\_in** = error codes

#### Returns

void

### GetRestartStatus() <a href="#a99d56462c3eb0a7f9c7d42ed9ad494a0" id="a99d56462c3eb0a7f9c7d42ed9ad494a0"></a>

bool GetRestartStatus

### InitVXComms() <a href="#a63a54b0dd95a1b95c327144de73f8e0b" id="a63a54b0dd95a1b95c327144de73f8e0b"></a>

int InitVXComms

### internal\_GetIPAddress() <a href="#afb24d619e9278eec2d27a3c03376d1c3" id="afb24d619e9278eec2d27a3c03376d1c3"></a>

int internal\_GetIPAddress

Function gather the IP address information.

**Parameters**

\[out] **pszIPAddress** = pointer to IP address \[out] **iIPAddressBufLen** = IP address buffer length

#### Returns

int 0, if success

### internal\_GetMACAddress() <a href="#a07cc05691d9ade5eac44bf6759c347fb" id="a07cc05691d9ade5eac44bf6759c347fb"></a>

int internal\_GetMACAddress

Function gather the MAC address information.

**Parameters**

\[out] **pszMACAddress** = pointer to MAC address \[out] **iMACAddressBufLen** = MAC address buffer length

#### Returns

int 0,if success

### StartCommEngine() <a href="#a4e9cf7d5bfbf9b781773b0f768525a5d" id="a4e9cf7d5bfbf9b781773b0f768525a5d"></a>

void StartCommEngine

### StartNetwork() <a href="#a14218cafcf8cb7b241304a53c65c98a9" id="a14218cafcf8cb7b241304a53c65c98a9"></a>

void StartNetwork

### VariableDocumentation <a href="#variable-documentation" id="variable-documentation"></a>

### g\_iRefCount <a href="#ac84b53de20ee2dea29d1cc5c43880c5e" id="ac84b53de20ee2dea29d1cc5c43880c5e"></a>

int g\_iRefCount = 0

### netFieldLen <a href="#a76079c39f1616f2ed37830b98d25cf54" id="a76079c39f1616f2ed37830b98d25cf54"></a>

const int netFieldLen = 9

### pszConnectionFile <a href="#a5d847c4bab1b1a9108829112298d746f" id="a5d847c4bab1b1a9108829112298d746f"></a>

char\\\* pszConnectionFile = NULL


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/files/dir_30aba3d9bf6279a25d84abe4015711f7/dir_f7a957c8f5c8e80b5a8d4b37f193d419/dir_e8da2933844aa72825eccee783cf08f3/ci_a_d_k_8c.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
