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

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

?? mbus.c

?? MPEG-4編解碼的實現(包括MPEG4視音頻編解碼)
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 * FILE:     mbus.c
 * AUTHOR:   Colin Perkins
 * MODIFIED: Orion Hodson
 *           Markus Germeier
 * 
 * Copyright (c) 1997-2000 University College London
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, is permitted provided that the following conditions 
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the Computer Science
 *      Department at University College London
 * 4. Neither the name of the University nor of the Department may be used
 *    to endorse or promote products derived from this software without
 *    specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include "config_unix.h"
#include "config_win32.h"
#include "debug.h"
#include "memory.h"
#include "net_udp.h"
#include "hmac.h"
#include "qfDES.h"
#include "base64.h"
#include "gettimeofday.h"
#include "vsnprintf.h"
#include "mbus.h"
#include "mbus_config.h"
#include "mbus_parser.h"
#include "mbus_addr.h"

#define MBUS_BUF_SIZE	  1500
#define MBUS_ACK_BUF_SIZE 1500
#define MBUS_MAX_ADDR	    10
#define MBUS_MAX_QLEN	    50 /* Number of messages we can queue with mbus_qmsg() */

#define MBUS_MAGIC	0x87654321
#define MBUS_MSG_MAGIC	0x12345678

struct mbus_msg {
	struct mbus_msg	*next;
	struct timeval	 send_time;	/* Time the message was sent, to trigger a retransmit */
	struct timeval	 comp_time;	/* Time the message was composed, the timestamp in the packet header */
	char		*dest;
	int		 reliable;
	int		 complete;	/* Indicates that we've finished adding cmds to this message */
	int		 seqnum;
	int		 retransmit_count;
	int		 message_size;
	int		 num_cmds;
	char		*cmd_list[MBUS_MAX_QLEN];
	char		*arg_list[MBUS_MAX_QLEN];
	uint32_t	 idx_list[MBUS_MAX_QLEN];
	uint32_t	 magic;		/* For debugging... */
};

struct mbus {
	socket_udp	 	 *s;
	char		 	 *addr;				/* Addresses we respond to. 					*/
	int		 	  max_other_addr;
	int		 	  num_other_addr;
	char			**other_addr;			/* Addresses of other entities on the mbus. 			*/
        struct timeval          **other_hello;                  /* Time of last mbus.hello we received from other entities      */
	int		 	  seqnum;
	struct mbus_msg	 	 *cmd_queue;			/* Queue of messages waiting to be sent */
	struct mbus_msg	 	 *waiting_ack;			/* The last reliable message sent, if we have not yet got the ACK */
	char		 	 *hashkey;
	int		 	  hashkeylen;
	char		 	 *encrkey;
	int		 	  encrkeylen;
	struct timeval	 	  last_heartbeat;		/* Last time we sent a heartbeat message */
	struct mbus_config	 *cfg;
	void (*cmd_handler)(char *src, char *cmd, char *arg, void *dat);
	void (*err_handler)(int seqnum, int reason);
	uint32_t		  magic;			/* For debugging...                                             */
	uint32_t		  index;
	uint32_t		  index_sent;
};

static void mbus_validate(struct mbus *m)
{
#ifdef DEBUG
	int	i;

	ASSERT(m->num_other_addr <= m->max_other_addr);
	ASSERT(m->num_other_addr >= 0);
	for (i = 0; i < m->num_other_addr; i++) {
		ASSERT(m->other_addr[i]  != NULL);
		ASSERT(m->other_hello[i] != NULL);
	}
	for (i = m->num_other_addr + 1; i < m->max_other_addr; i++) {
		ASSERT(m->other_addr[i]  == NULL);
		ASSERT(m->other_hello[i] == NULL);
	}
#endif
	ASSERT(m->magic == MBUS_MAGIC);
	xmemchk();
}

static void mbus_msg_validate(struct mbus_msg *m)
{
#ifdef DEBUG
	int	i;

	ASSERT((m->num_cmds < MBUS_MAX_QLEN) && (m->num_cmds >= 0));
	for (i = 0; i < m->num_cmds; i++) {
		ASSERT(m->cmd_list[i] != NULL);
		ASSERT(m->arg_list[i] != NULL);
		if (i > 0) {
			ASSERT(m->idx_list[i] > m->idx_list[i-1]);
		}
	}
	for (i = m->num_cmds + 1; i < MBUS_MAX_QLEN; i++) {
		ASSERT(m->cmd_list[i] == NULL);
		ASSERT(m->arg_list[i] == NULL);
	}	
	ASSERT(m->dest != NULL);
#endif
	ASSERT(m->magic == MBUS_MSG_MAGIC);
}

