19 static struct fwp_ac fwp_ac_table[FWP_AC_NUM];
21 const int prio_to_ac[8] = {2,3,3,2,1,1,0,0};
22 const unsigned int ac_to_tos[4] = {224,160,96,64};
24 void fwp_ac_table_init()
28 for (id = 0; id < FWP_AC_NUM; id++) {
29 fwp_ac_table[id].status = FWP_AC_CLOSED;
30 fwp_ac_table[id].count = 0;
34 int fwp_ac_open(unsigned int id)
37 unsigned int yes=1, tos;
38 struct fwp_ac *ac = &fwp_ac_table[id];
40 //if ((id < 0)||(id >= AC_NUM)||(ac[id].status != OPENED))
43 if (ac->status == FWP_AC_OPENED) {
48 if ((sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
50 /*perror("Unable to open socket");*/
54 if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
55 /*perror("Unable to set socket");*/
60 if (setsockopt(sockfd, SOL_IP, IP_TOS, &tos, sizeof(tos))) {
61 /*perror("Unable to set TOS");*/
67 ac->status = FWP_AC_OPENED;
74 int fwp_ac_close(unsigned int id)
76 struct fwp_ac *ac = &fwp_ac_table[id];
78 if (ac->status != FWP_AC_OPENED) return -1;
79 if (--ac->count == 0) {
81 ac->status = FWP_AC_CLOSED;
86 int fwp_ac_send(unsigned int id, struct fwp_msgb* msgb)
88 while (sendto(fwp_ac_table[id].sockfd, msgb->head, msgb->len,
89 /*msgb_>flags*/0, &msgb->addr, msgb->addrlen) < 0) {
91 if (errno == EINTR) continue;
92 /*perror("Error while sending data");*/