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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ipe.c

?? udp-cast!可以用multicasting的方式把檔案傳送到一個群組
?? C
字號:
#include <stdio.h>#include <netinet/in.h>#include <stdlib.h>#include <pthread.h>#include <string.h>#include <net/if.h>#include <unistd.h>#include <arpa/inet.h>#include "../udpcast/rateGovernor.h"/** * Example of a rate governor. * Rate governors are dynamically loadable modules that allow to control the * speed at which udpcast transfers data. * * In order to do this, udpcast calls the governor's wait function before * transmitting a packet. The governor may then wait some time until it * returns, thusly controling the transmission speed. * * This example rate governor acts upon the traffic control packets that a * "Logic Innovations IP Encapsulator 3000" sends *//** * One route. We assume here that all fields are in network byte order */struct route {  in_addr_t ip_address;  in_addr_t ip_mask;  uint32_t buffer_length; /* how many bytes IPE buffer can hold */  uint32_t buffer_level;  /* current occupation level of IPE buffer */};/** * Entire traffic control packet. We assume here that all fields are in * network byte order */struct ipe_packet {  int total_routes;  int total_length;  struct route route[4096];};struct ipe {  struct sockaddr_in recv; /* address to which the traffic control packets			    * are sent */  char *interface; /* name of network interface where traffic control		      packets will be received */  int fd; /* file descriptor on which the traffic control packets are	     received */  int maxFillLevel; /* percent of maximum buffer fill level */  int havePacket; /* have we at least received one packet? */  pthread_t thread; /* thread receiving the multicasted announcements */  pthread_mutex_t mutex; /* mutex protecting the traffic control packets */  pthread_cond_t cond; /* this condition will be signal when the traffic			  control packet has been updated */  struct ipe_packet packet[2]; /* array of two traffic control packets. One				* is active, whereas the other is ready to				* receive new data. After having received and				* validated a new packet, the receiving thread				* will switch the roles of both slots */  int activePacket; /* which one of the 2 packets is currently active? */  struct route *lastMatchedRoute; /* pointer to last matched route				     (performance optimization) */};/** * answers whether the given route matches the IP */static int routeMatches(struct route *route, in_addr_t ip){  return (route->ip_address & route->ip_mask) == (ip & route->ip_mask);}/** * Find route to ip in packet. Returns NULL if none found */static struct route *findRouteInPacket(struct ipe_packet *packet, in_addr_t ip){  int i=0;  for(i=0; i< packet->total_routes; i++)    if(routeMatches(&packet->route[i], ip))      return &packet->route[i];  return NULL;}/** * Find route to given IP address in packet. First check whether cached route * matches, and if not, search through last received packet */static struct route *findRoute(struct ipe *ipe, in_addr_t ip){  if(ipe->lastMatchedRoute && routeMatches(ipe->lastMatchedRoute, ip))    return ipe->lastMatchedRoute;  ipe->lastMatchedRoute = findRouteInPacket(&ipe->packet[ipe->activePacket],ip);  return ipe->lastMatchedRoute;}/** * Thread listening for traffic control packets */static void *run(void *p){  struct ipe *me = (struct ipe *) p;  while(1) {    int n;    struct ipe_packet *packet = &me->packet[1-me->activePacket];    n = recv(me->fd, packet, sizeof(*packet), 0);    if(n < 0 ) {      perror("receive traffic control");      continue;    }    /* Quick sanity check of packet...*/    if(n < 8) {      fprintf(stderr, "Incomplete traffic control header\n");      continue;    }    if(n < ntohl(packet->total_routes) * 16) {      fprintf(stderr, "Incomplete traffic control data\n");      continue;    }    /* packet is ok, activate it */    pthread_mutex_lock(&me->mutex);    me->activePacket = 1 - me->activePacket;    me->havePacket = 1;    me->lastMatchedRoute = NULL;    pthread_cond_signal(&me->cond);    pthread_mutex_unlock(&me->mutex);   }}/** * Allocate and initialize new instance private data structure for this * rate governor */static void *ipe_initialize(void){  struct ipe *me;  me = calloc(sizeof(struct ipe),1);  me->maxFillLevel=80;    pthread_mutex_init(&me->mutex, NULL);  pthread_cond_init(&me->cond, NULL);  return me;}/** * Set property. All properties are passed as strings, and should be * converted to the appropriate type by this rate governor * * In this example, the following properties are supported *  - ip	the multicast ip address which receives the traffic control *		packets *  - port	the UDP port which receives the traffic control packets *  - if	the network interface (default eth0) which receives the *		traffic control packets *  - maxFillLevel stop transmitting packets if buffers on IPE are fuller than *		this level (expressed in percent of available buffer size). *		Default is 80 */static void ipe_setProp(void *p, const char *key, const char *value){  struct ipe *me = (struct ipe *) p;  if(!strcmp("ip", key)) {    inet_aton(value, &me->recv.sin_addr);  } else if(!strcmp("port", key)) {    char *eptr;    me->recv.sin_port = htons(strtoul(value,&eptr, 0));    if(*eptr)      fprintf(stderr, "Bad port %s\n", value);  } else if(!strcmp("if", key)) {    me->interface = strdup(value);  } else if(!strcmp("maxFillLevel", key)) {    char *eptr;    me->maxFillLevel = strtoul(value, &eptr, 0);    if(*eptr)      fprintf(stderr, "Bad port %s\n", value);  } else {    fprintf(stderr, "Unknown parameter %s=%s\n", key, value);  }}/** * This method will be called after all properties have been set. * In this method, the rate governor knows its configuration, and may start * with *  - opening sockets and other communication channels *  - communicate with remote servers *  - start background threads */static void ipe_endConfig(void *data){  struct ipe *me = (struct ipe *) data;  char *interface;  int sock;  struct ip_mreqn mreq; /* used for subscribing to multicast */  int r; /* generic return value */  sock = socket(PF_INET, SOCK_DGRAM, 0);  if(socket < 0) {    perror("socket");    return;  }  if(bind(sock, (struct sockaddr*) &me->recv, sizeof(struct sockaddr_in)) < 0) {    perror("bind");    return;  }  if(me->interface)    interface = me->interface;  else    interface = "eth0";  mreq.imr_ifindex = if_nametoindex(interface);  mreq.imr_address.s_addr = 0;  mreq.imr_multiaddr = me->recv.sin_addr;  r = setsockopt(sock, SOL_IP, IP_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq));  if(r < 0) {    perror("add membership error");    /* consider this error non fatal, so that it still works with unicast     * addresses */  }  me->fd = sock;  pthread_create(&me->thread, NULL, run, me);}/** * This method is called by udpcast just before it transmits a packet. * The rate governor may uses this to wait until the ougoing channel is * ready to receive more data * Parameters: *  p	  the rate governor private data *  fd    file descriptor to which data is going to be sent *  ip    ip address to which data is going to be sent *  bytes bytes number of bytes which will be sent */static void ipe_wait(void *p, int fd, in_addr_t ip, long bytes){  struct ipe *me = (struct ipe *) p;  struct route *route;  int level=0;  int length=0;  pthread_mutex_lock(&me->mutex);  while(1) {    if(me->havePacket) {      route = findRoute(me, ip);      if(route == NULL)	/* no route found => no ratelimit... */	break;      level = ntohl(route->buffer_level);      length = ntohl(route->buffer_length);      if(bytes < length * me->maxFillLevel / 100  - level)	/* enough space left for new packet */	break;    }    pthread_cond_wait(&me->cond, &me->mutex);  }  if(route) {    /* Account packet that will be sent */    level += bytes;    route->buffer_level = htonl(level);  }  pthread_mutex_unlock(&me->mutex);}/** * Finalize is called just before program exits. This can be used to *  - signal remote servers that this sender is going away *  - close filedescriptors/communications channels *  - stop background threads *  - deallocate data structures */static void ipe_shutdown(void *p) {  struct ipe *me = (struct ipe *) p;  void *v;  pthread_cancel(me->thread);  pthread_join(me->thread, &v);  close(me->fd);  if(me->interface)    free(me->interface);}/** * Table of methods, to be picket up by udpcast */struct rateGovernor_t governor = {  ipe_initialize,  ipe_setProp,  ipe_endConfig,  ipe_wait,  ipe_shutdown,};

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品久久久久久久多人混战 | 成人白浆超碰人人人人| 99久久精品免费看国产| 欧美日韩你懂得| 国产欧美日韩卡一| 男女性色大片免费观看一区二区 | 一区二区三区在线免费观看 | 精品奇米国产一区二区三区| 亚洲私人黄色宅男| 精品亚洲国产成人av制服丝袜| 成人黄色在线看| 日韩欧美www| 亚洲成人自拍网| 99精品国产热久久91蜜凸| 精品少妇一区二区三区免费观看| 亚洲精品乱码久久久久久黑人| 国产精品主播直播| 911精品产国品一二三产区| 亚洲另类春色校园小说| 国产69精品久久久久毛片 | 国产乱码字幕精品高清av| 3d动漫精品啪啪一区二区竹菊| 亚洲精品日韩综合观看成人91| 国产成人综合在线观看| 精品电影一区二区三区| 天天综合色天天| 欧美日韩国产三级| 亚洲第一成年网| 欧美性极品少妇| 亚洲影院在线观看| 欧美视频在线观看一区二区| 亚洲精品高清在线| 日本高清免费不卡视频| 亚洲女子a中天字幕| 91日韩在线专区| 亚洲欧洲av在线| 91色视频在线| 亚洲一区国产视频| 欧美日韩另类国产亚洲欧美一级| 亚洲综合色噜噜狠狠| 欧美视频在线一区| 青青草97国产精品免费观看 | 国产精品一区二区在线看| 精品福利在线导航| 国产精品一品二品| 国产精品免费看片| 一道本成人在线| 天堂成人免费av电影一区| 5566中文字幕一区二区电影| 日本sm残虐另类| 久久看人人爽人人| 91视频.com| 琪琪一区二区三区| 久久精品夜色噜噜亚洲aⅴ| 成人免费毛片app| 亚洲欧美一区二区三区久本道91| 色婷婷精品大在线视频 | 狠狠久久亚洲欧美| 欧美韩日一区二区三区四区| 91亚洲精品久久久蜜桃| 亚洲国产精品自拍| 精品成人免费观看| 99re8在线精品视频免费播放| 亚洲制服丝袜在线| 日韩美一区二区三区| 成人免费的视频| 亚洲成av人影院| 久久久久久久综合日本| 色综合久久久久网| 久久99国产精品久久99| 亚洲精品视频免费看| 日韩精品一区二区三区在线观看 | 亚洲手机成人高清视频| 欧美一区二区三区不卡| 成人av一区二区三区| 日本中文字幕一区二区视频| 国产精品久久久久影院亚瑟| 在线不卡免费欧美| 不卡的电影网站| 蜜臀精品一区二区三区在线观看| 国产精品理伦片| 日韩免费看的电影| 欧美日韩精品一区二区在线播放| 国产91精品精华液一区二区三区| 亚洲电影一区二区三区| 国产精品毛片无遮挡高清| 日韩一区二区高清| 欧美性猛交xxxx黑人交| 国产成人免费在线| 国产精品毛片久久久久久久 | 成人免费高清在线观看| 午夜精品久久久久| 国产精品乱码人人做人人爱| 欧美图片一区二区三区| 国产河南妇女毛片精品久久久| 亚洲欧美日韩人成在线播放| 日韩欧美色电影| 91福利国产成人精品照片| 国产美女av一区二区三区| 一区二区在线看| 国产精品视频观看| 精品黑人一区二区三区久久| 91福利视频久久久久| 高清国产一区二区| 美女视频第一区二区三区免费观看网站| 欧美激情综合五月色丁香| 欧美一区二区三区四区高清| 欧美午夜片在线看| 色哟哟一区二区| 国v精品久久久网| 久久不见久久见免费视频7| 亚洲男人电影天堂| 国产精品每日更新| 中文字幕一区二区三区色视频| 日韩欧美成人激情| 欧美人妖巨大在线| 欧美性色aⅴ视频一区日韩精品| 高清shemale亚洲人妖| 男男gaygay亚洲| 一区二区三区鲁丝不卡| 亚洲精品v日韩精品| 国产精品国产三级国产普通话99 | 国产精品一区二区三区网站| 男女激情视频一区| 男男gaygay亚洲| 亚洲成人自拍网| 蜜臀av一区二区在线免费观看 | 久久综合九色综合97婷婷| 6080亚洲精品一区二区| 欧美日本一道本在线视频| 在线日韩一区二区| 日本韩国欧美一区二区三区| 不卡一区二区三区四区| 亚洲午夜国产一区99re久久| 亚洲精品国产无天堂网2021 | 久久精品免费看| 蜜臀久久久99精品久久久久久| 亚洲精品中文在线| 亚洲国产综合在线| 午夜欧美大尺度福利影院在线看| 亚洲伊人色欲综合网| 亚洲一级二级三级| 亚洲午夜久久久久久久久电影网| 日韩国产欧美在线视频| 蜜臀91精品一区二区三区 | 亚洲精品日日夜夜| 亚洲国产sm捆绑调教视频| 午夜精品久久久久久久| 亚洲一区在线观看网站| 美脚の诱脚舐め脚责91| 国产伦精品一区二区三区视频青涩| 精品影院一区二区久久久| 国产成人亚洲综合a∨婷婷图片| 福利一区二区在线| 在线中文字幕一区二区| 欧美日韩一区二区三区不卡| 色屁屁一区二区| 91麻豆精品国产| 久久久综合精品| 亚洲午夜私人影院| 亚洲成人av中文| av欧美精品.com| 欧美日韩国产高清一区二区| 欧美本精品男人aⅴ天堂| 国产农村妇女精品| 亚洲电影激情视频网站| 蜜桃久久久久久| 欧美三级韩国三级日本一级| 日韩精品一区二区三区在线观看 | 精品一区二区在线观看| 成人激情免费视频| 在线综合视频播放| 亚洲女女做受ⅹxx高潮| 蜜桃传媒麻豆第一区在线观看| 国产九色精品成人porny| 欧美三级中文字幕在线观看| 精品入口麻豆88视频| 伊人一区二区三区| 99精品1区2区| 欧美大片国产精品| 亚洲影视在线播放| 风间由美性色一区二区三区| 欧美日韩黄色一区二区| 欧美国产日韩一二三区| 奇米四色…亚洲| 色婷婷精品久久二区二区蜜臂av| 欧美xxxxx牲另类人与| 亚洲欧美激情小说另类| 日韩电影在线观看电影| 在线不卡中文字幕| 亚洲欧美区自拍先锋| 国产成人精品亚洲午夜麻豆| 欧美精品一区二区三区高清aⅴ | 欧美影片第一页| 久久精品人人做| 强制捆绑调教一区二区| 欧美日韩亚洲综合一区二区三区| 国产精品视频在线看| 久久精品国产99| 欧美一区欧美二区|