/* * TV headend - Access control * Copyright (C) 2008 Andreas Öman * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef ACCESS_H_ #define ACCESS_H_ TAILQ_HEAD(access_entry_queue, access_entry); extern struct access_entry_queue access_entries; typedef struct access_entry { char *ae_id; TAILQ_ENTRY(access_entry) ae_link; char *ae_username; char *ae_password; char *ae_comment; struct in_addr ae_ip; int ae_prefixlen; int ae_enabled; uint32_t ae_rights; uint32_t ae_network; /* derived from ae_ip */ uint32_t ae_netmask; /* derived from ae_prefixlen */ } access_entry_t; #define ACCESS_STREAMING 0x1 #define ACCESS_WEB_INTERFACE 0x2 #define ACCESS_RECORDER 0x4 #define ACCESS_ADMIN 0x8 #define ACCESS_FULL 0x3f /** * Verifies that the given user in combination with the source ip * complies with the requested mask * * Return 0 if access is granted, -1 otherwise */ int access_verify(const char *username, const char *password, struct sockaddr *src, uint32_t mask); void access_init(void); //access_entry_t *access_add(const char *id); //access_entry_t *access_by_id(int id); //void access_delete(access_entry_t *ae); //void access_save(void); #endif /* ACCESS_H_ */