static void store_other_addr(struct mbus *m, char *a)
{
	/* This takes the address a and ensures it is stored in the   */
	/* m->other_addr field of the mbus structure. The other_addr  */
	/* field should probably be a hash table, but for now we hope */
	/* that there are not too many entities on the mbus, so the   */
	/* list is small.                                             */
	int	i;

	mbus_validate(m);

	for (i = 0; i < m->num_other_addr; i++) {
		if (mbus_addr_match(m->other_addr[i], a)) {
			/* Already in the list... */
			gettimeofday(m->other_hello[i],NULL);
			return;
		}
	}

	if (m->num_other_addr == m->max_other_addr) {
		/* Expand the list... */
		m->max_other_addr *= 2;
		m->other_addr = (char **) xrealloc(m->other_addr, m->max_other_addr * sizeof(char *));
		m->other_hello = (struct timeval **) xrealloc(m->other_hello, m->max_other_addr * sizeof(struct timeval *));
	}
	m->other_hello[m->num_other_addr]=(struct timeval *)xmalloc(sizeof(struct timeval));
	gettimeofday(m->other_hello[m->num_other_addr],NULL);
	m->other_addr[m->num_other_addr++] = xstrdup(a);
}

static void remove_other_addr(struct mbus *m, char *a)
{
	/* Removes the address a from the m->other_addr field of the */
	/* mbus structure.                                           */
	int	i, j;

	mbus_validate(m);

	for (i = 0; i < m->num_other_addr; i++) {
		if (mbus_addr_match(m->other_addr[i], a)) {
			xfree(m->other_addr[i]);
			xfree(m->other_hello[i]);
			for (j = i+1; j < m->num_other_addr; j++) {
				m->other_addr[j-1] = m->other_addr[j];
				m->other_hello[j-1] = m->other_hello[j];
			}
			m->other_addr[m->num_other_addr  - 1] = NULL;
			m->other_hello[m->num_other_addr - 1] = NULL;
			m->num_other_addr--;
		}
	}
}

static void remove_inactiv_other_addr(struct mbus *m, struct timeval t, int interval){
	/* Remove addresses we haven't heard from for about 5 * interval */
	/* Count backwards so it is safe to remove entries               */
	int i;
    
	mbus_validate(m);

	for (i=m->num_other_addr-1; i>=0; i--){
		if ((t.tv_sec-(m->other_hello[i]->tv_sec)) > 5 * interval) {
			debug_msg("remove dead entity (%s)\n", m->other_addr[i]);
			remove_other_addr(m, m->other_addr[i]);
		}
	}
}

int mbus_addr_valid(struct mbus *m, char *addr)
{
	int	i;

	mbus_validate(m);

	for (i = 0; i < m->num_other_addr; i++) {
		if (mbus_addr_match(m->other_addr[i], addr)) {
			return TRUE;
		}
	}
	return FALSE;
}

static int mbus_addr_unique(struct mbus *m, char *addr)
{
	int     i, n = 0;

	mbus_validate(m);

	for (i = 0; i < m->num_other_addr; i++) {
		if (mbus_addr_match(m->other_addr[i], addr)) {
			n++;
		}
	}
	return n==1;
}

/* The mb_* functions are used to build an mbus message up in the */
/* mb_buffer, and to add authentication and encryption before the */
/* message is sent.                                               */
char	 mb_cryptbuf[MBUS_BUF_SIZE];
char	*mb_buffer;
char	*mb_bufpos;

#define MBUS_AUTH_LEN 16

static void mb_header(int seqnum, int ts, char reliable, const char *src, const char *dst, int ackseq)
{
	xmemchk();
	mb_buffer   = (char *) xmalloc(MBUS_BUF_SIZE + 1);
	memset(mb_buffer,   0, MBUS_BUF_SIZE);
	memset(mb_buffer, ' ', MBUS_AUTH_LEN);
	mb_bufpos = mb_buffer + MBUS_AUTH_LEN;
	sprintf(mb_bufpos, "\nmbus/1.0 %6d %9d %c (%s) %s ", seqnum, ts, reliable, src, dst);
	mb_bufpos += 33 + strlen(src) + strlen(dst);
	if (ackseq == -1) {
		sprintf(mb_bufpos, "()\n");
		mb_bufpos += 3;
	} else {
		sprintf(mb_bufpos, "(%6d)\n", ackseq);
		mb_bufpos += 9;
	}
}

static void mb_add_command(const char *cmnd, const char *args)
{
	int offset = strlen(cmnd) + strlen(args) + 5;

	ASSERT((mb_bufpos + offset - mb_buffer) < MBUS_BUF_SIZE);

	sprintf(mb_bufpos, "%s (%s)\n", cmnd, args);
	mb_bufpos += offset - 1; /* The -1 in offset means we're not NUL terminated - fix in mb_send */
}

