/* * config.h - Daemon and Utility Interface Header * * Copyright (C) 1997-2000 SpellCaster Telecommunications Inc. * $Id: config.h,v 1.5 2004/10/20 05:09:54 bcrl Exp $ * Released under the GNU Public License. See LICENSE file for details. */ #ifndef CONFIG_H #define CONFIG_H #include #include #include typedef u_int8_t u8; typedef u_int16_t u16; typedef u_int32_t u32; typedef u_int64_t u64; /* * Fixed array lengths, use these and you can't go wrong ;) */ #define PORT_NAME_LEN 16 #define CLASS_NAME_LEN 16 #define USER_NAME_LEN 256 #define PASSWORD_LEN 256 #define SITE_NAME_LEN 256 #define PHONE_LEN 256 #define SYSNAME_LEN 32 #include "call.h" /* * Policy masks indicate which fields are valid and which * should be ignored. When setting the policy using BIOC_SPOLICY you * must set the mask. Set the mask to indicate validity, clear it to * ignore. */ enum PolicyOpts { P_MAGIC, P_MRU, P_MRRU, P_PFC, P_ACFC, P_AUTH, P_ANSWER, P_ACCM, P_SSN, P_MLCP_SSN, P_ECHO, P_LDISC, P_CALL_INFO, P_EPD_CLASS, P_EPD_LENGTH, P_ECHO_INTERVAL, P_WANT_MLCP, P_WANT_RAIN, P_WANT_IPV6, P_IPV6_DEFROUTE, P_WANT_REJ_MRRU, P_REVERSE_PATH, P_ECHO_LEN, NumPMASKs }; #define PAUTH_PAP 0xC023 #define PAUTH_CHAP 0xC223 class dfs_object_t; class ctrlfd_t; /* * Link-level policy and configuration structure */ class policy_t { private: u32 data[NumPMASKs]; /* * validity mask for the policy. Indicates which of the following * fields are to be ignored. Default is 0x00000000 (ignore everything) */ u32 valid_mask; public: u8 epd_addr[20]; void Clear(void) { valid_mask = 0; memset(data, 0, sizeof(data)); memset(epd_addr, 0, sizeof(epd_addr)); } policy_t() { Clear(); } policy_t(policy_t &orig) { *this = orig; } policy_t(policy_t *orig) { *this = *orig; } int Valid(enum PolicyOpts opt) { return valid_mask & (1 << opt); } void Set(enum PolicyOpts opt, u32 value) { data[opt] = value; valid_mask |= 1 << opt; } u32 Get(enum PolicyOpts opt) { return data[opt]; } void Clear(enum PolicyOpts opt) { valid_mask &= ~(1 << opt); data[opt] = 0; } void Set(policy_t &src) { *this = src; } void Merge(policy_t &src) { for (unsigned i=0; i0 */ u16 ipv6_ndra_len; /* IPv6 link prefix length (1-64) */ OptionReq_t *cancel_obj; #define MAX_OPTIONSET_ROUTES 8 RouteMsg_t routes[MAX_OPTIONSET_ROUTES]; int nr_routes; RouteIpv6_t ipv6_routes[MAX_OPTIONSET_ROUTES]; int nr_ipv6_routes; OptionSet_t() { memset((void *)this, 0, sizeof(OptionSet_t)); } OptionSet_t operator = (OptionSet_t &orig) { *(char *)0 = 0; Set(orig); return *this; } void SetCall(Call *new_call) { if (call) call->DiscardCallUser(&call); call = new_call; if (call) call->CallUser(&call); } void Set(OptionSet_t *orig) { if (orig == this) return; if (pol && orig->pol == pol) *(char *)0 = 0; if (pol) delete pol; if (loc_ip_pool) free(loc_ip_pool); if (rem_ip_pool) free(rem_ip_pool); if (qos_profile_name) free(qos_profile_name); if (call) call->DiscardCallUser(&call); memcpy(this, orig, sizeof(OptionSet_t)); if (call) call->CallUser(&call); if (rem_ip_pool) rem_ip_pool = strdup(rem_ip_pool); if (loc_ip_pool) loc_ip_pool = strdup(loc_ip_pool); if (qos_profile_name) qos_profile_name = strdup(qos_profile_name); pol = NULL; ClonePolFrom(orig->pol); } void Set(OptionSet_t &orig) { Set(&orig); } OptionSet_t(OptionSet_t &orig) { pol = NULL; loc_ip_pool = NULL; rem_ip_pool = NULL; qos_profile_name = NULL; call = NULL; Set(orig); } ~OptionSet_t() { if (cancel_obj) cancel_obj->CancelGetConfig(); if (pol) delete pol; if (call) call->DiscardCallUser(&call); if (rem_ip_pool) free(rem_ip_pool); if (loc_ip_pool) free(loc_ip_pool); if (qos_profile_name) free(qos_profile_name); memset(this, 0xff, sizeof(OptionSet_t)); pol = NULL; cancel_obj = NULL; call = NULL; } void Clear(void) { if (cancel_obj) cancel_obj->CancelGetConfig(); if (pol) delete pol; if (call) call->DiscardCallUser(&call); if (rem_ip_pool) free(rem_ip_pool); if (loc_ip_pool) free(loc_ip_pool); if (qos_profile_name) free(qos_profile_name); memset((void *)this, 0, sizeof(OptionSet_t)); } void dfs_restore(dfs_object_t *obj); void dump_full_state(ctrlfd_t *cfd); void ClonePolFrom(policy_t *orig) { if (pol == orig) return; if (pol) delete pol; pol = NULL; if (orig) pol = new policy_t(orig); } }; /* the start and stop message types MUST match rfc2866 Acct-Status-Type Value */ #define ACCT_START 1 #define ACCT_STOP 2 #define ACCT_INTERIM_UPDATE 3 #define ACCT_TC_USERREQ 1 /* Remote termination */ #define ACCT_TC_NOCARR 2 /* Link Disconnection */ #define ACCT_TC_IDLE 4 /* Idle Timeout */ #define ACCT_TC_STIME 5 /* Session Timeout */ #define ACCT_TC_NONEED 12 /* BoD disconnect */ #define ACCT_TC_HOSTREQ 18 /* Local termination */ #define MAX_AC_MSGS 128 /* Queue no more than 16 accounting messages */ class AcctMessage_t { public: unsigned type; /* ACCT_START or ACCT_STOP */ unsigned term_cause; unsigned long long in_octets; unsigned long long out_octets; unsigned long long in_packets; unsigned long long out_packets; Call *call; char port[PORT_NAME_LEN]; /* Name of port concerned */ char dev_class[CLASS_NAME_LEN]; /* Name of device class */ char user[USER_NAME_LEN]; /* Authentication username */ char ifname[16]; /* Interface name */ char reason[256]; char phone[PHONE_LEN]; u32 loc_ip_address; u32 rem_ip_address; u32 connected_time; char qos_profile_name[256]; }; #define MAX_PROXY_MSGS 128 /* Queue no more than 16 proxy messages */ class ProxyMsg_t { public: u32 dst_addr; }; #define MAX_CFG_MSGS 128 /* Queue no more than 16 config messages */ class CfgMessage_t { public: void (*reserved1)(void *, OptionSet_t *); void *reserved2; OptionSet_t *m_options; OptionSet_t options; CfgMessage_t() { reserved1 = NULL; reserved2 = NULL; m_options = &options; } void Set(CfgMessage_t *orig) { reserved1 = orig->reserved1; reserved2 = orig->reserved2; if (orig->m_options) { options.Set(orig->m_options); m_options = &options; } else { options.Set(&orig->options); m_options = NULL; } } CfgMessage_t operator = (CfgMessage_t &orig) { if (orig.m_options) { options.Set(orig.m_options); m_options = &options; } else m_options = NULL; return *this; } ~CfgMessage_t() { if (m_options != &options) { delete m_options; m_options = NULL; } return; } }; class HangupMsg_t { public: unsigned int ident; /* Unique call identifier */ char port[PORT_NAME_LEN]; /* Port name */ }; class DialMsg_t { public: unsigned int ident; policy_t *pol; char site[SITE_NAME_LEN]; char phone[PHONE_LEN]; }; extern OptionSet_t *get_iface_options(void *iface); extern void DialGotConfig(void *, OptionSet_t *options); extern void babd_GetConfig(void (*cbf)(void *, OptionSet_t *), void *obj, OptionSet_t *options); #endif