On Wed, Aug 06, 2014 at 05:32:47AM -0700, [email protected] wrote:
> Signed-off-by: John Johansen <[email protected]>

Acked-by: Seth Arnold <[email protected]>

Thanks

> ---
>  parser/network.c |   54 
> +++++++++++++++++++++++++++++++++++++++++-------------
>  parser/network.h |    3 +++
>  2 files changed, 44 insertions(+), 13 deletions(-)
> 
> --- 2.9-test.orig/parser/network.c
> +++ 2.9-test/parser/network.c
> @@ -35,23 +35,51 @@
>   * have to make sure these are in order.  This means we are more brittle
>   * but there isn't much we can do.
>   */
> -const char *sock_types[] = {
> -     "none",         /* 0 */
> -     "stream",       /* 1 [SOCK_STREAM] */
> -     "dgram",        /* 2 [SOCK_DGRAM] */
> -     "raw",          /* 3 [SOCK_RAW] */
> -     "rdm",          /* 4 [SOCK_RDM] */
> -     "seqpacket",    /* 5 [SOCK_SEQPACKET] */
> -     "dccp",         /* 6 [SOCK_DCCP] */
> -     "invalid",      /* 7 */
> -     "invalid",      /* 8 */
> -     "invalid",      /* 9 */
> -     "packet",       /* 10 [SOCK_PACKET] */
> +struct sock_type_map {
> +     const char *name;
> +     int     value;
> +};
> +
> +struct sock_type_map sock_types[] = {
> +     { "none",       0 },
> +     { "stream",     SOCK_STREAM },
> +     { "dgram",      SOCK_DGRAM },
> +     { "raw",        SOCK_RAW },
> +     { "rdm",        SOCK_RDM },
> +     { "seqpacket",  SOCK_SEQPACKET },
> +     { "dccp",       SOCK_DCCP },
> +     { "invalid",    -1 },
> +     { "invalid",    -1 },
> +     { "invalid",    -1 },
> +     { "packet",     SOCK_PACKET },
> +     { NULL, -1 },
>       /*
>        * See comment above
>       */
>  };
>  
> +int net_find_type_val(const char *type)
> +{
> +     int i;
> +     for (i = 0; sock_types[i].name; i++) {
> +             if (strcmp(sock_types[i].name, type) == 0)
> +                     return sock_types[i].value;
> +     }
> +
> +     return -1;
> +}
> +
> +const char *net_find_type_name(int type)
> +{
> +     int i;
> +     for (i = 0; sock_types[i].name; i++) {
> +             if (sock_types[i].value  == type)
> +                     return sock_types[i].name;
> +     }
> +
> +     return NULL;
> +}
> +
>  struct network_tuple {
>       const char *family_name;
>       unsigned int family;
> @@ -319,7 +347,7 @@
>                       for (j = 0; j < count; j++) {
>                               const char *type;
>                               if (array[i] & (1 << j)) {
> -                                     type = sock_types[j];
> +                                     type = sock_types[j].name;
>                                       if (type)
>                                               printf("%s ", type);
>                                       else
> --- 2.9-test.orig/parser/network.h
> +++ 2.9-test/parser/network.h
> @@ -75,4 +75,7 @@
>       }
>  };
>  
> +int net_find_type_val(const char *type);
> +const char *net_find_type_name(int type);
> +
>  #endif /* __AA_NETWORK_H */
> 
> 
> -- 
> AppArmor mailing list
> [email protected]
> Modify settings or unsubscribe at: 
> https://lists.ubuntu.com/mailman/listinfo/apparmor
> 

Attachment: signature.asc
Description: Digital signature

-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to