亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mtp.c

?? asterisk 的7號信令處理模塊
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* mtp.c - MTP2 and MTP3 functionality. * * Copyright (C) 2005-2006, Sifira A/S. * * Author: Kristian Nielsen <kn@sifira.dk> *         Anders Baekgaard <ab@sifira.dk> *         Anders Baekgaard <ab@dicea.dk> * * This file is part of chan_ss7. * * chan_ss7 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * chan_ss7 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with chan_ss7; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */#include <stdarg.h>#include <stdio.h>#include <errno.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <netdb.h>#include <netinet/in.h>#include <pthread.h>#include <signal.h>#include <sys/poll.h>#include <sys/ioctl.h>#include <sys/time.h>#include "zaptel.h"#define FAST_HDLC_NEED_TABLES#include "fasthdlc.h"#include "config.h"#include "mtp.h"#include "transport.h"#include "lffifo.h"#include "cluster.h"#include "utils.h"#ifdef MTP_STANDALONE#include "aststubs.h"#define cluster_mtp_received(link, event) {}#define cluster_mtp_forward(req) {}#define cluster_receivers_alive(linkset) (0)#else#include "asterisk/options.h"#include "asterisk/logger.h"#include "asterisk/sched.h"#define mtp_sched_add ast_sched_add#define mtp_sched_del ast_sched_del#define mtp_sched_runq ast_sched_runq#define mtp_sched_context_create sched_context_create#define mtp_sched_context_destroy sched_context_destroy#endif/* NOTE: most of this code is run in the MTP thread, and has realtime   constraints because of the need to constantly feed/read the   signalling link with low latence and no frame drop.   The thread runs with high realtime priority, and any kind of   locking should generally be avoided. This includes ast_log() (use   fifo_log() instead), and malloc()/free()!*//* For testing failover mechanism */int testfailover = 0;/* #define DROP_PACKETS_PCT 66 *//* #define DO_RAW_DUMPS *//* Scheduling context for MTP2. *//* This should ONLY be used by the MTP2 thread, otherwise the locking done   by the sched operations may fatally delay the MTP2 thread because of   priority inversion. */static struct sched_context *mtp2_sched = NULL;/* Set true to ask mtp thread to stop */static int stop_mtp_thread;static int receivepipe[2];/* Lock-free FIFOs for communication with the MTP thread.   The sendbuf is polled by the MTP thread whenever the link is ready to   transmit data (every 2msec). It contains struct mtp_req entries for   the higher level protocol layers (currently only ISUP).   The receivebuf has an associated event pipe, and the MTP thread do   non-blocking dummy writes to it whenever blocks are put in the buffer.   The SS7 monitor thread can then wait for new data in poll(). The   receivebuf contains struct mtp_event entries.   The controlbuf is polled by the MTP thread, it contains struct mtp_req   entries for control purposes only. */struct lffifo *sendbuf[MAX_LINKSETS];struct lffifo *receivebuf;struct lffifo *controlbuf;typedef struct mtp2_state {  /* MTP2 stuff. */  enum {    /* Link is stopped by management command, will not go up until       started explicitly. */    MTP2_DOWN,    /* Initial alignment has started, link is transmitting 'O', but no 'O',       'N', or 'E' has been received. */    MTP2_NOT_ALIGNED,    /* 'O' has been received, 'N' or 'E' is transmitted. */    MTP2_ALIGNED,    /* 'N' or 'E' is transmitted and received. Runs for the duration of T4 to       check that the link is of sufficient quality in terms of error rate. */    MTP2_PROVING,    /* Local T4 expired, and we are sending FISU, but remote is still       proving. */    MTP2_READY,    /* The link is active sending and receiving FISU and MSU. */    MTP2_INSERVICE,  } state;  /* Counts of raw bytes read and written, used to timestamp raw dumps.     Make them double to avoid overflow for quite a while. */  double readcount, writecount;  /* Sequence numbers and indicator bits to be sent in signalling units. */  int send_fib;  int send_bsn, send_bib;  /* Send initial SLTM? */  int send_sltm;  /* Timeslot for signalling channel */  int schannel;  int slinkno;  struct link* link;  int sls;  int subservice;  /* logical link name */  char* name;  /* Open fd for signalling link zaptel device. */  int fd;  /* Receive buffer. */  unsigned char rx_buf[272 + 7];  int rx_len;  unsigned short rx_crc;  /* Transmit buffer. */  unsigned char tx_buffer[272 + 7 + 5];  int tx_len;  int tx_sofar;  int tx_do_crc;                /* Flag used to handle writing CRC bytes */  unsigned short tx_crc;  /* Zaptel transmit buffer. */  unsigned char zap_buf[ZAP_BUF_SIZE];  int zap_buf_full;  /* HDLC encoding and decoding state. */  struct fasthdlc_state h_rx;  struct fasthdlc_state h_tx;  /* Last few raw bytes received, for debugging link errors. */  unsigned char backbuf[36];  int backbuf_idx;  /* Retransmit buffer. */  struct { int len; unsigned char buf[MTP_MAX_PCK_SIZE]; } retrans_buf[128];  /* Retransmit counter; if this is != -1, it means that retransmission is     taking place, with this being the next sequence number to retransmit. */  int retrans_seq;  /* Last sequence number ACK'ed by peer. */  int retrans_last_acked;  /* Last sequence number sent to peer. */  int retrans_last_sent;  /* Counter for signal unit/alignment error rate monitors (Q.703 (10)). */  int error_rate_mon;  /* Counters matching the D and N values of the error rate monitors. */  int emon_ncount, emon_dcount;  /* Counter for bad BSN */  int bsn_errors;  /* Q.703 timer T1 "alignment ready" (waiting for peer to end initial     alignment after we are done). */  int mtp2_t1;  /* Q.703 timer T2 "not aligned" (waiting to receive O, E, or N after sending     O). */  int mtp2_t2;  /* Q.703 timer T3 "aligned" (waiting to receive E or N after sending E or     N). */  int mtp2_t3;  /* Q.703 timer T4 "proving period" - proving time before ending own initial     alignment. */  int mtp2_t4;  /* Q.703 timer T7 "excessive delay of acknowledgement" . */  int mtp2_t7;  /* Set true when SLTA is received and User Parts (ie. ISUP) is notified that     the link is now in service. */  int level4_up;  /* Hm, the rest is actually MTP3 state. Move to other structure, or     rename this structure. */  int sltm_t1;                  /* Timer T1 for SLTM (Q.707) */  int sltm_t2;                  /* Timer T2 for SLTM (Q.707) */  int sltm_tries;               /* For SLTM retry (Q.707 (2.2)) */  /* Q.704 timer T17, "initial alignment restart delay". */  int mtp3_t17;} mtp2_t;/* ToDo: Support more than one signalling link ... *//* ToDo: Need real initialization, that doesn't depend on linker. */mtp2_t mtp2_state[MAX_SCHANNELS];/* Get the next sequence number, modulo 128. */#define MTP_NEXT_SEQ(x) (((x) + 1) % 128)/* Forward declaration, needed because of cyclic reference graph. */static mtp2_t* find_alternative_slink(mtp2_t* m);static void start_initial_alignment(mtp2_t *m, char* reason);static void abort_initial_alignment(mtp2_t *m);static void mtp2_cleanup(mtp2_t *m);static void mtp2_queue_msu(mtp2_t *m, int sio, unsigned char *sif, int len);static void deliver_l4(mtp2_t *m, unsigned char *sif, int len, int sio);static void l4up(mtp2_t* m);static void l4down(mtp2_t* m);static void t7_stop(mtp2_t *m);static void fifo_log(mtp2_t *m, int level, const char *file, int line,		     const char *function, const char *format, ...)     __attribute__ ((format (printf, 6, 7)));static void process_msu(struct mtp2_state* m, unsigned char* buf, int len);int mtp2_slink_inservice(int ix) {  struct mtp2_state* m = &mtp2_state[ix];  return m->state == MTP2_INSERVICE;}int mtp_cmd_linkstatus(char* buff, int slinkno){  char* format = "linkset %s, link %s, schannel %d, sls %d, %s, rx: %d, tx: %d/%d, sentseq/lastack: %d/%d, total %9llu, %9llu\n";  char* s = "?";  if (slinkno >= this_host->n_schannels)    return -1;  /* Todo: when more than one signalling link supported, check against that */  struct mtp2_state* m = &mtp2_state[slinkno];  switch (m->state) {  case MTP2_DOWN: s = "DOWN"; break;  case MTP2_NOT_ALIGNED: s = "NOT_ALIGNED"; break;  case MTP2_ALIGNED: s = "ALIGNED"; break;  case MTP2_PROVING: s = "PROVING"; break;  case MTP2_READY: s = "READY"; break;  case MTP2_INSERVICE: s = "INSERVICE"; break;  default: s = "UNKNOWN";  }  sprintf(buff, format, m->link->linkset->name, m->link->name, m->schannel, m->sls, s, m->rx_len, m->tx_sofar, m->tx_len, m->retrans_last_sent, m->retrans_last_acked, (long long) m->readcount, (long long) m->writecount);  return 0;}int mtp_cmd_data(int fd, int argc, char *argv[]){  unsigned char buf[MTP_EVENT_MAX_SIZE];  int len = 0;  int i;  mtp2_t* m = &mtp2_state[0];  for (i = 3; i < argc; i++) {    char* p = argv[i];    while (*p) {      char b[3];      unsigned int v;      if (*p == ' ') {	p++;	continue;      }      b[0] = *p++;      b[1] = *p++;      b[2] = 0;      sscanf(b, "%x", &v);      buf[len++] = v;    }  }  mtp2_queue_msu(m, 3, buf, len);  deliver_l4(m, &buf[0], len, MTP_EVENT_SCCP);  return 0;}static inline int peerpc(mtp2_t* m){  return m->link->linkset->dpc;}static mtp2_t* findtargetslink(mtp2_t *originalm, int sls){  int i;  struct link* link = originalm->link;  struct mtp2_state* bestm = NULL;  for (i = 0; i < this_host->n_schannels; i++) {    struct mtp2_state* m = &mtp2_state[i];    struct link* slink = m->link;    if (m->sls == sls) {      if (link->linkset == slink->linkset) {	fifo_log(m, LOG_DEBUG, "Target slink %s %d -> %s\n", originalm->name, sls, m->name);        return m;      }      if (is_combined_linkset(link->linkset, slink->linkset))        bestm = m;    }  }  fifo_log(originalm, LOG_DEBUG, "Target slink %s %d -> %s\n", originalm->name, sls, bestm ? bestm->name : "(none)");  return bestm;}static void mtp_put(mtp2_t *m, struct mtp_event *event) {  static int log_safe_count = 0;  int res;  res = lffifo_put(receivebuf, (unsigned char *)event,                   sizeof(*event) + event->len);  if(res) {    /* Can't fifo_log() here, or we would get an infinite loop. */    /* Still, avoid excessive logging if the other thread gets long behind. */    if(log_safe_count == 0) {      ast_log(LOG_NOTICE, "Full MTP receivebuf, event lost, type=%d.\n", event->typ);      log_safe_count = 2000;    }  } else {    /* Wake up the other end. */    write(receivepipe[1], "\0", 1);  }  if ((event->typ == MTP_EVENT_ISUP) || (event->typ == MTP_EVENT_STATUS)) {    cluster_mtp_received(m ? m->link : NULL, event);  }  if(log_safe_count > 0) {    log_safe_count--;  }}/* Use this instead of ast_log() in the MTP thread, to avoid locking   issues interupting the link timing.   Note that LOG_WHATEVER includes all of (level, file, line, function), thanks   to #define trickery in asterisk/logger.h! *//* Grmble... stupid GCC allows the __attribute__ only in a   declaration, not definition. */static void fifo_log(mtp2_t *m, int level, const char *file, int line,		     const char *function, const char *format, ...){  va_list arg;  unsigned char buf[MTP_EVENT_MAX_SIZE];  struct mtp_event *event = (struct mtp_event *)buf;  event->typ = MTP_EVENT_LOG;  event->log.level = level;  event->log.file = file;  event->log.line = line;  event->log.function = function;  va_start(arg, format);  vsnprintf((char*)event->buf, sizeof(buf) - sizeof(struct mtp_event), format, arg);  va_end(arg);  event->len = strlen((char*)event->buf) + 1;  mtp_put(m, event);}static void log_frame(mtp2_t *m, int out, unsigned char *buf, int len) {  unsigned char ebuf[MTP_EVENT_MAX_SIZE];  struct mtp_event *event = (struct mtp_event *)ebuf;  event->typ = MTP_EVENT_DUMP;  event->dump.out = out;  gettimeofday(&event->dump.stamp, NULL);  event->dump.slinkno = m->slinkno;  if(sizeof(struct mtp_event) + len > MTP_MAX_PCK_SIZE) {    len = MTP_MAX_PCK_SIZE - sizeof(struct mtp_event);  }  event->len = len;  memcpy(event->buf, buf, len);  mtp_put(m, event);}#ifdef DO_RAW_DUMPSstatic void mtp2_dump_raw(mtp2_t *m, unsigned char *buf, int len, int out) {  unsigned char ebuf[MTP_EVENT_MAX_SIZE];  struct mtp_event *event = (struct mtp_event *)ebuf;  event->typ = MTP_EVENT_RAWDUMP;  event->rawdump.out = out;  if(sizeof(struct mtp_event) + len > MTP_MAX_PCK_SIZE) {    len = MTP_MAX_PCK_SIZE - sizeof(struct mtp_event);  }  event->len = len;  memcpy(event->buf, buf, len);  mtp_put(m, event);}#endifstatic int t17_timeout(void *data) {  mtp2_t *m = data;  fifo_log(m, LOG_DEBUG, "link %s\n", m->name);  m->mtp3_t17 = -1;  start_initial_alignment(m, "t17_timeout");  return 0;                     /* Do not re-schedule */}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人自拍高清视频在线免费播放| 日本一区中文字幕| 亚洲福利视频一区二区| 免费在线观看一区二区三区| thepron国产精品| 91精品黄色片免费大全| 国产精品国产自产拍高清av王其| 亚洲成人av资源| 成人美女视频在线看| 欧美精品在欧美一区二区少妇| 欧美激情一区不卡| 美女视频黄免费的久久| 色94色欧美sute亚洲13| 久久久久久久久久久久电影| 五月天视频一区| www.欧美.com| 久久久亚洲精品一区二区三区| 亚洲国产成人av| 91亚洲精品久久久蜜桃| 国产亚洲欧美日韩俺去了| 免费人成在线不卡| 欧美性大战久久| 亚洲欧美成aⅴ人在线观看| 国产成人精品三级麻豆| 久久综合色综合88| 日本少妇一区二区| 欧美精品久久一区| 亚洲影视资源网| 色94色欧美sute亚洲线路一久| 国产精品女主播av| 国产传媒久久文化传媒| 精品国产3级a| 韩国av一区二区三区在线观看| 亚洲精品在线免费播放| 日本不卡免费在线视频| 欧美日韩国产一级| 视频一区二区三区中文字幕| 欧美伊人久久久久久久久影院| 亚洲男女一区二区三区| 日本电影亚洲天堂一区| 亚洲制服丝袜av| 欧美伊人精品成人久久综合97 | 在线不卡中文字幕| 亚洲成a天堂v人片| 欧美精品tushy高清| 日韩电影在线免费看| 91精品国产一区二区三区蜜臀| 日韩av电影天堂| 日韩欧美一二三| 国产成人无遮挡在线视频| 国产肉丝袜一区二区| 不卡的电影网站| 亚洲影视在线观看| 欧美一级二级在线观看| 国产剧情一区在线| 中文字幕免费观看一区| 色婷婷综合久久久中文一区二区| 亚洲一区二区三区四区在线| 欧美日精品一区视频| 看电影不卡的网站| 欧美极品少妇xxxxⅹ高跟鞋| 91丨porny丨蝌蚪视频| 亚洲狠狠爱一区二区三区| 91精品国产色综合久久不卡电影| 狠狠色丁香婷综合久久| 亚洲视频一二三| 91精品综合久久久久久| 国产精品69毛片高清亚洲| 亚洲欧美中日韩| 欧美精品一卡二卡| 丁香六月综合激情| 亚洲成a人在线观看| 国产亚洲欧美日韩日本| 精品国产乱码久久久久久图片| 岛国精品一区二区| 首页综合国产亚洲丝袜| 国产精品美女久久久久久2018| 欧美唯美清纯偷拍| 国产不卡在线播放| 亚洲第一会所有码转帖| 久久精品夜色噜噜亚洲aⅴ| 在线视频一区二区三区| 国产麻豆9l精品三级站| 一区二区三区日韩精品| 久久精品欧美日韩| 777xxx欧美| a美女胸又www黄视频久久| 欧美a级一区二区| 亚洲精品国产无套在线观| 精品国产91九色蝌蚪| 欧美日韩国产小视频在线观看| 国产成人精品亚洲日本在线桃色| 五月婷婷久久丁香| 亚洲色图一区二区| 精品欧美一区二区三区精品久久| 一本大道久久a久久综合婷婷| 国产在线播放一区二区三区| 午夜久久久久久| 亚洲天天做日日做天天谢日日欢 | 欧美日本一道本| 色综合咪咪久久| 丰满白嫩尤物一区二区| 看电影不卡的网站| 日韩黄色片在线观看| 亚洲欧洲三级电影| 欧美激情一区二区三区在线| 日韩一区二区三区电影 | 国产精品一区一区三区| 热久久免费视频| 五月天亚洲婷婷| 亚洲午夜久久久久久久久电影网 | 国产精品美女久久久久aⅴ| 精品国产91久久久久久久妲己| 国产天堂亚洲国产碰碰| 日韩欧美国产电影| 日韩欧美一二三四区| 欧美一卡二卡在线观看| 在线不卡中文字幕播放| 欧美美女激情18p| 欧美日本不卡视频| 欧美日韩高清一区二区| 欧美综合亚洲图片综合区| 91女人视频在线观看| 91美女在线看| 色婷婷久久综合| 欧美三级在线看| 欧美亚洲综合色| 欧美精品在线观看播放| 欧美日韩成人高清| 91麻豆精品国产91久久久久久久久 | 久久久久久久国产精品影院| 精品久久久久久久久久久院品网| 欧美一级夜夜爽| 精品精品国产高清一毛片一天堂| 日韩欧美的一区二区| 欧美大片国产精品| 久久亚洲精华国产精华液 | 欧美一区二区黄| 日韩欧美精品在线视频| 精品国产一区二区三区不卡| 亚洲精品一区二区三区精华液 | 欧美日本一区二区三区| 欧美一个色资源| 国产亚洲精品精华液| 中文字幕一区二区三区乱码在线 | 色综合久久久久综合| 欧美性极品少妇| 日韩精品一区二区三区老鸭窝| 久久亚洲二区三区| 中文字幕制服丝袜一区二区三区 | 亚洲国产人成综合网站| 丁香六月综合激情| 欧美无乱码久久久免费午夜一区| 91精品国产乱| 国产欧美一区二区精品婷婷| 亚洲色图第一区| 视频一区欧美日韩| 国产精品资源站在线| 在线亚洲+欧美+日本专区| 91精品久久久久久久91蜜桃| 国产午夜精品理论片a级大结局 | 蜜臀av一级做a爰片久久| 国产一区二区日韩精品| 色老头久久综合| 日韩免费视频一区| 中文字幕一区二区三区精华液| 无码av免费一区二区三区试看| 精品一区二区免费视频| 91在线观看免费视频| 欧美一区二区三区视频免费 | 色天天综合色天天久久| 日韩一区二区三| 亚洲另类中文字| 国产成人av一区| 91超碰这里只有精品国产| 中文无字幕一区二区三区| 日韩中文字幕麻豆| 91网址在线看| 国产性做久久久久久| 天天色综合天天| 91在线视频免费观看| 久久影院电视剧免费观看| 亚洲高清在线视频| 99免费精品在线| 精品少妇一区二区三区日产乱码| 亚洲一区二区欧美| 成人av在线电影| 久久久久久久久久电影| 午夜精品视频在线观看| 91论坛在线播放| 久久免费视频色| 久久99精品久久久| 欧美巨大另类极品videosbest | 欧美日韩国产系列| 国产精品传媒入口麻豆| 懂色av噜噜一区二区三区av| 精品免费99久久| 日韩va亚洲va欧美va久久| 欧美亚洲国产一区二区三区| 国产精品乱码一区二区三区软件 |