blob: 8b4ebd92e2220bb0d6e8095806b5111f68ffcdde [file] [log] [blame]
/******************************************************************************
*(C) Copyright 2015 Marvell International Ltd.
* All Rights Reserved
******************************************************************************/
#ifndef __CHL_UTIL__
#define __CHL_UTIL__
#define _FILE_ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#ifdef LOGCAT
#define CHL_PRINTF(f_, ...) RDBGMSG("%s:%d " f_, _FILE_ , \
__LINE__, ##__VA_ARGS__)
#define CHL_DBG(f_, ...) RDBGMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__)
#define CHL_INFO(f_, ...) RINFOMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__)
#define CHL_WARN(f_, ...) RWARNMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__)
#define CHL_ERR(f_, ...) RERRMSG("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__)
#else
#define CHL_PRINTF(f_, ...) printf("%s:%d " f_, _FILE_ , __LINE__, ##__VA_ARGS__)
#define CHL_DBG(f_, ...) CHL_PRINTF(f_, ##__VA_ARGS__)
#define CHL_INFO(f_, ...) CHL_PRINTF(f_, ##__VA_ARGS__)
#define CHL_WARN(f_, ...) CHL_PRINTF("WARNING: " f_, ##__VA_ARGS__)
#define CHL_ERR(f_, ...) CHL_PRINTF("ERROR: " f_, ##__VA_ARGS__)
#endif
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
int validate_ip(const char *addr, int family);
int get_global_ipv6(const char *ifname, char *addr, int *prefix);
bool str_starts_with(const char *prefix, const char *str);
void cid_to_ccinet(int cid, char *ccinet);
void cid_to_section(int cid, char *wan);
void cid_to_section6(int cid, char *wan6);
#endif