spandsp 0.0.6

v42.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <inttypes.h>`
`#include <string.h>`
`#include <errno.h>`
`#include <fcntl.h>`
`#include <ctype.h>`
`#include <assert.h>`
`#include "spandsp/telephony.h"`
`#include "spandsp/logging.h"`
`#include "spandsp/bit_operations.h"`
`#include "spandsp/async.h"`
`#include "spandsp/hdlc.h"`
`#include "spandsp/v42.h"`
`#include "spandsp/private/logging.h"`
`#include "spandsp/private/hdlc.h"`
`#include "spandsp/private/v42.h"`

## Macros
#define | FALSE 0
#define | TRUE (!FALSE)
#define | T_400 750
#define | T_401 1000
#define | T_402 1000
#define | T_403 10000
#define | LAPM_DLCI_DTE_TO_DTE 0
#define | LAPM_DLCI_LAYER2_MANAGEMENT 63
#define | elements(a)
#define | LAPM_FRAMETYPE_MASK 0x03
#define | LAPM_S_PF 0x01
#define | LAPM_U_PF 0x10
#define | FI_GENERAL 0x82
#define | GI_PARAM_NEGOTIATION 0x80
#define | GI_PRIVATE_NEGOTIATION 0xF0
#define | GI_USER_DATA 0xFF
#define | LAPM_DLCI_DTE_TO_DTE 0
#define | LAPM_DLCI_LAYER2_MANAGEMENT 63

## Enumerations
enum | { LAPM_FRAMETYPE_I = 0x00 , LAPM_FRAMETYPE_I_ALT = 0x02 , LAPM_FRAMETYPE_S = 0x01 , LAPM_FRAMETYPE_U = 0x03 }
enum | { LAPM_S_RR = 0x00 , LAPM_S_RNR = 0x04 , LAPM_S_REJ = 0x08 , LAPM_S_SREJ = 0x0C }
enum | { LAPM_U_UI = 0x00 , LAPM_U_DM = 0x0C , LAPM_U_DISC = 0x40 , LAPM_U_UA = 0x60 , LAPM_U_SABME = 0x6C , LAPM_U_FRMR = 0x84 , LAPM_U_XID = 0xAC , LAPM_U_TEST = 0xE0 }
enum | { PI_HDLC_OPTIONAL_FUNCTIONS = 0x03 , PI_TX_INFO_MAXSIZE = 0x05 , PI_RX_INFO_MAXSIZE = 0x06 , PI_TX_WINDOW_SIZE = 0x07 , PI_RX_WINDOW_SIZE = 0x08 }
enum | { PI_PARAMETER_SET_ID = 0x00 , PI_V42BIS_COMPRESSION_REQUEST = 0x01 , PI_V42BIS_NUM_CODEWORDS = 0x02 , PI_V42BIS_MAX_STRING_LENGTH = 0x03 }
enum | { LAPM_DETECT = 0 , LAPM_IDLE = 1 , LAPM_ESTABLISH = 2 , LAPM_DATA = 3 , LAPM_RELEASE = 4 , LAPM_SIGNAL = 5 , LAPM_SETPARM = 6 , LAPM_TEST = 7 , LAPM_V42_UNSUPPORTED = 8 }

## Functions
const char * | lapm_status_to_str (int status)
void | lapm_receive (void *user_data, const uint8_t *frame, int len, int ok)
void | v42_stop (v42_state_t *ss)
void | v42_rx_bit (void *user_data, int bit)
int | v42_tx_bit (void *user_data)
int | v42_set_local_busy_status (v42_state_t *s, int busy)
int | v42_get_far_busy_status (v42_state_t *s)
void | v42_set_status_callback (v42_state_t *s, modem_status_func_t status_handler, void *user_data)
void | v42_restart (v42_state_t *s)
v42_state_t * | v42_init (v42_state_t *ss, int calling_party, int detect, get_msg_func_t iframe_get, put_msg_func_t iframe_put, void *user_data)
int | v42_release (v42_state_t *s)
int | v42_free (v42_state_t *s)

## Macro Definition Documentation

## ◆ elements

#define elements | ( |  | a | ) |

Value:
(sizeof(a)/sizeof((a)[0]))

## Function Documentation

## ◆ v42_free()

int v42_free | ( | v42_state_t * | s | ) |

Free a V.42 context.

Parameters

  s | The V.42 context.

Returns
  0 if OK

References v42_release().

## ◆ v42_get_far_busy_status()

int v42_get_far_busy_status | ( | v42_state_t * | s | ) |

Get the busy status of the far end of a V.42 context.

Parameters

  s | The V.42 context.

Returns
  The far end busy status.

## ◆ v42_init()

v42_state_t * v42_init | ( | v42_state_t * | s,
|  | int | calling_party,
|  | int | detect,
|  | get_msg_func_t | iframe_get,
|  | put_msg_func_t | iframe_put,
|  | void * | user_data )

Initialise a V.42 context.

Parameters

  s | The V.42 context.
  calling_party | TRUE if caller mode, else answerer mode.
  detect | TRUE to perform the V.42 detection, else go straight into LAP.M
  iframe_get | A callback function to handle received frames of data.
  iframe_put | A callback function to get frames of data for transmission.
  user_data | An opaque pointer passed to the frame handler routines.

Returns
  ???

References v42_state_s::calling_party, v42_state_s::detect, v42_state_s::logging, and v42_state_s::tx_bit_rate.

## ◆ v42_release()

int v42_release | ( | v42_state_t * | s | ) |

Release a V.42 context.

Parameters

  s | The V.42 context.

Returns
  0 if OK

Referenced by v42_free().

## ◆ v42_restart()

void v42_restart | ( | v42_state_t * | s | ) |

Restart a V.42 context.

Parameters

  s | The V.42 context.

References v42_state_s::detect, hdlc_rx_init(), hdlc_tx_init(), and v42_negotiation_t::rx_negotiation_step.

## ◆ v42_set_local_busy_status()

int v42_set_local_busy_status | ( | v42_state_t * | s,
|  | int | busy )

Set the busy status of the local end of a V.42 context.

Parameters

  s | The V.42 context.
  busy | The new local end busy status.

Returns
  The previous local end busy status.