static void mb_send(struct mbus *m)
{
	char		digest[16];
	int		len;
	unsigned char	initVec[8] = {0,0,0,0,0,0,0,0};
 
	mbus_validate(m);

	*(mb_bufpos++) = '\0';
	ASSERT((mb_bufpos - mb_buffer) < MBUS_BUF_SIZE);
	ASSERT(strlen(mb_buffer) < MBUS_BUF_SIZE);

	/* Pad to a multiple of 8 bytes, so the encryption can work... */
	while (((mb_bufpos - mb_buffer) % 8) != 0) {
		*(mb_bufpos++) = '\0';
	}
	len = mb_bufpos - mb_buffer;
	ASSERT(len < MBUS_BUF_SIZE);
	ASSERT(strlen(mb_buffer) < MBUS_BUF_SIZE);

	xmemchk();
	if (m->hashkey != NULL) {
		/* Authenticate... */
		hmac_md5(mb_buffer + MBUS_AUTH_LEN+1, strlen(mb_buffer) - (MBUS_AUTH_LEN+1), m->hashkey, m->hashkeylen, digest);
		base64encode(digest, 12, mb_buffer, MBUS_AUTH_LEN);
	}
	xmemchk();
	if (m->encrkey != NULL) {
		/* Encrypt... */
		memset(mb_cryptbuf, 0, MBUS_BUF_SIZE);
		memcpy(mb_cryptbuf, mb_buffer, len);
		ASSERT((len % 8) == 0);
		ASSERT(len < MBUS_BUF_SIZE);
		ASSERT(m->encrkeylen == 8);
		xmemchk();
		qfDES_CBC_e(m->encrkey, mb_cryptbuf, len, initVec);
		xmemchk();
		memcpy(mb_buffer, mb_cryptbuf, len);
	}
	xmemchk();
	udp_send(m->s, mb_buffer, len);
	xfree(mb_buffer);
}

static void resend(struct mbus *m, struct mbus_msg *curr) 
{
	/* Don't need to check for buffer overflows: this was done in mbus_send() when */
	/* this message was first transmitted. If it was okay then, it's okay now.     */
	int	 i;

	mbus_validate(m);

	mb_header(curr->seqnum, curr->comp_time.tv_sec, (char)(curr->reliable?'R':'U'), m->addr, curr->dest, -1);
	for (i = 0; i < curr->num_cmds; i++) {
		mb_add_command(curr->cmd_list[i], curr->arg_list[i]);
	}
	mb_send(m);
	curr->retransmit_count++;
}

