On Mon, Nov 21, 2011 at 11:53:10PM +0100, Antonio Quartulli wrote:
Hi Antonio
+/* Returns arphdr->ar_op if the skb contains a valid ARP packet, otherwise
- returns 0 */
+uint16_t arp_get_type(struct bat_priv *bat_priv, struct sk_buff *skb) +{
- struct arphdr *arphdr;
- struct ethhdr *ethhdr;
- uint16_t type = 0;
- char buf[30], *type_str[] = { "REQUEST", "REPLY", "RREQUEST", "RREPLY",
"InREQUEST", "InREPLY", "NAK" };
type_str could be marked as const. Saves a little bit of space on the BSS.
- if (type >= 1 && type <= 10)
scnprintf(buf, 30, "%s", type_str[type - 1]);
type_str currently has 6 entries, so if somebody sends you an ARP request with type greater than 6, you go off the end of the array. Better to use ARRAY_SIZE().
Andrew