Asterisk - The Open Source Telephony Project  18.5.0
Functions
max_forwards.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int ast_max_forwards_decrement (struct ast_channel *chan)
 Decrement the max forwards count for a particular channel. More...
 
int ast_max_forwards_get (struct ast_channel *chan)
 Get the current max forwards for a particular channel. More...
 
int ast_max_forwards_reset (struct ast_channel *chan)
 Reset the max forwards on a channel to its starting value. More...
 
int ast_max_forwards_set (struct ast_channel *chan, int starting_count)
 Set the starting max forwards for a particular channel. More...
 

Function Documentation

◆ ast_max_forwards_decrement()

int ast_max_forwards_decrement ( struct ast_channel chan)

Decrement the max forwards count for a particular channel.

If the channel has not had max forwards set on it, then the channel will have the default max forwards set on it and that value will not be decremented.

Precondition
chan is locked

The channel for which the max forwards value should be decremented

Return values
0Success
-1Failure

Definition at line 135 of file max_forwards.c.

References max_forwards::current_count, ast_datastore::data, and max_forwards_datastore_find_or_alloc().

Referenced by __ast_request_and_dial(), ast_ari_channels_dial(), begin_dial_prerun(), call_forward_inherit(), dial_exec_full(), do_forward(), findmeexec(), ring_entry(), and wait_for_answer().

136 {
137  struct ast_datastore *mf_datastore;
138  struct max_forwards *mf;
139 
140  mf_datastore = max_forwards_datastore_find_or_alloc(chan);
141  if (!mf_datastore) {
142  return -1;
143  }
144 
145  mf = mf_datastore->data;
146  --mf->current_count;
147 
148  return 0;
149 }
Structure for a data store object.
Definition: datastore.h:68
Channel datastore data for max forwards.
Definition: max_forwards.c:29
void * data
Definition: datastore.h:70
static struct ast_datastore * max_forwards_datastore_find_or_alloc(struct ast_channel *chan)
Definition: max_forwards.c:93

◆ ast_max_forwards_get()

int ast_max_forwards_get ( struct ast_channel chan)

Get the current max forwards for a particular channel.

If the channel has not had max forwards set on it, then the channel will have the default max forwards set on it and that value will be returned.

Precondition
chan is locked
Parameters
chanThe channel to get the max forwards for.
Returns
The current max forwards count on the channel

Definition at line 121 of file max_forwards.c.

References max_forwards::current_count, ast_datastore::data, and max_forwards_datastore_find_or_alloc().

Referenced by app_exec(), begin_dial_prerun(), dial_exec_full(), func_channel_read(), and queue_exec().

122 {
123  struct ast_datastore *mf_datastore;
124  struct max_forwards *mf;
125 
126  mf_datastore = max_forwards_datastore_find_or_alloc(chan);
127  if (!mf_datastore) {
128  return -1;
129  }
130 
131  mf = mf_datastore->data;
132  return mf->current_count;
133 }
Structure for a data store object.
Definition: datastore.h:68
Channel datastore data for max forwards.
Definition: max_forwards.c:29
void * data
Definition: datastore.h:70
static struct ast_datastore * max_forwards_datastore_find_or_alloc(struct ast_channel *chan)
Definition: max_forwards.c:93

◆ ast_max_forwards_reset()

int ast_max_forwards_reset ( struct ast_channel chan)

Reset the max forwards on a channel to its starting value.

If the channel has not had max forwards set on it, then the channel will have the default max forwards set on it.

Precondition
chan is locked.
Parameters
chanThe channel on which to reset the max forwards count.
Return values
0Success
-1Failure

Definition at line 151 of file max_forwards.c.

References max_forwards::current_count, ast_datastore::data, max_forwards_datastore_find_or_alloc(), and max_forwards::starting_count.

Referenced by pre_bridge_setup().

152 {
153  struct ast_datastore *mf_datastore;
154  struct max_forwards *mf;
155 
156  mf_datastore = max_forwards_datastore_find_or_alloc(chan);
157  if (!mf_datastore) {
158  return -1;
159  }
160 
161  mf = mf_datastore->data;
162  mf->current_count = mf->starting_count;
163 
164  return 0;
165 }
int starting_count
Definition: max_forwards.c:31
Structure for a data store object.
Definition: datastore.h:68
Channel datastore data for max forwards.
Definition: max_forwards.c:29
void * data
Definition: datastore.h:70
static struct ast_datastore * max_forwards_datastore_find_or_alloc(struct ast_channel *chan)
Definition: max_forwards.c:93

◆ ast_max_forwards_set()

int ast_max_forwards_set ( struct ast_channel chan,
int  starting_count 
)

Set the starting max forwards for a particular channel.

Precondition
chan is locked
Parameters
starting_countThe value to set the max forwards to.
chanThe channel on which to set the max forwards.
Return values
0Success
1Failure

Definition at line 105 of file max_forwards.c.

References max_forwards::current_count, ast_datastore::data, max_forwards_datastore_find_or_alloc(), and max_forwards::starting_count.

Referenced by func_channel_write_real().

106 {
107  struct ast_datastore *mf_datastore;
108  struct max_forwards *mf;
109 
110  mf_datastore = max_forwards_datastore_find_or_alloc(chan);
111  if (!mf_datastore) {
112  return -1;
113  }
114 
115  mf = mf_datastore->data;
117 
118  return 0;
119 }
int starting_count
Definition: max_forwards.c:31
Structure for a data store object.
Definition: datastore.h:68
Channel datastore data for max forwards.
Definition: max_forwards.c:29
void * data
Definition: datastore.h:70
static struct ast_datastore * max_forwards_datastore_find_or_alloc(struct ast_channel *chan)
Definition: max_forwards.c:93