void mbus_retransmit(struct mbus *m)
{
	struct mbus_msg	*curr = m->waiting_ack;
	struct timeval	time;
	long		diff;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品久久一区二区三区| 亚洲一区二区av在线| 亚洲婷婷在线视频| 日韩免费在线观看| 日韩欧美国产一区在线观看| 日韩欧美激情四射| 久久午夜老司机| 国产色一区二区| 中文字幕欧美国产| 国产精品久久久久久久久久免费看| 日本一区二区视频在线观看| 中文字幕av一区二区三区| 国产精品美女久久久久久久久 | 国产精品毛片无遮挡高清| 国产亚洲人成网站| 亚洲色图制服丝袜| 五月激情综合网| 国产尤物一区二区在线| 成人免费毛片aaaaa**| 中文字幕日韩一区| 亚洲曰韩产成在线| 国产综合色视频| 狠狠色综合色综合网络| 成人综合在线观看| 欧美午夜宅男影院| 久久久久青草大香线综合精品| 国产亚洲精品bt天堂精选| 综合久久国产九一剧情麻豆| 亚洲福利一二三区| 国产成人啪午夜精品网站男同| eeuss鲁一区二区三区| 欧美日韩三级一区二区| 国产日韩欧美精品综合| 亚洲精品国产品国语在线app| 蜜桃视频在线观看一区| 99久久国产免费看| 精品久久久久久久久久久久久久久久久 | 精品乱人伦一区二区三区| 国产精品美女久久久久aⅴ国产馆| 夜夜亚洲天天久久| 精品一区二区在线看| 99精品国产99久久久久久白柏| 91精品国产91久久综合桃花| 中文乱码免费一区二区| 日本va欧美va精品| 色先锋aa成人| 国产午夜精品久久久久久久| 亚洲成人在线观看视频| 成人久久视频在线观看| 欧美一区二区三区婷婷月色| 亚洲人一二三区| 国产91清纯白嫩初高中在线观看| 欧美肥妇bbw| 一区二区三区美女视频| 国产69精品一区二区亚洲孕妇| 日韩欧美一区电影| 五月婷婷综合在线| 日本道免费精品一区二区三区| 中文字幕乱码久久午夜不卡 | 成人黄色片在线观看| 日韩午夜激情av| 亚洲不卡一区二区三区| 91在线视频免费观看| 国产欧美中文在线| 国产尤物一区二区在线| 精品播放一区二区| 青青草国产成人av片免费| 欧美日韩国产成人在线91| 亚洲永久精品大片| 欧美影视一区在线| 亚洲成av人片在线| 欧美色国产精品| 一区二区久久久久| 91成人在线免费观看| 亚洲综合久久av| 欧美日韩精品综合在线| 午夜精品123| 日韩欧美中文字幕一区| 乱一区二区av| 亚洲精品在线观看网站| 国产经典欧美精品| 日韩毛片在线免费观看| 色哟哟一区二区| 色综合久久中文综合久久牛| 精品福利在线导航| 久久九九影视网| 久久精品国产99国产精品| 国产乱码精品一区二区三区av | 亚洲福利国产精品| 欧美性一二三区| 婷婷丁香激情综合| 日韩一级片网址| 国产精品69久久久久水密桃| 欧美国产激情二区三区| 色综合天天综合狠狠| 亚洲综合视频在线观看| 日韩一级精品视频在线观看| 国产精品一二三区| 亚洲另类在线一区| 91精品国产一区二区三区| 国产精品综合二区| 一区二区三区久久| 精品嫩草影院久久| 一本色道久久综合亚洲aⅴ蜜桃 | 精品视频一区二区不卡| 全部av―极品视觉盛宴亚洲| 日本一区二区三级电影在线观看 | 亚洲欧美一区二区三区久本道91| 色婷婷国产精品| 激情深爱一区二区| 亚洲一区二区三区中文字幕在线| 日韩一级片在线播放| 色综合天天综合色综合av| 蜜臀久久99精品久久久画质超高清 | 欧美韩国日本一区| 日本福利一区二区| 国产成人综合亚洲91猫咪| 亚洲一区免费观看| 中文一区一区三区高中清不卡| 欧美中文字幕亚洲一区二区va在线| 韩国毛片一区二区三区| 亚洲综合一区二区| 欧美精彩视频一区二区三区| 51久久夜色精品国产麻豆| 97久久超碰精品国产| 国模少妇一区二区三区| 午夜亚洲国产au精品一区二区| 欧美国产激情二区三区| 精品久久五月天| 日韩一区二区电影在线| 欧美日韩免费在线视频| 91在线精品一区二区| 丰满放荡岳乱妇91ww| 久久精品999| 琪琪久久久久日韩精品| 亚洲午夜一区二区三区| 日韩伦理av电影| 国产精品美女久久久久高潮| 久久久不卡影院| 日韩欧美专区在线| 日韩欧美一区中文| 欧美一区二区视频在线观看| 欧美另类久久久品| 欧美日韩日日摸| 欧美巨大另类极品videosbest| 91成人免费网站| 欧美日韩中文另类| 在线成人高清不卡| 91麻豆精品国产91久久久资源速度| 在线精品亚洲一区二区不卡| 91日韩精品一区| 欧美自拍偷拍午夜视频| 欧美在线观看18| 欧美日韩精品欧美日韩精品| 欧美一区二区三区免费在线看| 欧美精品丝袜久久久中文字幕| 欧美精品日日鲁夜夜添| 91麻豆精品国产91久久久更新时间| 91超碰这里只有精品国产| 欧美大片拔萝卜| 欧美婷婷六月丁香综合色| 欧美三区在线观看| 欧美日韩在线播放三区| 欧美天堂一区二区三区| 337p亚洲精品色噜噜狠狠| 制服丝袜亚洲精品中文字幕| 日韩精品在线网站| 久久精品欧美日韩| 亚洲色图制服诱惑| 日韩高清中文字幕一区| 久久99精品久久久| eeuss国产一区二区三区| 欧美在线免费观看视频| 日韩精品一区二区三区视频播放| 久久精品人人做人人综合 | 久久精品一区二区三区不卡牛牛| 国产亚洲欧洲997久久综合| 国产精品美女视频| 午夜久久电影网| 极品少妇一区二区三区精品视频| 91麻豆精品国产91久久久使用方法 | 精品一区二区综合| 成人午夜免费av| 欧美蜜桃一区二区三区| 久久久精品tv| 五月激情六月综合| 成人不卡免费av| 欧美日韩免费一区二区三区| 国产欧美日韩另类视频免费观看 | 欧美一级片在线观看| 欧美高清在线精品一区| 午夜精品福利在线| 国产91对白在线观看九色| 欧美日韩亚洲综合在线| 国产精品剧情在线亚洲| 美国毛片一区二区| 91福利视频在线| 国产欧美日韩综合精品一区二区| 亚洲chinese男男1069| aaa国产一区|