new set of cppcheck fixes
This commit is contained in:
@@ -46,22 +46,22 @@
|
||||
|
||||
|
||||
#define NIPADDR(addr) \
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
|
||||
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
|
||||
// Global variables
|
||||
@@ -76,12 +76,9 @@ struct oai_nw_drv_ioctl gifr;
|
||||
void IAL_NAS_ioctl_init(int inst)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
struct oai_nw_drv_msg_statistic_reply *msgrep;
|
||||
int err,rc;
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
// Get an UDP IPv6 socket ??
|
||||
fd=socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
|
||||
@@ -91,7 +88,6 @@ void IAL_NAS_ioctl_init(int inst)
|
||||
}
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
gifr.type = OAI_NW_DRV_MSG_STATISTIC_REQUEST;
|
||||
memset ((void *)dummy_buffer,0,800);
|
||||
gifr.msg= &(dummy_buffer[0]);
|
||||
@@ -160,7 +156,6 @@ int main(int argc,char **argv)
|
||||
char addr_str[46];
|
||||
char mask_len_delims[] = "/";
|
||||
char *result;
|
||||
|
||||
// scan options
|
||||
rb[0] = '\0';
|
||||
cx[0] = '\0';
|
||||
@@ -171,156 +166,155 @@ int main(int argc,char **argv)
|
||||
|
||||
while ((c = getopt (argc, argv, "adr:i:c:f:l:m:s:t:x:y:z:")) != -1)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
action = ADD_RB;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
action = DEL_RB;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
strcpy(rb,optarg);
|
||||
rbset = 1;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
strcpy(inst,optarg);
|
||||
instset = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
strcpy(cx,optarg);
|
||||
cxset = 1;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
strcpy(classref,optarg);
|
||||
classrefset = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&saddr_ipv4);
|
||||
printf("Arg Source Addr IPv4 string: %s\n",result);
|
||||
saddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv4 string: ERROR\n");
|
||||
case 'a':
|
||||
action = ADD_RB;
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv4 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&daddr_ipv4);
|
||||
printf("Arg Dest Addr IPv4 string: %s\n",result);
|
||||
daddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv4 string: ERROR\n");
|
||||
case 'd':
|
||||
action = DEL_RB;
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Dest Addr IPv4 mask len: %d\n",dplen);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Source Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv6 string: ERROR\n");
|
||||
case 'r':
|
||||
strcpy(rb,optarg);
|
||||
rbset = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 128;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv6 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Dest Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv6 string: ERROR\n");
|
||||
case 'i':
|
||||
strcpy(inst,optarg);
|
||||
instset = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
case 'c':
|
||||
strcpy(cx,optarg);
|
||||
cxset = 1;
|
||||
break;
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 128;
|
||||
}
|
||||
case 'f':
|
||||
strcpy(classref,optarg);
|
||||
classrefset = 1;
|
||||
break;
|
||||
|
||||
printf("Arg Dest Addr IPv6 mask len: %d\n",dplen);
|
||||
break;
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
dscpset=1;
|
||||
strcpy(dscp,optarg);
|
||||
break;
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"Unknown option character `\\x%x'.\n",
|
||||
optopt);
|
||||
case 's':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
return 1;
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&saddr_ipv4);
|
||||
printf("Arg Source Addr IPv4 string: %s\n",result);
|
||||
saddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv4 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv4 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&daddr_ipv4);
|
||||
printf("Arg Dest Addr IPv4 string: %s\n",result);
|
||||
daddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv4 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Dest Addr IPv4 mask len: %d\n",dplen);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Source Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv6 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 128;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv6 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Dest Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv6 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 128;
|
||||
}
|
||||
|
||||
printf("Arg Dest Addr IPv6 mask len: %d\n",dplen);
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
dscpset=1;
|
||||
strcpy(dscp,optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"Unknown option character `\\x%x'.\n",
|
||||
optopt);
|
||||
|
||||
return 1;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
printf ("action = %d, rb = %s,cx = %s\n", action, rb, cx);
|
||||
|
||||
if (rbset==0) {
|
||||
@@ -364,13 +358,11 @@ int main(int argc,char **argv)
|
||||
}
|
||||
|
||||
IAL_NAS_ioctl_init(atoi(inst));
|
||||
|
||||
msgreq = (struct oai_nw_drv_msg_rb_establishment_request *)(gifr.msg);
|
||||
msgreq->rab_id = atoi(rb);
|
||||
msgreq->lcr = atoi(cx);
|
||||
msgreq->qos = 0;
|
||||
|
||||
|
||||
if (action == ADD_RB) {
|
||||
gifr.type = OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST;
|
||||
printf("OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST: RB %d LCR %d QOS %d\n ", msgreq->rab_id, msgreq->lcr, msgreq->qos);
|
||||
@@ -405,8 +397,6 @@ int main(int argc,char **argv)
|
||||
printf(" IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen);
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 4;
|
||||
@@ -420,7 +410,6 @@ int main(int argc,char **argv)
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_RECEIVE RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
printf("IPV4: Source = %d.%d.%d.%d/%d ", NIPADDR(msgreq_class->saddr.ipv4), msgreq_class->splen);
|
||||
printf("IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen);
|
||||
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
@@ -443,7 +432,6 @@ int main(int argc,char **argv)
|
||||
msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND;
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT;
|
||||
|
||||
memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16);
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_SEND RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
@@ -451,7 +439,6 @@ int main(int argc,char **argv)
|
||||
printf("IPV6: Dest = %x:%x:%x:%x:%x:%x:%x:%x/%d\n", NIP6ADDR(&msgreq_class->daddr.ipv6), msgreq_class->dplen);
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->dplen = splen;
|
||||
@@ -468,7 +455,6 @@ int main(int argc,char **argv)
|
||||
}
|
||||
|
||||
if (mpls_inlabelset == 1) {
|
||||
|
||||
msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
@@ -483,40 +469,26 @@ int main(int argc,char **argv)
|
||||
//msgreq_class->classref = 4 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=OAI_NW_DRV_DIRECTION_SEND;
|
||||
msgreq_class->fct=OAI_NW_DRV_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_outlabel = atoi(mpls_outgoinglabel);
|
||||
|
||||
printf("Setting MPLS outlabel %d with exp %d\n",mpls_outlabel,msgreq_class->dscp);
|
||||
|
||||
printf("Setting MPLS outlabel %u with exp %d\n",mpls_outlabel,msgreq_class->dscp);
|
||||
msgreq_class->daddr.mpls_label = mpls_outlabel;
|
||||
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8);
|
||||
//msgreq_class->classref = 5 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=OAI_NW_DRV_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_inlabel = atoi(mpls_incominglabel);
|
||||
|
||||
printf("Setting MPLS inlabel %d with exp %d\n",mpls_inlabel,msgreq_class->dscp);
|
||||
|
||||
printf("Setting MPLS inlabel %u with exp %d\n",mpls_inlabel,msgreq_class->dscp);
|
||||
msgreq_class->daddr.mpls_label = mpls_inlabel;
|
||||
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
} else if (action == DEL_RB) {
|
||||
gifr.type = OAI_NW_DRV_MSG_RB_RELEASE_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
@@ -108,12 +108,9 @@ int NAS_RALconnect(void)
|
||||
void IAL_NAS_ioctl_init(int inst)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
struct nas_msg_statistic_reply *msgrep;
|
||||
int err;
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
// Get an UDP IPv6 socket ??
|
||||
fd=socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
|
||||
@@ -123,7 +120,6 @@ void IAL_NAS_ioctl_init(int inst)
|
||||
}
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
gifr.type = NAS_MSG_STATISTIC_REQUEST;
|
||||
memset ((void *)dummy_buffer,0,800);
|
||||
gifr.msg= &(dummy_buffer[0]);
|
||||
@@ -139,8 +135,6 @@ void IAL_NAS_ioctl_init(int inst)
|
||||
printf("tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes);
|
||||
printf("tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors);
|
||||
printf("tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -160,11 +154,7 @@ int main(int argc,char **argv)
|
||||
in_addr_t saddr_ipv4 = 0,daddr_ipv4 = 0;
|
||||
struct in6_addr saddr_ipv6,daddr_ipv6;
|
||||
unsigned int mpls_outlabel=0,mpls_inlabel=0;
|
||||
|
||||
char addr_str[46];
|
||||
|
||||
|
||||
|
||||
// scan options
|
||||
rb[0] = '\0';
|
||||
cx[0] = '\0';
|
||||
@@ -174,89 +164,87 @@ int main(int argc,char **argv)
|
||||
|
||||
while ((c = getopt (argc, argv, "adr:i:c:l:m:s:t:x:y:z:")) != -1)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
action = ADD_RB;
|
||||
break;
|
||||
case 'a':
|
||||
action = ADD_RB;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
action = DEL_RB;
|
||||
break;
|
||||
case 'd':
|
||||
action = DEL_RB;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
strcpy(rb,optarg);
|
||||
rbset = 1;
|
||||
break;
|
||||
case 'r':
|
||||
strcpy(rb,optarg);
|
||||
rbset = 1;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
strcpy(inst,optarg);
|
||||
instset = 1;
|
||||
break;
|
||||
case 'i':
|
||||
strcpy(inst,optarg);
|
||||
instset = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
strcpy(cx,optarg);
|
||||
cxset = 1;
|
||||
break;
|
||||
case 'c':
|
||||
strcpy(cx,optarg);
|
||||
cxset = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
|
||||
case 's': {
|
||||
struct in_addr a;
|
||||
inet_aton(optarg,&a);
|
||||
saddr_ipv4 = a.s_addr;
|
||||
saddr_ipv4set = 1;
|
||||
break;
|
||||
case 's': {
|
||||
struct in_addr a;
|
||||
inet_aton(optarg,&a);
|
||||
saddr_ipv4 = a.s_addr;
|
||||
saddr_ipv4set = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 't': {
|
||||
struct in_addr a;
|
||||
inet_aton(optarg,&a);
|
||||
daddr_ipv4 = a.s_addr;
|
||||
daddr_ipv4set = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'x':
|
||||
printf("IPv6: %s\n",optarg);
|
||||
inet_pton(AF_INET6,optarg,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
inet_pton(AF_INET6,optarg,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
dscpset=1;
|
||||
strcpy(dscp,optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"Unknown option character `\\x%x'.\n",
|
||||
optopt);
|
||||
|
||||
return 1;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
case 't': {
|
||||
struct in_addr a;
|
||||
inet_aton(optarg,&a);
|
||||
daddr_ipv4 = a.s_addr;
|
||||
daddr_ipv4set = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'x':
|
||||
printf("IPv6: %s\n",optarg);
|
||||
inet_pton(AF_INET6,optarg,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
inet_pton(AF_INET6,optarg,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
dscpset=1;
|
||||
strcpy(dscp,optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"Unknown option character `\\x%x'.\n",
|
||||
optopt);
|
||||
|
||||
return 1;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
printf ("action = %d, rb = %s,cx = %s\n", action, rb, cx);
|
||||
|
||||
|
||||
if (rbset==0) {
|
||||
printf("ERROR: Specify a RAB id!!\n");
|
||||
exit(-1);
|
||||
@@ -293,31 +281,27 @@ int main(int argc,char **argv)
|
||||
}
|
||||
|
||||
IAL_NAS_ioctl_init(atoi(inst));
|
||||
|
||||
msgreq = (struct nas_msg_rb_establishment_request *)(gifr.msg);
|
||||
msgreq->rab_id = atoi(rb);
|
||||
msgreq->lcr = atoi(cx);
|
||||
msgreq->qos = 0;
|
||||
|
||||
|
||||
if (action == ADD_RB) {
|
||||
gifr.type = NAS_MSG_RB_ESTABLISHMENT_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
if (saddr_ipv4set == 1) {
|
||||
msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 4;
|
||||
|
||||
msgreq_class->classref = 0 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir = NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct = NAS_FCT_QOS_SEND;
|
||||
msgreq_class->saddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->daddr.ipv4 = daddr_ipv4;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
@@ -326,21 +310,20 @@ int main(int argc,char **argv)
|
||||
else
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 1+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir = NAS_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
msgreq_class->daddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->saddr.ipv4 = daddr_ipv4;
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
}
|
||||
|
||||
@@ -358,38 +341,32 @@ int main(int argc,char **argv)
|
||||
msgreq_class->classref = 2+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct=NAS_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16);
|
||||
|
||||
inet_ntop(AF_INET6,(void *)&saddr_ipv6,addr_str,46);
|
||||
printf("IPV6: Source %s\n",addr_str);
|
||||
inet_ntop(AF_INET6,(void *)&daddr_ipv6,addr_str,46);
|
||||
printf("IPV6: Dest %s\n",addr_str);
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 3+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_RECEIVE;
|
||||
memcpy(&msgreq_class->daddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->saddr.ipv6,&daddr_ipv6,16);
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mpls_inlabelset == 1) {
|
||||
|
||||
msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
@@ -403,50 +380,34 @@ int main(int argc,char **argv)
|
||||
msgreq_class->classref = 4 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct=NAS_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_outlabel = atoi(mpls_outgoinglabel);
|
||||
|
||||
printf("Setting MPLS outlabel %d with exp %d\n",mpls_outlabel,msgreq_class->dscp);
|
||||
|
||||
printf("Setting MPLS outlabel %u with exp %d\n",mpls_outlabel,msgreq_class->dscp);
|
||||
msgreq_class->daddr.mpls_label = mpls_outlabel;
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 5 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_inlabel = atoi(mpls_incominglabel);
|
||||
|
||||
printf("Setting MPLS inlabel %d with exp %d\n",mpls_inlabel,msgreq_class->dscp);
|
||||
|
||||
printf("Setting MPLS inlabel %u with exp %d\n",mpls_inlabel,msgreq_class->dscp);
|
||||
msgreq_class->daddr.mpls_label = mpls_inlabel;
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
|
||||
|
||||
}
|
||||
} else if (action == DEL_RB) {
|
||||
gifr.type = NAS_MSG_RB_RELEASE_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err == -1) perror("ioctl");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
//#define MPLS
|
||||
|
||||
#ifdef MPLS
|
||||
#include <net/mpls.h>
|
||||
#include <net/mpls.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,12 +46,9 @@
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (send direction)
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref);
|
||||
#endif
|
||||
@@ -91,8 +88,7 @@ struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_
|
||||
// Add a new classifier rule (receive direction)
|
||||
struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp,
|
||||
uint16_t classref,
|
||||
struct nas_priv *gpriv)
|
||||
{
|
||||
struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -125,8 +121,7 @@ struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp,
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (forwarding)
|
||||
struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -166,8 +161,7 @@ struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx)
|
||||
{
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -196,8 +190,7 @@ void nas_CLASS_flush_sclassifier(struct cx_entity *cx)
|
||||
#endif
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx)
|
||||
{
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -227,8 +220,7 @@ void nas_CLASS_flush_fclassifier(struct cx_entity *cx)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv)
|
||||
{
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
@@ -251,8 +243,7 @@ void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -295,8 +286,7 @@ void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t clas
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -339,8 +329,7 @@ void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t clas
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (receive direction)
|
||||
void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv)
|
||||
{
|
||||
void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
@@ -379,8 +368,7 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned int *addr,*dst=NULL;
|
||||
@@ -388,17 +376,12 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
if (skb!=NULL) {
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; cxi++) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
|
||||
p = gpriv->cx[cxi].sclassifier[dscp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 6) { // verify that this is an IPv4 rule
|
||||
|
||||
|
||||
if ((addr = (unsigned int *)(&(p->daddr.ipv6)))== NULL) {
|
||||
printk("nas_CLASS_cx6: addr is null \n");
|
||||
p = p->next;
|
||||
@@ -409,9 +392,8 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
printk("cx %d : %X,%X.%X,%X\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
|
||||
//if ((dst = (unsigned int*)&(((struct rt6_info *)skbdst)->rt6i_gateway)) == 0){
|
||||
if ( (dst = &((struct iphdr*)(skb_network_header(skb)))->daddr) == NULL) {
|
||||
|
||||
if ( (dst = &((struct iphdr *)(skb_network_header(skb)))->daddr) == NULL) {
|
||||
printk("nas_CLASS_cx6: dst addr is null \n");
|
||||
p = p->next;
|
||||
continue;
|
||||
@@ -446,11 +428,15 @@ struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
}
|
||||
}
|
||||
|
||||
printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n",
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
|
||||
if (dst ) {
|
||||
printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n",
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
}
|
||||
|
||||
return default_ip;
|
||||
}
|
||||
|
||||
@@ -460,8 +446,7 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned char *addr;
|
||||
@@ -473,10 +458,9 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
if (skb!=NULL) {
|
||||
daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr;
|
||||
daddr = ((struct iphdr *)(skb_network_header(skb)))->daddr;
|
||||
|
||||
if (daddr!=0) {
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASS][IPv4] Searching for %d.%d.%d.%d\n",
|
||||
((unsigned char *)&daddr)[0],
|
||||
@@ -491,7 +475,6 @@ struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 4) { // verify that this is an IPv4 rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
addr = (char *)(&(p->daddr.ipv4));
|
||||
printk("found classifier cx %d for destination: %d.%d.%d.%d\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
@@ -536,32 +519,23 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
unsigned char exp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
unsigned char *cx_searcher) {
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
|
||||
struct cx_entity *default_label=NULL;
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
// if (inst >0)
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
|
||||
printk("[NAS][CLASS][MPLS] Searching for label %d\n",MPLSCB(skb)->label);
|
||||
#endif
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; ++cxi) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
p = gpriv->cx[cxi].sclassifier[exp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == NAS_MPLS_VERSION_CODE) { // verify that this is an MPLS rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("cx %d : label %d\n",cxi,p->daddr.mpls_label);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
@@ -588,11 +562,8 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
// goto to next classification rule for the connection
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return default_label;
|
||||
}
|
||||
|
||||
@@ -600,8 +571,7 @@ struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the sending function
|
||||
void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
{
|
||||
void nas_CLASS_send(struct sk_buff *skb,int inst) {
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p, *sp;
|
||||
uint8_t *protocolh,version;
|
||||
@@ -609,15 +579,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
uint16_t classref;
|
||||
struct cx_entity *cx;
|
||||
//unsigned int i;
|
||||
|
||||
//unsigned int router_adv = 0;
|
||||
struct net_device *dev=nasdev[inst];
|
||||
|
||||
struct nas_priv *gpriv=netdev_priv(dev);
|
||||
|
||||
unsigned char cx_searcher,no_connection=1;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: begin - inst %d\n",inst);
|
||||
#endif
|
||||
@@ -629,9 +594,7 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
|
||||
printk("[NAS][CLASS][SEND] Got packet from kernel:\n");
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
@@ -641,80 +604,65 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
#endif
|
||||
// find all connections related to socket
|
||||
cx_searcher = 0;
|
||||
|
||||
no_connection = 1;
|
||||
|
||||
//while (cx_searcher<NAS_CX_MAX) {
|
||||
|
||||
cx = NULL;
|
||||
|
||||
// Address classification
|
||||
switch (ntohs(skb->protocol)) {
|
||||
case ETH_P_IPV6:
|
||||
version = 6;
|
||||
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
);
|
||||
case ETH_P_IPV6:
|
||||
version = 6;
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
#endif
|
||||
cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
|
||||
|
||||
cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp);
|
||||
printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp);
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case ETH_P_IP:
|
||||
|
||||
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
case ETH_P_IP:
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
#endif
|
||||
version = 4;
|
||||
|
||||
break;
|
||||
version = 4;
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case ETH_P_MPLS_UC:
|
||||
cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher);
|
||||
|
||||
case ETH_P_MPLS_UC:
|
||||
cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx);
|
||||
printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx);
|
||||
#endif
|
||||
dscp = MPLSCB(skb)->exp;
|
||||
version = NAS_MPLS_VERSION_CODE;
|
||||
protocol = version;
|
||||
break;
|
||||
#endif
|
||||
|
||||
dscp = MPLSCB(skb)->exp;
|
||||
version = NAS_MPLS_VERSION_CODE;
|
||||
protocol = version;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
printk("NAS_CLASS_SEND: Unknown protocol\n");
|
||||
version = 0;
|
||||
return;
|
||||
default:
|
||||
printk("NAS_CLASS_SEND: Unknown protocol\n");
|
||||
version = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If a valid connection for the DSCP/EXP with destination address
|
||||
// is found scan all protocol-based classification rules
|
||||
|
||||
if (cx) {
|
||||
|
||||
classref=0;
|
||||
sp=NULL;
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASSIFIER] DSCP/EXP %d : looking for classifier entry\n",dscp);
|
||||
#endif
|
||||
@@ -738,12 +686,10 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
classref=sp->classref;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sp!=NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
char sfct[10], sprotocol[10];
|
||||
|
||||
if (sp->fct==nas_COMMON_QOS_send)
|
||||
@@ -759,41 +705,38 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
strcpy(sfct, "dc");
|
||||
|
||||
switch(protocol) {
|
||||
case NAS_PROTOCOL_UDP:
|
||||
strcpy(sprotocol, "udp");
|
||||
printk("udp packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_UDP:
|
||||
strcpy(sprotocol, "udp");
|
||||
printk("udp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_TCP:
|
||||
strcpy(sprotocol, "tcp");
|
||||
printk("tcp packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_TCP:
|
||||
strcpy(sprotocol, "tcp");
|
||||
printk("tcp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP4:
|
||||
strcpy(sprotocol, "icmp4");
|
||||
printk("icmp4 packet\n");
|
||||
break;
|
||||
case NAS_PROTOCOL_ICMP4:
|
||||
strcpy(sprotocol, "icmp4");
|
||||
printk("icmp4 packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP6:
|
||||
strcpy(sprotocol, "icmp6");
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr*)protocolh);
|
||||
break;
|
||||
case NAS_PROTOCOL_ICMP6:
|
||||
strcpy(sprotocol, "icmp6");
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr *)protocolh);
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
strcpy(sprotocol,"mpls");
|
||||
break;
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
strcpy(sprotocol,"mpls");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
printk("NAS_CLASS_SEND: (dscp %u, %s) received, (classref %u, fct %s, rab_id %u) classifier rule\n",
|
||||
dscp, sprotocol, sp->classref, sfct, sp->rab_id);
|
||||
#endif
|
||||
|
||||
sp->fct(skb, cx, sp,inst, NULL);
|
||||
|
||||
} // if classifier entry match found
|
||||
|
||||
else {
|
||||
printk("NAS_CLASS_SEND: no corresponding item in the classifier, so the message is dropped\n");
|
||||
// nas_COMMON_del_send(skb, cx, NULL,inst);
|
||||
@@ -802,20 +745,14 @@ void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
no_connection = 0;
|
||||
} // if connection found
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
if (no_connection == 1)
|
||||
printk("NAS_CLASS_SEND: no corresponding connection, so the message is dropped\n");
|
||||
|
||||
#endif /* NAS_DEBUG_CLASS */
|
||||
|
||||
|
||||
// } // while loop over connections
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: end\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user